For a long time I’ve been annoyed that VirtualBox issues a different DHCP lease to a virtual machine guest after a while, and there doesn’t seem to be any way to change that within VirtualBox itself. I asked on Twitter, and got a response which trigerred an aha!

virtualbox dhcp disable

I disabled VirtualBox’ DHCP for the interface I’m interested in, and configured a dnsmasq on my notebook.

port=53
interface=vboxnet0
dhcp-range=192.168.56.101,192.168.56.254,255.255.255.0,12h
dhcp-option=option:dns-server,192.168.56.1
dhcp-leasefile=/usr/local/var/lib/misc/dnsmasq/dnsmasq.leases

Minutes later I saw this on the console upon launching dnsmasq and then a VirtualBox guest I already had:

dnsmasq: started, version 2.78 cachesize 150
dnsmasq: compile time options: IPv6 GNU-getopt no-DBus no-i18n no-IDN DHCP DHCPv6 no-Lua TFTP no-conntrack no-ipset auth no-DNSSEC loop-detect no-inotify
dnsmasq: setting --bind-interfaces option because of OS limitations
dnsmasq-dhcp: DHCP, IP range 192.168.56.101 -- 192.168.56.254, lease time 12h
dnsmasq: reading /etc/resolv.conf
dnsmasq: using nameserver 192.168.1.82#53
dnsmasq: using nameserver 192.168.1.113#53
dnsmasq: read /etc/hosts - 3 addresses


dnsmasq-dhcp: DHCPDISCOVER(vboxnet0) 192.168.56.102 08:00:27:7d:aa:db
dnsmasq-dhcp: DHCPOFFER(vboxnet0) 192.168.56.102 08:00:27:7d:aa:db
dnsmasq-dhcp: DHCPREQUEST(vboxnet0) 192.168.56.102 08:00:27:7d:aa:db
dnsmasq-dhcp: DHCPACK(vboxnet0) 192.168.56.102 08:00:27:7d:aa:db cen7pdns

Lovely. It works.

VirtualBox and DHCP :: 07 Mar 2018 :: e-mail