Tags

, ,

IP Address reservation is a commonly used feature in any DHCP deployment. You may want to have fixed IPs for certain hosts (like printers, BMS devices) without configuring them for static IPs. All other hosts will get dynamically assign IP without having a requirement to  keep the same IP all the time.

In this post we will see how we can do this on IOS DHCP server. There are primarily two ways of doing this.

1. Address reservation under the same DHCP pool configuration.
2. Defining multiple host pool for each static Hosts.

There are two terms used in DHCP configuration to identify a client.

1. Hardware Address (chaddr)
2. Client Identifier

Hardware Address: It is the MAC address of the client device who is requesting an DHCP IP. This is the value of the CHADDR (Client Hardware Address) field of the BootP message.

Client Identifier: This is used by DHCP client to identify them-self to DHCP server instead of using CHADDR (hardware address). Usually this is derived from the hardware address. In  most deployments you can derive client Identifier by adding “01” prefix to its hardware address.  For example if your client MAC address is “001f.1618.dfec” then client identifier would be “0100.1f16.18df.ec”.

Why this is important in IOS DHCP configurations ? A DHCP server needs to use some unique identifier to associate a client with its lease. The client MAY choose to explicitly provide the identifier through the ‘client identifier‘ option. If the client supplies a ‘client identifier’, the client MUST use the same ‘client identifier’ in all subsequent messages, and the server MUST use that identifier to identify the client. If the client does not provide a ‘client identifier’ option, the server MUST use the contents of the ‘chaddr‘ field to identify the client.

This mean DHCP server always prefer “Client Identifier” over “Hardware Address” when allocating IP addresses to clients. Therefore you have to use “Client ID” option when reserving IPs to client instead of “hardware-address”.

You can configure IOS DHCP server to ignore BOOTP request (then it will only responds to DHCP discovery or request messages coming from clients). You can use the following CLI command to do this.

ip dhcp bootp ignore

Now lets configure an  IP address reservation using a single DHCP pool. Command to use is “address <ip-address> {hardware-address|client-id} <mac-add|client-id>“. For the above mentioned reason, you have to always use Client-ID option when configuring this.

CAT2(config)#ip dhcp pool VLAN9
CAT2(dhcp-config)#address ?
  A.B.C.D  IP address in dotted-decimal notation

CAT2(dhcp-config)#address 192.168.9.199 ?
  client-id         Client identified by Client-ID option
  hardware-address  Client identified by MAC address

CAT2(dhcp-config)#address 192.168.9.199 cl
CAT2(dhcp-config)#address 192.168.9.199 client-id ?
  WORD  Client MAC or Client-ID value

Here is the full DHCP pool configuration for an address reservation for a device with MAC address (001f.1618.dfec) or client ID (0100.1f16.18df.ec)

ip dhcp pool VLAN9
   network 192.168.9.0 255.255.255.0
   default-router 192.168.9.1 
   domain-name mrn.com
   dns-server 192.168.200.1 
   address 192.168.9.199 client-id 0100.1f16.18df.ec

You can verify this client will get 192.168.9.199 IP when they connect to network. You can use “debug ip dhcp server events” to verify this.

