O'Reilly logo

Cisco IOS Cookbook, 2nd Edition by Ian Brown, Kevin Dooley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required