Using DHCP to Dynamically Configure Router IP Addresses

Problem

You want the router to obtain its IP addressing information dynamically.

Solution

The ip address dhcp configuration command allows the router to obtain the address information for an interface dynamically:

Router1#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
Router1(config)#interface FastEthernet0/1
Router1(config-if)#ip address dhcp 
Router1(config-if)#end
Router1#
Interface FastEthernet0/1 assigned DHCP address 172.25.1.57, mask 255.255.255.0
Router1#

Tip

Prior to Release 12.2(8)T, the ip address dhcp command was only supported on Ethernet interfaces.

Discussion

Cisco started to include DHCP client functionality in IOS Version 12.1(2)T. This allows routers to obtain interface IP address information via DHCP. While we don’t recommend using dynamic addressing for routers in an internal network, this can be extremely useful for routers that connect to the Internet through an ISP. It is increasingly common for service providers to use DHCP to give address information to allocate information to client devices.

When an interface on the router is configured as a DHCP client like this, it is able to dynamically learn its IP address, and netmask, via DHCP. In addition, the router also learns its TFTP server address, NETBIOS nameserver, vendor-specific information, static routes, domain name, DNS servers, and default router information.

Beginning with IOS Version 12.3(8)T, you can control which options ...

Get Cisco IOS Cookbook, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.