0
1
Challenge: to get one Debian VM (Virtualbox) to route all its traffic through another Debian VM (Paralles), both hosted under OS X 10.11.5. I've tried for days, I hope you can help here.
Schema:
vm1 (Virtualbox) ---> ( OS X ) --> vm2 (Parallels) --> internet
This is what I have:
VM1 (the “client”):
- Interface eth1 setup with Host-only Network under Virtualbox, gets ip address 192.168.56.103 with netmask 255.255.255.0
VM2 (the “router”):
Wifi card attached directly to the VM, interface wlan0 with ip 10.251.26.168, connected to internet. wlan0 will be my outgoing interface.
Interface eth0 setup as host-only under Parallels, gets ip address 10.37.129.6 with netmask 255.255.255.0.
On the host:
- VM1 is connected to interface vboxnet0 with ip 192.168.56.1 VM2 is connected to interface vnic1 with ip 10.37.129.2
With this setup pinging the host from each VM and viceversa works perfectly well (on their respective networks).
What I’ve done so far:
Under the host OS X systems I enable ip forwarding and bridge both virtual interfaces together:
bash-3.2# sysctl -w net.inet.ip.forwarding=1
net.inet.ip.forwarding: 1 -> 1
bash-3.2# ifconfig bridge0 create
bash-3.2# ifconfig vnic1 down
bash-3.2# ifconfig vboxnet0 down
bash-3.2# ifconfig bridge0 up addm vnic1 addm vboxnet0
bash-3.2# ifconfig vnic1 up
bash-3.2# ifconfig vboxnet0 up
bash-3.2# ifconfig bridge0
bridge0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
options=3<RXCSUM,TXCSUM>
ether ba:e8:56:14:5f:00
Configuration:
id 0:0:0:0:0:0 priority 0 hellotime 0 fwddelay 0
maxage 0 holdcnt 0 proto stp maxaddr 100 timeout 1200
root id 0:0:0:0:0:0 priority 0 ifcost 0 port 0
ipfilter disabled flags 0x2
member: vnic1 flags=3<LEARNING,DISCOVER>
ifmaxaddr 0 port 14 priority 0 path cost 0
member: vboxnet0 flags=3<LEARNING,DISCOVER>
ifmaxaddr 0 port 12 priority 0 path cost 0
Address cache:
media: autoselect
status: active
bash-3.2# ifconfig vnic1
vnic1: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
options=3<RXCSUM,TXCSUM>
ether 00:1c:42:00:00:09
inet 10.37.129.2 netmask 0xffffff00 broadcast 10.37.129.255
media: autoselect
status: active
bash-3.2# ifconfig vboxnet0
vboxnet0: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
ether 0a:00:27:00:00:00
inet 192.168.56.1 netmask 0xffffff00 broadcast 192.168.56.255
On VM1 (“client”) I add default gateway:
root@vm1:~# ip route del 0/0
root@vm1:~# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.56.0 0.0.0.0 255.255.255.0 U 100 0 0 eth1
root@vm1:~# route add default gw 192.168.56.1
root@vm1:~# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.56.1 0.0.0.0 UG 0 0 0 eth1
192.168.56.0 0.0.0.0 255.255.255.0 U 100 0 0 eth1
On VM2 (“router”) I enable ip forwarding and setup nat:
root@vm2:~# sysctl -w net.ipv4.ip_forward = 1
root@vm2:~# iptables -t nat -A POSTROUTING --out-interface wlan0 -j MASQUERADE
root@vm2:~# iptables -A FORWARD --in-interface eth0 -j ACCEPT
Now, after all this I can ping from VM1 to 192.168.56.1 and 10.37.129.2 (host-side IPs for the virtual network adapters vboxnet0 and vnic1 respectively) but I can’t ping 10.37.129.6. I have also failed so far to access the internet from VM1 through VM2 (from VM1 ping 8.8.8.8):
root@vm1:~# ping -c 1 192.168.56.1
PING 192.168.56.1 (192.168.56.1) 56(84) bytes of data.
64 bytes from 192.168.56.1: icmp_seq=1 ttl=64 time=1.54 ms
--- 192.168.56.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 1.543/1.543/1.543/0.000 ms
root@vm1:~# ping -c 1 10.37.129.2
PING 10.37.129.2 (10.37.129.2) 56(84) bytes of data.
64 bytes from 10.37.129.2: icmp_seq=1 ttl=64 time=0.208 ms
--- 10.37.129.2 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.208/0.208/0.208/0.000 ms
root@vm1:~# ping -c 1 10.37.129.6
PING 10.37.129.6 (10.37.129.6) 56(84) bytes of data.
--- 10.37.129.6 ping statistics ---
1 packets transmitted, 0 received, 100% packet loss, time 0ms
root@vm1:~# ping -c 1 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
--- 8.8.8.8 ping statistics ---
1 packets transmitted, 0 received, 100% packet loss, time 0ms
So I can't get VM1 to route all its traffic through VM2... what am I missing??
In case it helps troubleshooting, I launched wireshark on vm2 ("the router") listening to all interfaces. When I ping 10.37.129.6 from vm1, I see the ARP requests "who was 10.37.129.6 Tell 10.37.129.2", the corresponding ARP reply and the subsequent ICMP originating from vm1's ip (192.168.56.101) so the OS X bridge must be working. But I don't seem to get the ping response back to vm1 neither I see it on wireshark. And when I ping 8.8.8.8 from vm1 I don't see anything in vm2's wireshark session.
Thanks a lot for your help.
Try virtualbox forums, but I think what you're trying to do may be way too technical. These virtualboxes have a lot of low level limitations which will also depend on the peculiarities of the specific host and guest OS-s you're using. So if it doesn't work with Mac-Debian, it may work with Mac-Ubuntu, or Windows-Debian, etc. – None – 2016-07-14T12:16:36.870
Thanks for your comments Florian. My feeling is this should be os-independent, at the end of the day we are talking linux (debian) & freebsd (osx) which are excellent networking os. It's true the hypervisor technologies differ greatly but I'm constrained to to use both Virtualbox and Paralles. Anyway, I'll keep fiddling with the above setup and I'll also try NAT (instead of bridge) on the host side. – Keyser Soze – 2016-07-15T07:35:39.953
By the way, I just found this interesting (although old) post: http://www.tolaris.com/2012/05/16/using-host-networking-and-nat-with-virtualbox-v2-0/. I'll try this and report progress.
– Keyser Soze – 2016-07-15T08:53:55.467