0

I'm trying to forward/masquarade some trafic from my guest CentOS6 (virtualbox with bridged connection). Host is OSX Lion. Here is my network layout:

  en1 - host iface
  address: 78.251.xx.yy
  alias: 10.0.2.1

  eth0 - guest iface
  address: 10.0.2.2

Now the connection between the guest and the host is working. Only if I could make the guest to talk to the internet my job would be done.

So I tried this ipfw rule (actually made the things worse - the guest can't talk to host):

ipfw add divert natd all from 10.0.2.2/32 to any via en1

I also tried to enable ip forwarding using this command:

sysctl -w net.inet.ip.forwarding=1

Still no luck.

Bart De Vos
  • 17,761
  • 6
  • 62
  • 81

1 Answers1

1

If you have a bridged connection, you do not need to forward traffic. All you need to do is configure the virtual network adapter with a valid IP address on the same subnet as the host, or let it request one via DHCP.

If you really want the host to be responsible for forwarding traffic from the guest machine and you want to configure this forwarding manually, you first need to set the virtual machine to use a "host-only" or "internal" network. Then work from there. This would be a highly unconventional approach.

The two most common options for configuring virtual machine network adapters to communicate with your LAN and/or the Internet are as follows:

  1. Workstation (virtual machine that is strictly a client): set the virtual network adapter to NAT, let the VM's operating system obtain an IP address using DHCP, and forget about it. Your VM will be able to make outbound connections to any LAN or internet IP address, but it will not accept inbound connections from other computers on your network. Note that this may be undesirable if the host has a private IP address due to "double-NAT" issues.

  2. Server or Peer (virtual machine that offers network services of any kind): bridge the virtual network adapter to a physical network card. Give the virtual machine a valid IP address on the host's subnet either via static assignment or via DHCP. Your VM will function exactly like a physical computer on the host's LAN subnet.

Of course, if a host has multiple network adapters, you also have the option of bridging the virtual adapter to a different card which could be connected to a different LAN, DMZ, etc.

Skyhawk
  • 14,149
  • 3
  • 52
  • 95
  • I can't get another ip from the hosts subnet and still get internet to the guest. My ISP doesn't allow that. This is why I tried to create an internal subnet with the bridged connection.When I select host-only adapter is gives me an error: Invalid settings detected (very verbose, right?) – Alexandru Plugaru Nov 17 '11 at 13:12
  • If you have access to only one IP address on the host's subnet, just use the default "NAT" setting for the guest machine's network adapter. Log into the guest OS and configure it to obtain an IP address using DHCP. – Skyhawk Nov 18 '11 at 14:56