Skip to content

Instantly share code, notes, and snippets.

@zapstar
Created April 13, 2016 07:41
Show Gist options
  • Save zapstar/37edcc2c27779de4ef31b1d4eacc1792 to your computer and use it in GitHub Desktop.
Save zapstar/37edcc2c27779de4ef31b1d4eacc1792 to your computer and use it in GitHub Desktop.
My Dnsmasq configuration on OSX. This acts as both DNS & DHCP server for my VirtualBox host-only network
# Setup taken from
# https://gist.github.com/ramonza/4744623#file-dnsmasq-conf
# More steps can be found here:
# https://github.com/HuaweiTech/lattice/blob/master/docs/dnsmasq-readme.md
# The interface on which Dnsmasq should listen on
interface=vboxnet0
# This + lo0 will be where Dnsmasq will be listening on
# Prevent warnings
bind-interfaces
# Enable the integrated DHCP server
dhcp-range=192.168.56.100,192.168.56.200,infinite
# Alternative DHCP lease file
dhcp-leasefile=/var/lib/dnsmasq.leases
# Any address in .vm is local
local=/vm/
# Expand simple names to FDQN
expand-hosts
# The domain name for Dnsmasq
domain=vm
# Host address
address=/vbox-host.vm/192.168.56.1
# Forward other to here
server=8.8.8.8
server=8.8.4.4
server=208.67.222.222
server=208.67.220.220
  • First create a host-only network if not already done so. Use the IP Address 192.168.56.1 with the netmask 255.255.255.0. Don't enable DHCP server (next tab), it should be unchecked.

  • Make sure two network interfaces are assigned to the VM. The first being a NAT interface (note: NOT NAT Network). The second being a Host-Only Adapter.

  • In the Ubuntu guest the /etc/network/interfaces file should look something similar to below.

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet dhcp

# Secondary network interface
auto eth1
iface eth1 inet dhcp
  • Reboot the guest
  • Click the WiFi icon on the menu bar and select Open Network Preferences...

  • Select WiFi Adapter or any other adapter you're interested in, then click on Advanced... and head over to the DNS tab.

  • Add these two IPs as your DNS Servers: 192.168.56.1 and 8.8.8.8. The second server is added so that we can resolve hostnames even when no VirtualBox VMs are running.

  • Finally add the vm to your search domain.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment