Using guest as router, serving host and others: Odd behaviou

Discussions related to using VirtualBox on Mac OS X hosts.
Post Reply
Michael Tyson
Posts: 2
Joined: 23. Sep 2011, 23:26
Primary OS: Mac OS X other
VBox Version: OSE other
Guest OSses: TinyCoreLinux

Using guest as router, serving host and others: Odd behaviou

Post by Michael Tyson »

Hi!

I'm using TinyCoreLinux as a guest, on an OS X host, in order to use an RTL8187L-based USB WiFi device than has a horrendously bad OS X driver. So, the guest runs the WiFi device, and runs IP masquerading, along with a DNS caching server and DHCP server, in order to act as a router for the host, and other computers on the local network.

I'm using bridged networking on the host's builtin wireless adapter, with plans to set up an ad hoc network from the host, to which another laptop and a couple of iPhones can connect, so that they can access the Internet via the linux guest VM (on the bridged wifi interface).

So,

Internet (RTL8187L) <-- TinyCoreLinux Guest (IP MASQ) <-- { OS X Host, other local computers/iPhones }

I'm seeing some truly baffling stuff, though, and I was wondering if anyone might have any ideas.

This works absolutely marvellously from the host - although the DHCP server doesn't seem to work (oddly, I don't know why), I can manually assign an appropriate IP address and assign the VM's IP addresss as the host's router setting, and I can happily access the Internet from the host.

Other computers on the local network (communicating via the host's wifi card, that is) instantly get assigned an address from the guest's DHCP server, and they can happily resolve via DNS (from the guest's DNS cache server). So far so good. However, no guests can actually access the Internet, load websites, etc. Timeouts aplenty. There's one bizarre exception - if I load a website (or access a mail server, etc) from the host first, THEN any other computer on the network can access that server too! Note than I can still resolve the IP of any server from one of the other computers - it's only actual communication with the server that doesn't work, unless I initiate communication from the host, first.

So, in summary:

- Guest VM is the router, running on bridged wifi adapter of host
- Host can access Internet through the guest router, perfectly
- Other computers on the network can talk to the guest (DHCP, DNS, PING, etc),
- ...but can only actually access the Internet if the host accesses the server in question first.

I did some logging using iptables, and noticed that I couldn't actually see any outgoing requests from the other computers, except for the initial DNS lookup. The request was only happening once the remote server had already been contacted from the host computer. This seems insane, though, so I could be losing my marbles and misinterpreting the log.

Also, it's worth noting that I created another VM, also using the same bridged interface, and from that VM I could instantly obtain a DHCP address, and access the Internet. That says to me that something weird is going on with the actual interface bridging, with respect to the outside world, but not knowing any implementation details, I'm flying blind.

Does anyone have any clue about what could be happening?

Failing that, my Plan B is to create a host-only interface to communicate with the guest. Then, I'll use Internet Sharing on the host to serve other computers on the local network, via the host-only interface. To make that work, though, I need to find a way to make the 'vboxnet0' virtual interface visible in System Preferences - any ideas?

Many, many thanks in advance.

Cheers,
Michael
Michael Tyson
Posts: 2
Joined: 23. Sep 2011, 23:26
Primary OS: Mac OS X other
VBox Version: OSE other
Guest OSses: TinyCoreLinux

Re: Using guest as router, serving host and others: Odd beha

Post by Michael Tyson »

Righto, I've come up with a solution - I couldn't get the bridged adapter working the way I expect, and I suspect that the absence of outgoing requests in the log suggests some odd stuff going on with the bridge itself.

There doesn't seem to be any way to get System Preferences to see the host-only adapter vboxnet0, but it turns out not to be necessary, because it's possible to implement a NAT system without using System Preferences.

I wrote up a tutorial on how to setup a VM to drive a network adapter and share the resulting internet connection to the host on my blog: http://atastypixel.com/blog/using-a-vir ... -your-mac/
Post Reply