9
1
For a test I need to allow routing from my local network to a guest inside a VirtualBox. The guest already have outside access.
So far I enabled ip forwarding on my local machine (OSX 10.9) and added a route to the host-only network on the machine on the local network.
route add -net 192.168.59.0 netmask 255.255.255.0 gw 192.168.0.107
sysctl -w net.ipv4.ip_forward=1
The network look like that.
Local network 192.168.0.104 -> [Wireless 192.168.0.0/24] -> MacOSX 192.168.0.107 (Wifi) & 192.168.59.3 (VboxHost) -> [VBox 192.168.59/24] -> 192.168.59.103
Unless VirtualBox is purposely dropping packet from the outside this should work.
My goal would be for 192.168.0.104
to connect to 192.168.59.103
. So far I can only ping 192.168.59.3
from it.
Also, my guest already have another adapter with a default gw that allow access to the wifi.
What route or network config could I be missing?
Also I could understand the packet getting the my guest, but the guest not being able to reply, however tcpdump show no paquet ever get to guest if say I ping the machine. Also no firewall is running anywhere.
Routing table on my Mac
Destination Gateway Flags Refs Use Netif Expire
default 192.168.0.1 UGSc 42 1 en0
127 127.0.0.1 UCS 0 0 lo0
127.0.0.1 127.0.0.1 UH 6 2943735 lo0
169.254 link#4 UCS 0 0 en0
192.168.0 link#4 UCS 3 0 en0
192.168.0.1 9c:d6:43:c8:cf:e8 UHLWIir 43 21647 en0 1199
192.168.0.104 8:0:27:c2:fc:68 UHLWI 0 7 en0 1068
192.168.0.106 0:15:99:77:73:ed UHLWI 0 82 en0 845
192.168.0.107 127.0.0.1 UHS 2 9114 lo0
192.168.59 link#9 UC 3 0 vboxnet
192.168.59.3 a:0:27:0:0:0 UHLWI 0 69759 lo0
192.168.59.103 link#9 UHRLWIi 2 31866 vboxnet 1
3Any reason you can't just configure your VM's network adapter to be bridged instead of host-only? Your effectively getting the same behavior. – heavyd – 2014-07-25T06:54:02.067
The same? The host only adapter is separate network, while bridged AFAIK will bind the host to my real network. Which inconvenient because IP while change from office, to home, etc. – kkx – 2014-07-25T14:47:59.477
I'm a VMware guy but like @heavyd mentioned, you should be able to setup a private or "host only" LAN with Virtual Box just like you can with VMware Fusion or Workstation. – SaxDaddy – 2014-07-26T02:46:02.137
@SaxDaddy It's exactly that I'm using but trying to route traffic to it for a test. However like I said not working like it should/want (or it's actually doing too good of a job). The host-only adapter seems to be dropping outside traffic, even if the routing is correct or something in MacOSX is no routing the traffic properly. – kkx – 2014-07-26T22:28:54.727
4I am astounded that no one noticed the error in this configuration, since it is so obvious: in the route add command, the host-only network was configured to use as a gateway a pc outside the host-only network. This cannot possibly work. The correct route should have used as gw the IP address of the mac interface on the host-only adapter, not its default LAN. There are other mistakes (why does lo have an address of 192.168.59.3 in the routing table???) but with the error in route add no progress at all is possible. I leave this note for eventaul readers. – MariusMatutiae – 2017-04-22T08:57:54.120
@MariusMatutiae why don't you post that as a solution instead of a comment? Give him the proper route to add. – HackSlash – 2018-06-29T21:01:44.650
"My goal would be for 192.168.0.104 to connect to 192.168.59.103." Have you considered trying a netmask of 255.255.0.0? – Elder Geek – 2018-07-25T18:40:50.990