Lesson Contents
Cisco IOS devices can be configured as DHCP servers and it’s also possible to configure a static binding for certain hosts. This might sound easy but there’s a catch to it…in this lesson I’ll show you how to configure this for a Cisco router and Windows 7 and Linux host. This is the topology I’ll be using:
The router called “DHCP” will be the DHCP server, R1 and the two computers will be DHCP clients. Everything is connected to a switch and we’ll use the 192.168.1.0 /24 subnet. The idea is to create a DHCP pool and use static bindings for the two computers and R1:
- R1: 192.168.1.100
- Windows 7: 192.168.1.110
- Linux: 192.168.1.120
First we will create a new DHCP pool for the 192.168.1.0 /24 subnet:
DHCP(config)#ip dhcp pool MYPOOL
DHCP(dhcp-config)#network 192.168.1.0 255.255.255.0
Whenever a DHCP client sends a DHCP discover it will send its client identifier or MAC address. We can see this if we enable a debug on the DHCP server:
DHCP#debug ip dhcp server packet
Cisco Router DHCP Client
Now we’ll configure R1 to request an IP address:
R1(config)#interface fastEthernet 0/0
R1(config-if)#no shutdown
R1(config-if)#ip address dhcp
In a few seconds you will see the following message on the DHCP server:
DHCP#
DHCPD: DHCPDISCOVER received from client 0063.6973.636f.2d63.3230.382e.3135.6430.2e30.3030.302d.4661.302f.30 on interface FastEthernet0/0.
When a Cisco router sends a DHCP Discover message it will include a client identifier to uniquely identify the device. We can use this value to configure a static binding, here’s what it looks like:
DHCP(config)#ip dhcp pool R1-STATIC
DHCP(dhcp-config)#host 192.168.1.100 255.255.255.0
DHCP(dhcp-config)#client-identifier 0063.6973.636f.2d63.3230.382e.3135.6430.2e30.3030.302d.4661.302f.30
We create a new pool called “R1-STATIC” with the IP address we want to use for R1 and its client identifier. We’ll renew the IP address on R1 to see what happens:
R1#renew dhcp fastEthernet 0/0
Use the renew dhcp command or do a ‘shut’ and ‘no shut’ on the interface of R1 and you’ll see this on the DHCP server:
DHCP#
DHCPD: Sending DHCPOFFER to client 0063.6973.636f.2d63.3230.332e.3065.3232.2e30.3030.302d.4661.302f.30 (192.168.1.100).
As you can see above the DHCP server uses the client identifier for the static binding and assigns IP address 192.168.1.100 to R1. If you don’t like these long numbers you can also configure R1 to use the MAC address as the client identifier instead:
R1(config)#interface fastEthernet 0/0
R1(config-if)#ip address dhcp client-id fastEthernet 0/0
This tells the router to use the MAC address of its FastEthernet 0/0 interface as the client identifier, you’ll see this change on the DHCP server:
DHCP#
DHCPRELEASE message received from client 0063.6973.636f.2d63.3230.382e.3135.6430.2e30.3030.302d.4661.302f.30 (192.168.1.100).
DHCPD: Finding a relay for client 0063.6973.636f.2d63.3230.382e.3135.6430.2e30.3030.302d.4661.302f.30 on interface FastEthernet0/0.
DHCPD: DHCPDISCOVER received from client 01c2.0815.d000.00 on interface FastEthernet0/0.
Of course now we have to change the binding on the DHCP server to match the MAC address:
DHCP(config)#ip dhcp pool R1-STATIC
DHCP(dhcp-config)#no client-identifier 0063.6973.636f.2d63.3230.382e.3135.6430.2e30.3030.302d.4661.302f.30
DHCP(dhcp-config)#client-identifier 01c2.0815.d000.00
Do another release on R1:
R1#renew dhcp fastEthernet 0/0
And you’ll see that R1 gets its correct IP address from the DHCP server and is being identified with its MAC address:
DHCP#
DHCPD: DHCPDISCOVER received from client 01c2.0815.d000.00 on interface FastEthernet0/0.
DHCPD: Sending DHCPOFFER to client 01c2.0815.d000.00 (192.168.1.100).
So that’s how the Cisco router requests an IP address. Let’s look at the Windows 7 host now to see if there’s a difference.
Windows 7 DHCP Client
C:UsersWindows7>ipconfig /release
C:UsersWindows7>ipconfig /renew
This is what you’ll find on the DHCP server:
DHCP#
DHCPD: DHCPDISCOVER received from client 0100.0c29.7e06.12 on interface FastEthernet0/0.
Windows 7 uses its MAC address as the client identifier. We can verify this by looking at ipconfig:
C:UsersWindows7>ipconfig /all
Windows IP Configuration
Host Name . . . . . . . . . . . . : Windows7
Primary Dns Suffix . . . . . . . :
Node Type . . . . . . . . . . . . : Hybrid
IP Routing Enabled. . . . . . . . : No
WINS Proxy Enabled. . . . . . . . : No
Ethernet adapter Local Area Connection:
Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : Intel(R) PRO/1000 MT Network Connection
Physical Address. . . . . . . . . : 00-0C-29-7E-06-12
That’s easy enough, we’ll create another static binding on the DHCP server so that our Windows 7 computers receives IP address 192.168.1.110:
DHCP(config)#ip dhcp pool WIN7-STATIC
DHCP(dhcp-config)#host 192.168.1.110 255.255.255.0
DHCP(dhcp-config)#client-identifier 0100.0c29.7e06.12
Let’s verify our work:
C:UsersWindows7>ipconfig /release
C:UsersWindows7>ipconfig /renew
This is what the debug on the DHCP server will tell us:
DHCP#
DHCPD: DHCPRELEASE message received from client 0100.0c29.7e06.12 (192.168.1.3). DHCPD: DHCPDISCOVER received from client 0100.0c29.7e06.12 on interface FastEthernet0/0. DHCPD: Sending DHCPOFFER to client 0100.0c29.7e06.12 (192.168.1.110).
There you go, Windows 7 has received the correct IP address. Last but not least is our Linux computer which acts a little different.
Linux DHCP Client
Linux (Ubuntu) in my example acts a little different when it comes to DHCP client, let me show you:
# sudo dhclient eth0
The DHCP server shows this:
DHCP#
DHCPD: DHCPDISCOVER received from client 000c.29c9.4bb1 on interface FastEthernet0/0.
DHCPD: Sending DHCPOFFER to client 000c.29c9.4bb1 (192.168.1.4).
We see the MAC address of the linux server so we’ll create a static binding that matches this:
DHCP(config)#ip dhcp pool LINUX-STATIC
DHCP(dhcp-config)#host 192.168.1.120 255.255.255.0
DHCP(dhcp-config)#client-identifier 000c.29c9.4bb1
We’ll release the IP address on our Linux host:
# sudo dhclient eth0 -r
# sudo dhclient eth0
Now take a good look at the debug:
DHCP#
DHCPD: DHCPRELEASE message received from client 000c.29c9.4bb1 (192.168.1.4).
DHCPD: DHCPDISCOVER received from client 000c.29c9.4bb1 on interface FastEthernet0/0.
DHCPD: Sending DHCPOFFER to client 000c.29c9.4bb1 (192.168.1.4).
That’s not good, even though we configured the client identifier it’s not working. Let’s double check the MAC address:
Hi Catalin,
Your message wasn’t deleted but not approeved before, I do this manually because of spam. I think this example should help you:
http://networklessons.com/network-services/cisco-ios-dhcp-relay-agent/
If not, let me know.
Rene
Thanks Jose!
Hello Rene,
Is the client-identifier configured on the dhcp server is not the mac address of the dhcp client? Is it a different value?(real world)
I tried to configure the “ip address dhcp client-id fa0/0” on the dhcp client but it’s not getting the correct ip im expecting. I already have a dhcp pool for it on the dhcp server.:
DHCP SERVER:
... Continue reading in our forumHi Don,
It’s probably the DHCP client that is bugging you. Take a look here:
https://networklessons.com/network-services/cisco-ios-dhcp-client-identifier/
Rene
Hello Chandra
Yes you are correct, that was my mistake. You cannot explicitly state the MAC address of the interface to be used as a client ID. You can either use the long string of characters that identify the client, or use the interface as a keyword to send the MAC address as the client ID.
I tried labbing up the scenario and I find the following. I am running the command:
R1(config-if)#ip address dhcp client-id GigabitEthernet 0/1
My MAC address of this interface is fa16.3e5d.5fe6. However, when I debug DHCP packets and see what client ID is being sent
... Continue reading in our forum