DHCP server on a /32 subnet

How to force a DHCP server to hand over /32s, while running on a different /32 subnet.

What? Why?

These are all very valid questions. Let me explain.

At my job, I designed and built a virtualization platform for creating hourly billed virtual machines. One of the challenges was building a robust and scalable network. I wanted to maximize IP space utilization efficiency as well, so allocating a fixed subnet per each hypervisor was out of the question.

All this led me to design a Layer 3-only network, where routes to each virtual machine are redistributed over iBGP.

However, this somewhat complicates things. Since each virtual machine is basically only connected to the hypervisor, one would typically need a /31 for each virtual machine. One address for the VM and one for the default gateway, isn’t that right?

It turns out that it is possible to overcome this limitation with the following design:

VM interface IP (on hypervisor):
VM interface IP (in the VM):

Routes in the VM: dev eth0 scope link
  default via dev eth0 

Routes on the hypervisor: via dev virbr13 metric 1

This solution actually works fantastically.

However, there is one issue. How do you assign addresses and routes to the VMs?

Hacking DHCP

Manual IP assignment per each virtual machine is painful and slow. Would it be possible to assign addresses automatically? Maybe even with a standard protocol like DHCP?

After spending lots of hours researching possible solutions and a hefty amount of trial and error, I found the following configuration works reliably:

option domain-name-servers,;
option subnet-mask;
option routers;
shared-network "virbr13" {
    subnet netmask {
    subnet netmask {
lease-file-name "/var/lib/dhcpd/virbr13.leases";
deny declines;
deny duplicates;
one-lease-per-client true;
ignore-client-uids true;
allow unknown-clients;

dhcpd will listen for DHCP requests on Once such request arrives, it will however advertise with as the default gateway, as well as an interface route for

Note that only few DHCP servers allow this sort of configuration.
ISC dhcpd works, dnsmasq does not.


Add yours

  1. Thanks for the writeup. Very useful.
    I’m trying to get /32 addresses using this technique for all clients. First client gets with, but all other clients get “no free leases” error. If I try to add a range in the conf file (instead of just, I get error that the range isn’t in the netmask (which of course only has 1 IP).
    Any way to get multiple clients get different IPs, but force netmask to ?

    • Hi, generally this approach only works if you have a point-to-point type network with only one client in it. In my case, each VM gets its own dedicated network bridge and runs its own DHCP instance.

      In case you have multiple hosts in your network, you would generally want to use a more suitable subnet mask that’s not a /32

Leave a Reply...

%d bloggers like this: