DHCP IP Per-Port HowTo
Introduction
This document shows how to set up the DHCP server to hand out a static IP address (lease) to clients connected to a specific physical port.
.---------------------.
| Switch | DHCP Server/Relay
| | iface: vlan1
| eth1 eth2 | 192.168.1.0/24
'--+---------------+--'
|.132 |.55
| |
.--+--. .--+--.
| H1 | | H2 |
'-----' '-----'
In the case depicted above, clients connected to port eth1
receive an
address from the server’s pool of addresses. Clients on port eth2
on
the other hand always receive a specific address, 192.168.1.55. Hence,
the most obvious use-case for the latter is to have a single end-device
connected to eth2
.
For more information about any of the sub-systems used and their configurations options, see:
Configuration
Configuration of both DHCP server and DHCP relay services. First, we set
up the relay to forward all DHCP traffic to the local DHCP server. The
key setting is option82
, which makes sure the relay agent appends DHCP
Option 82 port information for the server:
example:/#> configure example:/config/#> dhcp-relay example:/config/dhcp-relay/#> server 127.0.0.1 example:/config/dhcp-relay/#> iface vlan1 example:/config/dhcp-relay/iface-vlan1/#> port eth2 example:/config/dhcp-relay/iface-vlan1/port-eth2/#> circuitid-type portname example:/config/dhcp-relay/iface-vlan1/port-eth2/#> end example:/config/dhcp-relay/iface-vlan1/#> end example:/config/dhcp-relay/#> option82 Activating Option 82. example:/config/dhcp-relay/option82/#> remoteid-type mac example:/config/dhcp-relay/option82/#> end example:/config/dhcp-relay/#> end example:/config/#>
We can now move to set up the DHCP server, starting with the default subnet and address pool.
example:/config/#> dhcp-server example:/config/dhcp-server/#> subnet 192.168.1.0/24 Created new DHCP server for subnet 192.168.1.0. example:/config/dhcp-server/subnet-192.168.1.0/#> pool 192.168.1.100 100 example:/config/dhcp-server/subnet-192.168.1.0/#> end example:/config/dhcp-server/#>
Next, we set up the static lease for host(s) connected to port eth2
.
The match option82
configuration is what the server use to identify
the correct port (circuit-id) and its own MAC address for iface vlan1
(remote-id).
example:/config/dhcp-server/#> host example:/config/dhcp-server/host-1/#> match option82 circuit-id string eth2 example:/config/dhcp-server/host-1/#> match option82 remoteid-id string 0c:50:e5:65:97:00 example:/config/dhcp-server/host-1/#> address 192.168.1.55 example:/config/dhcp-server/host-1/#> end example:/config/dhcp-server/#> leave example:/#>
Status
To verify that addresses are distributed as intended any provided lease can be viewed on the server:
example:/#> show dhcp-clients 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.132 H1 864000 0c:50:e5:65:97:00 01:0c:50:e5:65:97:00 192.168.1.55 H2