Table of Contents
Can also be a DHCP client
As a DHCP server, a Cisco router not only automatically assigns IP addresses to PCs and other devices, but can also be configured as a DHCP client. For example, if you have an Internet connection service and your ISP assigns you an IP address via DHCP, configure your Cisco router as a DHCP client.
Related articles
The details for configuring a Cisco router as a “DHCP server” are described in the following article.
DHCP Client Configuration
To automatically assign an IP address/subnet mask for an interface with a Cisco router as a DHCP client, use the following command in interface configuration mode.
IP address configuration DHCP Client
(config)#interface <interface-name>
(config-if)#ip address dhcp
<interface-name> : Interface name to be a DHCP client
The router connecting to the Internet must also be configured with a default route. In most cases, the default route is configured as a static route.
To use the IP address of the default gateway obtained by DHCP as the next hop for the default route, make the following configuration
Default route with DHCP default gateway as next hop
(config)#ip route 0.0.0.0 0.0.0.0 dhcp
Client ID
There is a client ID to identify the DHCP client; the default client ID for the ip address dhcp command is a string like this
“cisco-<MAC-address>-<interface-name>”
To make the client ID the MAC address of the interface, add the client-id option to the ip address dhcp command.
IP address configuartion DHCP Client Change Client ID
(config)#interface <interface-name>
(config-if)#ip address dhcp client-id <interface-name>
<interface-name> : Interface name to be a DHCP client
With the client-id option, the client ID is the MAC address of the interface. It is a hexadecimal number, not a string.
<MAC-address>
release/renew
To release the IP address/subnet mask assigned by DHCP, enter the following command in privileged EXEC mode
DHCP Release
#release dhcp <interface-name>
<interface-name> : Interface name configured as DHCP client
Also, if you want to reacquire the address via DHCP, use the following command in privileged EXEC mode.
DHCP Renew
#renew dhcp <interface-name>
<interface-name> : Interface name configured as DHCP client
DHCP Client Verification
As a DHCP client, use the following command to verify IP address and other assignments.
Commands | Overview |
---|---|
#show ip interface | Verify detailed information at the Layer 3 level for the interface. |
#show dchp lease | Verify the information assigned by DHCP. |
DHCP Client Configuration Example
Configure R1 in the following figure as a DHCP client.
- Obtain the IP address/subnet mask of R1 Fa0/0 via DHCP.
- Configure the default route as a static route on R1.
R1 DHCP Client Configuartion
Use the ip address dhcp command to make Fa0/0 on R1 a DHCP client. Also, specify dhcp as the next hop for the default route “0.0.0.0 0.0 0.0.0” in the static route configuration.
R1 DHCP Client Configuration
interface FastEthernet0/0 ip address dhcp ! ip route 0.0.0.0 0.0.0.0 dhcp
R1 DHCP Client Verification
The show ip interface fa0/0 shows that the IP address and subnet mask are assigned by DHCP.
R1 DHCP Client Verification show ip interface
R1#show ip interface FastEthernet 0/0 FastEthernet0/0 is up, line protocol is up Internet address is 10.0.0.2/24 Broadcast address is 255.255.255.255 Address determined by DHCP MTU is 1500 bytes Helper address is not set -- omitted --
The show dhcp lease command shows the TCP/IP configuration information assigned by the DHCP server.
R1 DHCP Client Verification show dhcp lease
R1#show dhcp lease Temp IP addr: 10.0.0.2 for peer on Interface: FastEthernet0/0 Temp sub net mask: 255.255.255.0 DHCP Lease server: 10.0.0.100, state: 3 Bound DHCP transaction id: 16EB Lease: 86400 secs, Renewal: 43200 secs, Rebind: 75600 secs Temp default-gateway addr: 10.0.0.100 Next timer fires after: 11:53:45 Retry count: 0 Client-ID: cisco-cc01.20f4.0000-Fa0/0 Client-ID hex dump: 636973636F2D636330312E323066342E 303030302D4661302F30 Hostname: R1
In addition, a default route is registered in the routing table of R1 with the default gateway obtained by DHCP as the next hop.
R1 DHCP Client Verification show ip route
R1#show ip route -- omitted -- Gateway of last resort is 10.0.0.100 to network 0.0.0.0 10.0.0.0/24 is subnetted, 1 subnets C 10.0.0.0 is directly connected, FastEthernet0/0 C 192.168.1.0/24 is directly connected, FastEthernet1/0 S* 0.0.0.0/0 [1/0] via 10.0.0.100