Assign a Static IP Address to a VirtualBox Guest with a NAT Network Without Accessing the Guest

I am using VirtualBox 5.2.18 on Ubuntu Server 18.04. I have several VirtualBox guests machines sharing a NAT Network intnet. Currently, intnet has a DHCP server (set up by VirtualBox) that automatically assigns dynamic IP's to the guests. This works fine, but I would like the DHCP server to assign static IP's to specific guests based on their network interface's MAC address. Static IP's can be set inside the guests, but that takes time and is guest OS dependent. Is there a way, in VirtualBox, to assign static IP's to the guests?

There is a an executable in the VirtualBox installation folder called VBoxNetDHCP. Judging by the output of VBoxNetDHCP, it seems to allow for static IP assignment by MAC address. I cannot get it to work though, and documentation for it is virtually nonexistent.


Normally when I do things like this (and I do it a lot) I tend to use a VM acting as a network server that does things like DHCP, DNS - both caching for the world and locally spoofing fake.tld - etc.

Simplest way is to do a base, bare install of Debian via the netinstall image - select none of the package groups other than the ssh server option and perhaps "standard utilities".

Once it is up and running, to turn it into a DHCP server for your internal VM network, install the isc-dhcp-server package. Then edit /etc/dhcp/dhcpd.conf

Here's a simple example from mine. This sets a short lease time (5 minutes), sets the client search-domain, etc. to "fake.tld", points their dns queries to 192.168.1.2, and gives out addresses in the range of 10.99.98.80-100 with 24 bits of netmask. Note that the VM doing this must have an adapter configured with an IP within the 10.99.98.0/24 subnet.

In addition to the general pool, I give the device with the MAC address of 80:c1:6e:2b:b6:cd an explicitly defined lease (as well as any other option like a DNS server to use, gateway, etc) for the .110 ip. Any such "static leases" must be for addresses OUTSIDE of your dynamic range, but within the subnet configured in both the config file AND on the network adapter of the machine hosting the service.

When you add a new host and you want it to have a specific IP, simply add another host stanza - the host name doesn't need to match whatever the client sends but it does need to be unique in the file. After you've added it, restart the service service isc-dhcp-server restart

ddns-update-style none;
option domain-name "fake.tld";
option domain-name-servers 192.168.1.2;
option domain-search "fake.tld";
default-lease-time 600;
max-lease-time 720;
authoritative;
log-facility local7;

subnet 10.99.98.0 netmask 255.255.255.0{
    range 10.99.98.80 10.99.98.100;
    option routers 10.99.98.1;
}

host lr-tv {
    hardware ethernet 80:c1:6e:2b:b6:cd;
    fixed-address 10.99.98.110;
    option routers 10.99.98.1;
    option domain-name-servers 192.168.1.2;
}