CAT2#
*Mar  9 09:17:58.356 AEDT: DHCPD: Sending notification of DISCOVER:
*Mar  9 09:17:58.356 AEDT:   DHCPD: htype 1 chaddr 001f.1618.dfec
*Mar  9 09:17:58.356 AEDT:   DHCPD: interface = Vlan9
*Mar  9 09:17:58.356 AEDT:   DHCPD: class id 4d53465420352e30
*Mar  9 09:17:58.356 AEDT:   DHCPD: out_vlan_id 0
*Mar  9 09:17:58.356 AEDT: DHCPD: Sending notification of DISCOVER:
*Mar  9 09:17:58.356 AEDT:   DHCPD: htype 1 chaddr 001f.1618.dfec
*Mar  9 09:17:58.356 AEDT:   DHCPD: interface = Vlan9
*Mar  9 09:17:58.356 AEDT:   DHCPD: class id 4d53465420352e30
*Mar  9 09:17:58.356 AEDT:   DHCPD: out_vlan_id 0
*Mar  9 09:17:58.356 AEDT: DHCPD: DHCPOFFER notify setup address 192.168.9.199 mask 255.255.255.0
*Mar  9 09:17:58.356 AEDT: DHCPD: Sending notification of ASSIGNMENT:
*Mar  9 09:17:58.356 AEDT:  DHCPD: address 192.168.9.199 mask 255.255.255.0
*Mar  9 09:17:58.356 AEDT:   DHCPD: htype 1 chaddr 001f.1618.dfec
*Mar  9 09:17:58.356 AEDT:   DHCPD: lease time remaining (secs) = 4294967295
*Mar  9 09:17:58.356 AEDT:   DHCPD: interface = Vlan9
*Mar  9 09:17:58.356 AEDT:   DHCPD: out_vlan_id 0
*Mar  9 09:18:20.905 AEDT: DHCPD: checking for expired leases.

The otherway of doing this is create host IP pool for this device. First of all you have to remove the previous reservation if you are using the same cleint.

CAT2(config)#
ip dhcp excluded-address 192.168.9.1 192.168.9.99

ip dhcp pool VLAN9
   network 192.168.9.0 255.255.255.0
   default-router 192.168.9.1 
   domain-name mrn.com
   dns-server 192.168.200.1
   no  address 192.168.9.199 client-id 0100.1f16.18df.ec

ip dhcp pool PRINTER-1
   host 192.168.9.99 255.255.255.0
   client-identifier 0100.1f16.18df.ec

You can verify the client will get allocated IP when connecting to the network. Here is the “debug ip dhcp server events” output.

*Mar  9 10:16:02.022 AEDT: DHCPD: Sending notification of DISCOVER:
*Mar  9 10:16:02.022 AEDT:   DHCPD: htype 1 chaddr 001f.1618.dfec
*Mar  9 10:16:02.022 AEDT:   DHCPD: interface = Vlan9
*Mar  9 10:16:02.022 AEDT:   DHCPD: class id 4d53465420352e30
*Mar  9 10:16:02.022 AEDT:   DHCPD: out_vlan_id 0
*Mar  9 10:16:02.022 AEDT: DHCPD: Sending notification of DISCOVER:
*Mar  9 10:16:02.022 AEDT:   DHCPD: htype 1 chaddr 001f.1618.dfec
*Mar  9 10:16:02.022 AEDT:   DHCPD: interface = Vlan9
*Mar  9 10:16:02.022 AEDT:   DHCPD: class id 4d53465420352e30
*Mar  9 10:16:02.022 AEDT:   DHCPD: out_vlan_id 0
*Mar  9 10:16:02.022 AEDT: DHCPD: DHCPOFFER notify setup address 192.168.9.99 mask 255.255.255.0
*Mar  9 10:16:02.022 AEDT: DHCPD: Sending notification of ASSIGNMENT:
*Mar  9 10:16:02.022 AEDT:  DHCPD: address 192.168.9.99 mask 255.255.255.0
*Mar  9 10:16:02.022 AEDT:   DHCPD: htype 1 chaddr 001f.1618.dfec
*Mar  9 10:16:02.022 AEDT:   DHCPD: lease time remaining (secs) = 4294967295
*Mar  9 10:16:02.022 AEDT:   DHCPD: interface = Vlan9
*Mar  9 10:16:02.022 AEDT:   DHCPD: out_vlan_id 0

From CCIE wireless lab perspective, if you want to APs to stick with same IP all the time (specially important with H-REAP) you can use these IP reservation configuration unless static IP configuration allowed.

Here is an debug output (both dhcp server events & dhcp packet detail) of an AP getting a reserved IP. In this switch I have not configured “ip dhcp bootp ignore” & you can see switch is replying for both BootP messages & DHCP messages. You can see the difference where bootp reply goes with “hardware address” & DHCP messages go with “client identifier“.

