Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

  eth0 - guest iface

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 to any via en1

I also tried to enable ip forwarding using this command:

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

Still no luck.

share|improve this question
Try add nat to all subnet – Biriukov Nov 13 '11 at 13:15
00100 divert 8668 ip from to any via en1 - same effect. – Alexandru Plugaru Nov 14 '11 at 10:49
Is iptables enabled? – Bart De Vos Nov 16 '11 at 0:10
iptables is a frontend tool for Linux's netfilter => no iptables in OSX – Alexandru Plugaru Nov 17 '11 at 13:11
up vote 1 down vote accepted

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.

share|improve this answer
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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.