Home > Articles

This chapter is from the book

Topic: Configure and verify DHCP on a router (excluding static reservations)

Figure 14.2 shows the simple topology we use to configure a Dynamic Host Configuration Protocol (DHCP) server using a Cisco router (R1), and to configure a Cisco router (R2) as a DHCP client.

FIGURE 14.2

FIGURE 14.2 The DHCP Server and Client Topology

Example 14.4 shows the configuration of R1, the DHCP Server.

EXAMPLE 14.4 The Configuration of the DHCP Server

R1#
R1#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#interface fa0/0
R1(config-if)#ip address 10.1.1.1 255.255.255.0
R1(config-if)#no shutdown
R1(config-if)#exit
R1(config)#
%LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0,
changed state to up
R1(config)#ip dhcp excluded-address 10.1.1.1 10.1.1.10
R1(config)#ip dhcp pool CCNAEXAMCRAM
R1(dhcp-config)#default-router 10.1.1.1
R1(dhcp-config)#dns-server 8.8.8.8 4.2.2.2
R1(dhcp-config)#option 150 ip 10.10.10.2
R1(dhcp-config)#network 10.1.1.0 /24
R1(dhcp-config)#end
R1#

The commands directly involving DHCP are as follows:

  • ip dhcp excluded-address 10.1.1.1 10.1.1.10: This command tells the DHCP server not to assign the addresses from 10.1.1.1 to 10.1.1.10 to DHCP clients. For example, the 10.1.1.1 address is the static router interface address configured on R1’s fa0/0 interface.

  • ip dhcp pool CCNAEXAMCRAM: This command creates our DHCP pool on R1. This pool will contain the specific parameters we want to hand out to clients who lease addresses from the DHCP server.

  • default-router 10.1.1.1: This command assigns the default gateway to clients of this DHCP pool.

  • dns-server 8.8.8.8 4.2.2.2: This command sets a primary and backup DNS server for the clients.

  • option 150 ip 10.10.10.2: This command provides clients with the IP address of a TFTP server.

  • network 10.1.1.0 /24: This command specifies the IP address assignments for the pool. Remember, we excluded a small portion of this network address space. As a result, we expect the first leased address to be 10.1.1.11/24.

Example 14.5 shows the configuration of a DHCP client function on a Cisco router.

EXAMPLE 14.5 The Configuration of the DHCP Client

R2#
R2#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
R2(config)#interface fa0/0
R2(config-if)#ip address dhcp
R2(config-if)#no shutdown
R2(config-if)#end
R2#
%SYS-5-CONFIG_I: Configured from console by console
R2#
%LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0,
changed state to up
R2#

Notice here the very simple configuration. The command ip address dhcp gets the job done for the client interface.

Next, let’s begin our verification on the server. Example 14.6 shows the use of the show ip dhcp binding command to verify the server’s operation.

EXAMPLE 14.6 Verifying the DHCP Server

R1#
R1#show ip dhcp binding
Bindings from all pools not associated with VRF:
IP address          Client-ID/           Lease expiration     Type
                    Hardware address/
                    User name
10.1.1.11           0063.6973.636f.2d63. 08:10 PM _______ Automatic
                    6130.332e.3066.6330.
                    2e30.3030.302d.4661.
                    302f.30
R1#

Example 14.7 shows a simple verification on the client. The show ip interface brief command allows us to quickly view the DHCP learned address on Fa0/0.

EXAMPLE 14.7 Verifying the DHCP Client

R2#
R2#show ip interface brief
Interface        IP-Address  OK? Method Status                Protocol
FastEthernet0/0  10.1.1.11   YES DHCP   up                    up
FastEthernet1/0  unassigned  YES unset  administratively down down
FastEthernet1/1  unassigned  YES unset  administratively down down
R2#

What happens if your DHCP server is not on the same subnet with the clients that need it? One option is to configure a DHCP relay-agent. This is a router that hears the DHCP requests from clients and forwards them to the appropriate DHCP server. It is very simple to configure this relay agent. Figure 14.3 and Example 14.8 show a sample topology and configuration. Note that the powerful ip helper-address dhcp-server-ip command gets the job done. The relay agent knows the address of the DHCP server, so it can successfully forward local DHCP traffic to the DHCP server.

FIGURE 14.3

FIGURE 14.3 The DHCP Relay-Agent

EXAMPLE 14.8 Configuring the DHCP Relay-Agent

R2#
R2#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
R2(config)#interface fa1/0
R2(config-if)#ip helper-address 10.1.1.3
R2(config-if)#end
R2#

CramQuiz

  1. What command ensures your DHCP server does not lease out addresses you have statically configured elsewhere?

    • src.jpg A. no dhcp-server assign-address

    • src.jpg B. no dhcp-lease address

    • src.jpg C. ip dhcp no-lease address

    • src.jpg D. ip dhcp excluded-address

  2. What command configures a default gateway in a DHCP server pool?

    • src.jpg A. ip default-gateway

    • src.jpg B. gateway-of-last-resort

    • src.jpg C. ip domain-server

    • src.jpg D. default-router

  3. What command configures a Cisco device as a DHCP client?

    • src.jpg A. ip address auto

    • src.jpg B. ip address dhcp

    • src.jpg C. ip address learn

    • src.jpg D. ip address dynamic

CramQuiz Answers

  1. D is correct. Use the ip dhcp excluded-address command to create a range of excluded addresses from your pool.

  2. D is correct. Use the default-router command in the DHCP pool to set the default gateway address.

  3. B is correct. ip address dhcp, used in interface configuration mode, sets the Cisco device as a DHCP client.

Pearson IT Certification Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from Pearson IT Certification and its family of brands. I can unsubscribe at any time.