I have bonding set up with wlan0 and eth0 as members. This works okay in the sense that I can connect to the internet successfully.

I now wish to setup VirtualBox VM such that internet connectivity is available via bond0. Bridged networking option in VirtualBox does not help. Setting up a host only adapter and then iptables rules does not help either. I set up the iptables rules exactly like libvirt does for its routed network. With a routed networking (using subsubnetting and proxy arp) setup using libvirt, the same VM works fine, but cannot get it to work using VirtualBox.

The iptables rules are:

Code:
# Generated by iptables-save v1.4.12 on Sun Jun  3 22:24:49 2012
*nat
:PREROUTING ACCEPT [1:32]
:INPUT ACCEPT [1:32]
:OUTPUT ACCEPT [49:2870]
:POSTROUTING ACCEPT [47:2640]
COMMIT
# Completed on Sun Jun  3 22:24:49 2012
# Generated by iptables-save v1.4.12 on Sun Jun  3 22:24:49 2012
*mangle
:PREROUTING ACCEPT [125:24781]
:INPUT ACCEPT [125:24781]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [126:13541]
:POSTROUTING ACCEPT [198:22234]
-A POSTROUTING -o vboxnet0 -p udp -m udp --dport 68 -j CHECKSUM --checksum-fill
COMMIT
# Completed on Sun Jun  3 22:24:49 2012
# Generated by iptables-save v1.4.12 on Sun Jun  3 22:24:49 2012
*filter
:INPUT ACCEPT [125:24781]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [126:13541]
-A INPUT -i vboxnet0 -p udp -m udp --dport 53 -j ACCEPT
-A INPUT -i vboxnet0 -p tcp -m tcp --dport 53 -j ACCEPT
-A INPUT -i vboxnet0 -p udp -m udp --dport 67 -j ACCEPT
-A INPUT -i vboxnet0 -p tcp -m tcp --dport 67 -j ACCEPT
-A FORWARD -d 192.168.2.0/27 -o vboxnet0 -j ACCEPT
-A FORWARD -s 192.168.2.0/27 -i vboxnet0 -j ACCEPT
-A FORWARD -i vboxnet0 -o vboxnet0 -j ACCEPT
-A FORWARD -o vboxnet0 -j REJECT --reject-with icmp-port-unreachable
-A FORWARD -i vboxnet0 -j REJECT --reject-with icmp-port-unreachable
COMMIT
# Completed on Sun Jun  3 22:24:49 2012
The dnsmasq command running at guest bootup, to provide DHCP and nameserver config to guests is:
Code:
sudo /usr/sbin/dnsmasq -u libvirt-dnsmasq --strict-order --bind-interfaces --pid-file=/var/run/libvirt/network/vboxnet0.pid --conf-file= --except-interface lo --listen-address 192.168.2.1 --dhcp-range 192.168.2.16,192.168.2.30 --dhcp-leasefile=/var/lib/libvirt/dnsmasq/vboxnet0.leases --dhcp-lease-max=15 --dhcp-no-override --dhcp-hostsfile=$vmSupportingFilesLocation/vboxnet0.hostsfile --dhcp-option=option:dns-server,192.168.2.254
The guest gets the IP address 192.168.1.19 although I am assigning it 192.168.1.16 in the vboxnet0.hosts file:

Code:
08:00:27:73:3D:98,192.168.1.16
The guest shows:

Code:
$route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.1.1     0.0.0.0         UG    100    0        0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U     1000   0        0 eth0
192.168.1.0     0.0.0.0         255.255.255.224 U     0      0        0 eth0


$ ifconfigeth0
      Link encap:Ethernet  HWaddr 08:00:27:73:3d:98  
          inet addr:192.168.1.19  Bcast:192.168.1.31  Mask:255.255.255.224
          inet6 addr: fe80::a00:27ff:fe73:3d98/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:27 errors:0 dropped:0 overruns:0 frame:0
          TX packets:796 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:1600 (1.6 KB)  TX bytes:68114 (68.1 KB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:278 errors:0 dropped:0 overruns:0 frame:0
          TX packets:278 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:21000 (21.0 KB)  TX bytes:21000 (21.0 KB)
Internet connectivity is not available in the guest although 192.168.1.254 is connected to the internet and working fine (tried from the host).

gateway in the guest is set to host IP (vboxnet adapter 192.168.1.1), not to 192.168.1.254.

Similar set up works fine if I use libvirt instead of VirtualBox.

How do I successfully connect to the internet using bond0 and VirtualBox?