ip dhcp excluded-address 10.10.23.193 10.10.23.200
!
ip dhcp pool VLAN23
   network 10.10.23.192 255.255.255.192
   default-router 10.10.23.193 
   dns-server 192.168.200.1 
   domain-name mrn.com
   address 10.10.23.250 client-id 01cc.ef48.8cfd.41
   address 10.10.23.251 client-id 0100.1e7a.bee0.fe

CAT4#debug ip dhcp server packet detail 
DHCP server packet detail debugging is on.          
CAT4#debug ip dhcp server events 
DHCP server event debugging is on
*Mar  1 06:54:51.328: DHCPD: Reload workspace interface Vlan23 tableid 0.
*Mar  1 06:54:51.328: DHCPD: tableid for 10.10.23.193 on Vlan23 is 0
*Mar  1 06:54:51.328: DHCPD: client's VPN is .
*Mar  1 06:54:51.328: DHCPD: using received relay info.
*Mar  1 06:54:51.328: DHCPD: Sending notification of DISCOVER:
*Mar  1 06:54:51.328:   DHCPD: htype 1 chaddr 001e.7abe.e0fe
*Mar  1 06:54:51.328:   DHCPD: interface = Vlan23
*Mar  1 06:54:51.328:   DHCPD: class id 436973636f204150206331313330
*Mar  1 06:54:51.328:   DHCPD: out_vlan_id 0
*Mar  1 06:54:51.328: DHCPD: DHCPDISCOVER received from client 0100.1e7a.bee0.fe on interface Vlan23.
*Mar  1 06:54:51.328: DHCPD: using received relay info.
*Mar  1 06:54:51.328: DHCPD: Sending notification of DISCOVER:
*Mar  1 06:54:51.328:   DHCPD: htype 1 chaddr 001e.7abe.e0fe
*Mar  1 06:54:51.328:   DHCPD: interface = Vlan23
*Mar  1 06:54:51.328:   DHCPD: class id 436973636f204150206331313330
*Mar  1 06:54:51.328:   DHCPD: out_vlan_id 0
*Mar  1 06:54:51.328: DHCPD: DHCPOFFER notify setup address 10.10.23.251 mask 255.255.255.192
*Mar  1 06:54:51.328: DHCPD: Sending DHCPOFFER to client 0100.1e7a.bee0.fe (10.10.23.251).
*Mar  1 06:54:51.328: DHCPD: no option 125
*Mar  1 06:54:51.328: DHCPD: broadcasting BOOTREPLY to client 001e.7abe.e0fe.
*Mar  1 06:54:51.337: DHCPD: Reload workspace interface Vlan23 tableid 0.
*Mar  1 06:54:51.337: DHCPD: tableid for 10.10.23.193 on Vlan23 is 0
*Mar  1 06:54:51.337: DHCPD: client's VPN is .
*Mar  1 06:54:51.337: DHCPD: DHCPREQUEST received from client 0100.1e7a.bee0.fe.
*Mar  1 06:54:51.337: DHCPD: Sending notification of ASSIGNMENT:
*Mar  1 06:54:51.337:  DHCPD: address 10.10.23.251 mask 255.255.255.192
*Mar  1 06:54:51.337:   DHCPD: htype 1 chaddr 001e.7abe.e0fe
*Mar  1 06:54:51.337:   DHCPD: lease time remaining (secs) = 4294967295
*Mar  1 06:54:51.337:   DHCPD: interface = Vlan23
*Mar  1 06:54:51.337:   DHCPD: out_vlan_id 0
*Mar  1 06:54:51.337: DHCPD: Sending DHCPACK to client 0100.1e7a.bee0.fe (10.10.23.251).
*Mar  1 06:54:51.337: DHCPD: no option 125
*Mar  1 06:54:51.337: DHCPD: broadcasting BOOTREPLY to client 001e.7abe.e0fe.

It is important you understand these configuration options.