Tag Archives: dhcp relay

Supporting Multiple Subnets from a single DHCP Server

This took a bit of google work to piece together how it works, so just posting it here so others can benefit. The basic scenario is as follows:

  1. I have a number of subnets that I need to assign addresses to
  2. I have a single server with only one interface and it lives on my management network

DHCP Relay SetupSince the server isn’t on each of the subnets I’m going to make user of the UDP Helper functionality built into most routers/L3 switches today. If a DHCP client outside the DHCP server’s subnet broadcasts an address request, it is the helper that forwards the message to the DHCP server. The server then chooses an address and sends the client a unicast message, using the helper to send the message back to the client’s subnet.

The address is reserved for a limited time while the DHCP server waits for a response. If the client responds with another broadcast message, the DHCP server distributes the address.

Router config

This is incredibly simple. On each SVI, simply add the ip helper-address:

interface vlan 10
ip address 10.0.10.1/24
ip helper-address 10.10.10.200
interface vlan 20
ip address 10.0.20.1/24
ip helper-address 10.10.10.200
interface vlan 30
ip address 10.0.30.1/24
ip helper-address 10.10.10.200

Of course, your router should be able to reach the helper address.

DHCP Server Config

This was actually the harder part to hunt down. Basically we just define our subnets without using the “shared-network” statement

authoritative;

# this is the most important line. It specifies the method
# to use to connect to the DNS server and update it.
ddns-update-style none;
ddns-domainname "example.com";
ignore client-updates;


option domain-name              "example.com";
option domain-name-servers      8.8.8.8,8.8.4.4;
option time-offset              0;
option ntp-servers              10.10.10.200;
one-lease-per-client off;
default-lease-time 86400;
max-lease-time 604800;
option ip-forwarding off;


# Subnet for internal hosts
    subnet 10.0.10.0 netmask 255.255.255.0 {
        range 10.0.10.2 10.0.10.254;
        option routers                  10.0.10.1;
        option subnet-mask              255.255.255.0;
    }

subnet 10.0.20.0 netmask 255.255.255.0 {
        range 10.0.20.2 10.0.20.254;
        option routers                  10.0.20.1;
        option subnet-mask              255.255.255.0;
    }
subnet 10.0.30.0 netmask 255.255.255.0 {
        range 10.0.30.2 10.0.30.254;
        option routers                  10.0.30.1;
        option subnet-mask              255.255.255.0;
    }

The server will select the correct subnet, based on the GIADDR (Gateway IP Address) contained in the request e.g. the DHCP Request reaching the server from vlan10 will have GIADDR = 10.0.10.1