Skip to main content

DHCP Client Relay Server HowTo

Introduction

This document shows how to set up a DHCP server to provide leases to an IP subnet behind a DHCP relay agent.

The DHCP server is be configured with a default pool of addresses and a number of Static Leases. The DHCP relay is configured to append DHCP option 82 to each DHCP message on vlan1 and forward it to the DHCP sever.

                    |
.--.-.
( ( )__
(_, \ ) ,_) Internet/Intranet
'-'--`--'
|
.----+----.
| |
| Server |
| |
'----+----'
| .1
192.168.2.0/24 |
| .2
.----+----.
| | iface: vlan2
| Relay |
| | iface: vlan1
'----+----'
| .1
192.168.1.0/24 |
|
-----+-------+---+---+-------+-----
| | | |
.--+--. .--+--. .--+--. .--+--.
| H1 | | H2 | | H3 | | H4 |
'-----' '-----' '-----' '-----'

Figure 1: DHCP server and relay setup with multiple clients.

Relay Configuration

Configure the Relay to forward any DHCP traffic towards the server.

  • Forward all DHCP messages to the server at 192.168.1.1 port 6767
  • Append option82, to all DHCP messages that pass through the relay
Relay:/#> configure
Relay:/config/#> dhcp-relay
Relay:/config/dhcp-relay/#> server 192.168.1.1:6767
Relay:/config/dhcp-relay/#> iface vlan1
Relay:/config/dhcp-relay/iface-vlan1/#> end
Relay:/config/dhcp-relay/#>
Relay:/config/dhcp-relay/#> option82
Activating Option 82.
Relay:/config/dhcp-relay/option82/#> end
Relay:/config/dhcp-relay/#> leave
Relay:/#>

Server Configuration

The DHCP server is set up to provide a dynamic pool of addresses and a number of static leases for the 192.168.1.0 subnet. With each lease the server will also provide some additional information like: gateway and DNS server. Worth noting is the use of the non-standard port 6767, this means clients cannot accidentally connect to the server for a pool address, but must always go through a relay agent.

Server:/config/#> dhcp-server
Server:/config/dhcp-server/#> server-port 6767
Server:/config/dhcp-server/#> name-server auto
Server:/config/dhcp-server/#> gateway auto

Next up is the subnet to serve:

Server:/config/dhcp-server/#> subnet 192.168.1.0/24
Created new DHCP server for subnet 192.168.1.0.
Server:/config/dhcp-server/subnet-192.168.1.0/#> pool 192.168.1.100 100
Server:/config/dhcp-server/subnet-192.168.1.0/#> end
Server:/config/dhcp-server/#>

We conclude the configuration by setting up a couple of static leases:

  • The first lease use match mac, meaning only the client with that particular MAC address will be offered the host 1 configuration, address 192.168.1.10

  • The second lease use match option82, meaning any host connected to port eth1 on the Relay (identified by its MAC address) will be offered the host 2 configuration, address 192.168.1.20

Server:/config/dhcp-server/#> host 1
Server:/config/dhcp-server/host-1/#> match mac 0c:50:e5:07:24:00
Server:/config/dhcp-server/host-1/#> address 192.168.1.10
Server:/config/dhcp-server/host-1/#> end
Server:/config/dhcp-server/#> host 2
Server:/config/dhcp-server/host-2/#> match option82 circuit-id eth1
Server:/config/dhcp-server/host-2/#> match option82 remoteid-id 0c:50:e5:65:97:00
Server:/config/dhcp-server/host-2/#> address 192.168.1.20
Server:/config/dhcp-server/host-2/#> end
Server:/config/dhcp-server/#> leave
Server:/#>

Status

To verify that addresses are distributed as intended any provided lease can be viewed on the server:

Server:/#> show dhcp
LEASE TIME  MAC ADDRESS       CLIENT ID            IP ADDRESS       HOSTNAME
864000      0c:50:e5:07:24:00 01:0c:50:e5:07:24:00 192.168.1.10     H1
864000      0c:50:e5:a0:b3:00 01:0c:50:e5:a0:b3:00 192.168.1.20     H2
864000      0c:50:e5:b2:55:00 01:0c:50:e5:b2:55:00 192.168.1.114    H3
864000      0c:50:e5:c6:27:00 01:0c:50:e5:c6:27:00 192.168.1.120    H4