Configuring DHCP on routers is not something that is normally
done in a production network. Typically in a production network
DHCP servers are either Windows, Linux, or some other vendors
implementation. Occasionally you will need to configure a Cisco
device to provided DHCP for initial purposes - say a new location
build-out, a lab network, or even just perhaps for your home
networking.
For this post, I will show you how to:
- Configure your route to be a DHCP Server
- Configure your router to be a client
- Configure DHCP Reservations for a specific client
- Release / Renew your DHCP lease
- Configure DHCP options (150 for example)
Here is the network information we are going to use:
Network - 192.168.1.0/24
Gateway - 192.168.1.1
DNS - 192.168.1.2 and 192.168.1.3
Domain - FryGuyLab.Net
Cisco UCM - 192.168.1.5 and 192.168.1.6
WINS - 192.168.1.2
Node Type - Hybrid
So, first lets setup the DHCP Server router (R2)
Rack1R2#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Rack1R2(config)#ip dhcp pool DHCP_POOL_1
Rack1R2(dhcp-config)#network 192.168.1.0 /24
Rack1R2(dhcp-config)#default-router 192.168.1.1
Rack1R2(dhcp-config)#dns-server 192.168.1.2 192.168.1.3
Rack1R2(dhcp-config)#domain-name FryGuyBlog.Net
Rack1R2(dhcp-config)#option 150 ip 192.168.1.5 192.168.1.6
Rack1R2(dhcp-config)#netbios-node-type h-node
Rack1R2(dhcp-config)#netbios-name-server 192.168.1.2
Rack1R2(dhcp-config)#exit
Now, don't forget to exclude addresses if necessary.
Here will exclude 192.168.1.1 - 192.168.1.10
Rack1R2(config)#ip dhcp excluded-address 192.168.1.1 192.168.1.10
Rack1R2(config)#
Now we can go over to R1 and configure DHCP and then enable
the G0/0 interface on the router.
Rack1R1#show run int g0/0
Building configuration...
Current configuration : 103 bytes
!
interface GigabitEthernet0/0
no ip address
shutdown
duplex auto
speed auto
media-type rj45
end
Now we can configure the interface:
Rack1R1(config)#int g0/0
Rack1R1(config-if)#ip address dhcp
Rack1R1(config-if)#no shut
Rack1R1(config-if)#exit
Rack1R1(config)#exit
Rack1R1#
*Nov 15 18:37:55.302: %SYS-5-CONFIG_I: Configured from console
by console
*Nov 15 18:37:56.102: %LINK-5-CHANGED: Interface GigabitEthernet0/0,
changed state to reset
Rack1R1#
*Nov 15 18:37:58.866: %LINK-3-UPDOWN: Interface GigabitEthernet0/0,
changed state to up
*Nov 15 18:37:59.866: %LINEPROTO-5-UPDOWN: Line protocol on Interface
GigabitEthernet0/0, changed state to up
Rack1R1#
*Nov 15 18:38:05.490: %DHCP-6-ADDRESS_ASSIGN: Interface GigabitEthernet0/0
assigned DHCP address 192.168.1.13, mask 255.255.255.0, hostname Rack1R1
As you can see, we received a DHCP address of 192.168.1.13/24 from the
server. To check the DHCP Lease information on the client, issue the
show dhcp lease command
Rack1R1#show dhcp lease
Temp IP addr: 192.168.1.13 for peer on Interface: GigabitEthernet0/0
Temp sub net mask: 255.255.255.0
DHCP Lease server: 192.168.1.1, state: 3 Bound
DHCP transaction id: 859
Lease: 86400 secs, Renewal: 43200 secs, Rebind: 75600 secs
Temp default-gateway addr: 192.168.1.1
Next timer fires after: 11:58:27
Retry count: 0 Client-ID: cisco-001c.f6e6.6a90-Gi0/0
Client-ID hex dump: 636973636F2D303031632E663665362E
366139302D4769302F30
Hostname: Rack1R1
Now to check the connectivity, lets PING the other router:
Rack1R1#ping 192.168.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/1 ms
Rack1R1#
To check the active leases on the server, issue the sh ip dhcp
binding command:
Rack1R2#sh ip dhcp binding
Bindings from all pools not associated with VRF:
IP address Client-ID/ Lease expiration Type
Hardware address/
User name
192.168.1.13 0063.6973.636f.2d30. Nov 16 2010 06:25 PM Automatic
3031.632e.6636.6536.
2e36.6139.302d.4769.
302f.30
Rack1R2#
Now for reservations.
We will configure the DHCP server (R2) to assign 192.168.1.254/24
to R3's F0/0 interface.
On the DHCP Server (R2) - configure a special DHCP pool just
for that client:
Rack1R2#conf t
Rack1R2(config)#ip dhcp pool R3
Rack1R2(config)#host 192.168.1.254 255.255.255.0
Rack1R2(config)#client-identifier 0100.0bfd.5661.e0
To find out the Cleint Identifier to use, on R3 look at the Fa0/0
MAC address and then pre-pend 01 to the mac address.
(see IETF RFC1700 Hardware table below)
Rack1R3#sh int f0/0
FastEthernet0/0 is up, line protocol is up
Hardware is AmdFE, address is 000b.fd56.61e0
On R3, configure the Fa0/0 interface as follows:
Rack1R3(config)#interface FastEthernet0/0
Rack1R3(config)#ip address dhcp client-id FastEthernet0/0
Rack1R3(config)#no shut
Rack1R3(config)#exit
Rack1R3#
You will then see:
*Mar 13 23:29:28.142: %DHCP-6-ADDRESS_ASSIGN: Interface FastEthernet0/0
assigned DHCP address 192.168.1.254, mask 255.255.255.0, hostname Rack1R3
And on R2 you will see under the DHCP binding:
Bindings from all pools not associated with VRF:
IP address Client-ID/ Lease expiration Type
Hardware address/
User name
192.168.1.13 0063.6973.636f.2d30. Nov 16 2010 06:25 PM Automatic
3031.632e.6636.6536.
2e36.6139.302d.4769.
302f.30
192.168.1.254 0100.0bfd.5661.e0 Infinite Manual
Rack1R2#
IETF Hardware Table from RFC1700
http://www.ietf.org/rfc/rfc1700.txt
Number Hardware Type (hrd) References
------ ----------------------------------- ----------
1 Ethernet (10Mb) [JBP]
2 Experimental Ethernet (3Mb) [JBP]
3 Amateur Radio AX.25 [PXK]
4 Proteon ProNET Token Ring [JBP]
5 Chaos [GXP]
6 IEEE 802 Networks [JBP]
7 ARCNET [JBP]
8 Hyperchannel [JBP]
9 Lanstar [TU]
10 Autonet Short Address [MXB1]
11 LocalTalk [JKR1]
12 LocalNet (IBM PCNet or SYTEK LocalNET) [JXM]
13 Ultra link [RXD2]
14 SMDS [GXC1]
15 Frame Relay [AGM]
16 Asynchronous Transmission Mode (ATM) [JXB2]
17 HDLC [JBP]
18 Fibre Channel [Yakov Rekhter]
19 Asynchronous Transmission Mode (ATM) [Mark Laubach]
20 Serial Line [JBP]
21 Asynchronous Transmission Mode (ATM) [MXB1]
Now, if you need to force release an IP address on a client, you can issue the command:
Rack1R1# release dhcp g0/0
If you need to renew the address, you can use the command
Rack1R1# renew dhcp g0/0
For a voice network you could use dhcp on the access routers