Contents

DHCP Server
Static IP
DHCP Relay

DHCP Server

Let us discuss how to set a Cisco device to become DHCP Server. Use the following network as an example, I will try to set R1 to be the DHCP Server and R2 to be the DHCP Client. E0/0 of R2 should get an IP Address after configuration completed.

dhcp

First, use ip dhcp pool <word> at R1 to enter DHCP Server Pool mode. <word> is the name of this Pool.

R1(config)#ip dhcp pool POOL_1
R1(dhcp-config)#

Then, set the necessary configuration of DHCP Server.

hostname R1
!
ip dhcp pool POOL_1
   network 192.168.12.0 255.255.255.0       //IP range for assignment
   default-router 192.168.12.1              //Default Gateway
   dns-server 192.168.12.101 192.168.12.102 //DNS Server
   lease 7                                  //lease times, default setting is 1 day

To reserve some IP that do not assign to other hosts, we can use the ip dhcp excluded-address <IP> command. The meaning of the first line is to reserve 192.168.12.1. The meaning of the second line is to reserve from 192.168.12.101 to 192.168.12.102.

R1(config)#ip dhcp excluded-address 192.168.12.1
R1(config)#ip dhcp excluded-address 192.168.12.101 192.168.12.102

Of course, we need to set the IP on e0/0.

hostname R1
!
interface Ethernet0/0
 ip address 192.168.12.1 255.255.255.0

Then, configure the IP of e0/0 on R2 to DHCP.

hostname R2
!
interface Ethernet0/0
 ip address dhcp

Interfae e0/0 of R2 can get an IP now.

R2#show interfaces ethernet 0/0 | i Internet
  Internet address is 192.168.12.2/24

Use show ip dhcp binding on R1 to check the IP assignment status. But what is the strange coding at Client-ID/Hardware address/User name?

R1#show ip dhcp binding
Bindings from all pools not associated with VRF:
IP address          Client-ID/              Lease expiration        Type
                    Hardware address/
                    User name
192.168.12.2        0063.6973.636f.2d63.    Mar 08 2002 01:06 AM    Automatic
                    6330.382e.3266.3430.
                    2e30.3030.302d.4574.
                    302f.30

It is Hex code. Try to translate to string.

HEX00636973636f2d636330382e326634302e303030302d4574302f30
String   c i s c o - c c 0 8 . 2 f 4 0 . 0 0 0 0 - E t 0 / 0

The string is cisco-cc08.2f40.0000-Et0/0. It means that the IP address 192.168.12.2 is assigned to a Cisco product which have the MAC Address cc08.2f40.0000 on its Et0/0 interface.

Static IP

As like as a general DHCP Server, Cisco can assign IP depends on different Client (Static IP). First, we need to configure another DHCP Pool. Then, use host <ip> <mask> to assign an IP, in this example, we use 192.168.12.201. And then put the string that we saw in last session followed by client-identifier to define the host.

hostname R1
!
ip dhcp pool STATIC
   host 192.168.12.201 255.255.255.0
   client-identifier 0063.6973.636f.2d63.6330.382e.3266.3430.2e30.3030.302d.4574.302f.30

DHCP Binding Table will show a manual record which have Infinite Lease Time.

R1#show ip dhcp binding
Bindings from all pools not associated with VRF:
IP address          Client-ID/              Lease expiration        Type
                    Hardware address/
                    User name
192.168.12.201      0063.6973.636f.2d63.    Infinite                Manual
                    6330.382e.3266.3430.
                    2e30.3030.302d.4574.
                    302f.30

Reset e0/0 on R2 and it should get the IP 192.168.12.201.

R2(config-if)#shutdown
R2(config-if)#no shutdown
R2(config-if)#end
R2#show interfaces ethernet 0/0 | i Internet
  Internet address is 192.168.12.201/24

DHCP Relay

Since DHCP packets is transmitted by broadcast, if the DHCP Server is not in the same network with DHCP Client, they cannot communicate. We can use DHCP Relay (or called IP Helper) to transmit the Broadcast from DHCP Client to the DHCP Server。In the following diagram, R1 is the DHCP Server and R3 is the DHCP Client. We need to configure DHCP Relay on R2.

dhcp

Step 1: Configure IP Address

hostname R1
!
interface Ethernet0/0
 ip address 192.168.12.1 255.255.255.0
hostname R2
!
interface Ethernet0/0
 ip address 192.168.12.2 255.255.255.0
!
interface Ethernet0/1
 ip address 192.168.23.2 255.255.255.0

Step 2: Configure DHCP on R1

hostname R1
!
ip dhcp excluded-address 192.168.23.1 192.168.23.10
!
ip dhcp pool POOL_2
   network 192.168.23.0 255.255.255.0
   default-router 192.168.23.2

Step 3: Routing

The concept of IP Helper is simple. When it receives DHCP broadcast from R3, it will transmit it to R1 e0/0 by using unicast. So e0/1 of R2 must be reachable to e0/0 of R1, vice versa. In this example, we use static route to make it work.

hostname R1
!
ip route 192.168.23.0 255.255.255.0 192.168.12.2
hostname R2
!
ip route 192.168.12.0 255.255.255.0 192.168.12.1

Try to have a ping test.

R2#ping 192.168.12.1 source 192.168.23.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.12.1, timeout is 2 seconds:
Packet sent with a source address of 192.168.23.2
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 16/20/28 ms

Step 4: IP Helper

Use ip helper-address <ip> command. <ip> is the ip address of the DHCP Server.

hostname R2
!
interface Ethernet0/1
 ip address 192.168.23.2 255.255.255.0
 ip helper-address 192.168.12.1

At last, R3 can obtain an IP from DHCP server.

R3(config)#int ethernet 0/0
R3(config-if)#ip address dhcp
R3(config-if)#no shutdown
R3(config-if)#end
R3#show interface ethernet 0/0 | i Internet
  Internet address is 192.168.23.11/24