Simple DHCP and DNS Forwarding for your host-only network

Discussion in 'Parallels Desktop for Mac' started by mcg, Apr 29, 2006.

  1. mcg

    mcg Hunter

    Messages:
    168
    Hey folks,

    Good news! With a little bit of elbow grease, you can get a complete solution to a problem many of us have been wondering about: how to share your Mac OSX connection to the Internet with your Guest OS's using host-only networking mode. In this post

    http://forum.parallels.com/showthread.php?t=726&page=2#16

    user c789a123 gets us part of the way there. Basically, he turns on Internet Connection Sharing in MacOS by tying it to an unused network connection (like Firewire, for example). This gets "natd" going, which does the address translation. Then, you manually set each GuestOS's IP address (10.37.129.x), gateway address (10.37.129.2), and DNS servers (???), and everything works.

    The question is, is there any way to avoid having to do those manual settings? YES!

    The magic ingredient is a utility called DNSMasq, which is available from DarwinPorts:

    http://darwinports.opendarwin.org/

    DNSMasq does two things: it provides simple DNS forwarding, and optionally DHCP service. By using DNSMasq, your Guest OS's DNS servers can be permanently set to 10.37.129.2, and DNSMasq will handle the forwarding of your DNS requests to whatever DNS servers your OSX Host is using. It will even track changes to those DNS servers due to manual changes or DHCP renewals. So no matter where you take your computer, your Guest OS's will get DNS service.

    If you turn on DNSMasq's DHCP service---which is off by default---then you get true, full, automatic configuration of all of your Guest OS's network settings.

    So how do you install and configure DNSMasq? Here's what I did. WARNING: this assumes some real proficiency at the command line, and I do NOT have step-by-step instructions for you. Proceed at your own risk.
    1) First, get DarwinPorts.
    2) Then do a "sudo port install dnsmasq" to download and install dnsmasq.
    3) Copy /opt/local/etc/dnsmsq.conf.sample to /opt/local/etc/dnsmasq.conf. Just to be safe, I cd'ed over to /etc and created a symbolic link to this dnsmasq.conf file, too. You'll probably need a root shell ("sudo bash", etc.) to accomplish this and subsequent steps.
    4) Now, edit the dnsmasq.conf file, and do this:
    --- on the line that begins with "# interface=", change it to "interface=vi2". This causes dnsmasq to listen ONLY to the host-only network.
    --- uncomment the command "bind-interfaces". For some reason, when I started up dnsmasq, the program enabled this "due to OS limitations". So, to save a line in the console log, I just uncommented this.
    --- I personally uncommented the command "no-dhcp-interface=" to turn OFF DHCP, for two reasons: 1) I don't need it now, and 2) I wasn't ready to navigate a full DHCP configuration. If you want to use DHCP, I CANNOT HELP YOU. But I'm sure it will work.
    5) Now you need to get DNSMasq set up as a service and fire it up. To do that, I duplicated the work done on THIS page
    http://www.macosxhints.com/article.php?story=20050420025219402
    but keep in mind: this page shows you how to get BIND working. I did not actually do that---I just duplicated the same steps to get DNSMasq working. So, for example, instead of creating a directory /System/Library/StartupItems/BIND, I created one called DNSMASQ instead. Sorry, I just don't want to transcribe all of my steps for your sake, but this did work for me.

    This seems to work for me! I hope it works for you too. If you run into problems, let's post them here and we can figure them out together. I do think I'll eventually try and get DHCP working. It would be nice, because that way your Guest OS's will keep their network configs the same whether or not you use host-only or bridged networking.
     
  2. mcg

    mcg Hunter

    Messages:
    168
    By the way, if you read that BIND web page

    http://www.macosxhints.com/article.p...50420025219402

    you might wonder why I didn't just implement it, and extend it by sharing the BIND service over the vi2 connection. Well, that's because I couldn't figure out if/how to get BIND to automatically obtain the server list---it seemed like I had to enter the servers by hand, which defeated the purpose of my search.

    If you know how to get BIND to do that, then you could just use BIND instead of DNSMasq---and please, post that here in this thread. But if you use BIND, you have to use BOOTPD too if you want to enable DHCP. DNSMasq seems like an easy way to get both rollled up in one, and it is configured right out of the box for EXACTLY the kind of application we have here.

    If you go the BIND route, though, watch out---some of the comments in that referenced post suggest that using BIND to cache lookups is not necessary and may cause more problems than it's worth. So you may not want to redirect your OSX lookups to that service---but you MAY still want to use it for the host-only network service.
     
    Last edited: Apr 29, 2006
  3. mcg

    mcg Hunter

    Messages:
    168
    Well, uh, nevermind, I think. I have a feeling that Beta6 basically does all this for me. I'm about to check.
     
  4. mcg

    mcg Hunter

    Messages:
    168
    Well, beta 6 seems to have problems with networking, so I don't know what to think. Hold off on trying my hack until we know more.
     

Share This Page