top of page
Writer's pictureMc Cube

Dive in to DHCP Configuration

Updated: Mar 25, 2022



Introduction


Dynamic Host Configuration Protocol is an excellent tool to reduce administrative overhead. Large networks will likely deploy a server to handle this job, but smaller networks with low demand, can get away with utilizing the available "extra" processing powers of their Routers or switches.


If you are studying for your CCNA then this lab (Download lab pack here) is ideal to help you understand several components of this configuration on a Cisco IOS device. There are two main tasks that you will want to achieve. Configure the Cisco Device as a DHCP server (with all the bells and whistles) or configure the device as a DHCP client. Either way both are covered in this lab.



Instructions


In this lab R2 will act as the DHCP server for two networks.

1. The Local Area Network connected to R1 G0/1

2. The Point to Point (P2P) network for R1 G0/0 interface


In the initial network, only hostnames have been configured.


Topology



IP Table

Device

Interface

Address

R2

G0/0

10.1.2.1/24

R1

G0/0

DHCP (from P2P pool)

R1

G0/1

192.168.0.1/24

S1

VLAN 1

DHCP (from MyLAN pool)

PC-A

Eth0

DHCP (from MyLAN pool)

PC-B

Eth0

DHCP (from MyLAN pool)


Activity


Part 1 - Configure R2

1. Configure the IP address on R2 G0/0 as indicated in the IP Table

R2#conf t
R2(config)#int g0/0
R2(config-if)#ip add 10.1.2.1 255.255.255.0
R2(config-if)#no shut
R2(config-if)#exit
R2(config)#

2. Enable the DHCP Service

R2(config)#
R2(config)#service dhcp
R2(config)#

3. Configure the excluded addressed for the P2P network pool. (10.1.2.0/24)

a. Exclude all addresses from

i. 10.1.2.1 up to 10.1.2.252

ii. The single address 10.1.2.254

R2(config)#
R2(config)#ip dhcp excluded-address 10.1.2.1 10.1.2.252
R2(config)#ip dhcp excluded-address 10.1.2.254
R2(config)#

* Note - This range of excluded addresses is designed to demonstrate how the excluded-address command can work. The goal of this range is to exclude every address except 10.1.2.253 which R1 will be given.


4. Configure the first DHCP pool

a. Called “P2P

b. Only the network command is required (10.1.2.0/24)

R2(config)#
R2(config)#ip dhcp pool P2P
R2(dhcp-config)#network 10.1.2.0 255.255.255.0
R2(dhcp-config)#exit
R2(config)#

5. Configure the excluded addresses for the MyLAN network pool.

a. Again we want to customise what addresses can be used. Using only 3 lines can you configure so that addresses

i. 192.168.0.1 up to 192.168.0.100

ii. 192.168.0.110 up to 192.168.0.252

iii. 192.168.0.254

are all excluded.

R2(config)#
R2(config)#ip dhcp excluded-address 192.168.0.1 192.168.0.100
R2(config)#ip dhcp excluded-address 192.168.0.110 192.168.0.252
R2(config)#ip dhcp excluded-address 192.168.0.254
R2(config)#

6. Configure the second DHCP Pool

a. Called “MyLAN

b. The network 192.168.0.0/24

c. The default gateway of 192.168.0.1

d. The DNS server 10.2.3.254

e. The domain name mymindsmadness.co.uk

R2(config)#
R2(config)#ip dhcp pool MyLAN
R2(dhcp-config)#network 192.168.0.0 255.255.255.0
R2(dhcp-config)#default-router 192.168.0.1
R2(dhcp-config)#dns-server 10.2.3.254
R2(dhcp-config)#domain-name mymindsmadness.co.uk
R2(dhcp-config)#exit
R2(config)#

7. Finally, R2 will have no idea how to get to the 192.168.0.0 network once we create it.

a. You can confirm this with the command

i. Show ip route

R2#sh ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
       i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
       * - candidate default, U - per-user static route, o - ODR
       P - periodic downloaded static route

Gateway of last resort is not set

ii. show ip route 192.168.0.0

R2#show ip route 192.168.0.0
% Network not in table

b. We will need to ensure that R2 knows how to get the 192.168.0.0/24 network that is connected to R1’s G0/1 interface. To keep this simple let’s use a Static Route informing R2 that to get to the 192.168.0.0/24 network it can simply leave it’s G0/0 interface

R2(config)#
R2(config)#ip route 192.168.0.0 255.255.255.0 g0/0
R2(config)#

Part 2 – Configure R1 G0/0 as DHCP Client

1. Set up the interface to obtain an address via DHCP and ensure it is activated.

R1#
R1#conf t
R1(config)#int g0/0
R1(config-if)#ip address dhcp
R1(config-if)#no shut
R1(config-if)#end
R1#

2. You can use the “Show in interface Brief command to verify that the interface has been given an IP address.

a. This can take time. You should receive output on the CLI indicating that an address has been assigned.

R1#
R1#show ip int brief
Interface              IP-Address  OK? Method Status                Protocol
GigabitEthernet0/0     unassigned  YES DHCP   up                    up
GigabitEthernet0/1     unassigned  YES unset  administratively down down
R1#
*Jan  5 15:37:05.824: %DHCP-6-ADDRESS_ASSIGN: Interface GigabitEthernet0/0 assigned DHCP address 10.1.2.253, mask 255.255.255.0, hostname R1
R1#
R1#show ip int brief
Interface              IP-Address  OK? Method Status                Protocol
GigabitEthernet0/0     10.1.2.253  YES DHCP   up                    up
GigabitEthernet0/1     unassigned  YES unset  administratively down down
R1#

Part 3 – Configure R1 LAN interface as a DHCP Relay

1. This G0/1 interface will need to have an IP address statically assigned. Use the address in the IP Table and ensure the interface is activated

R1#
R1#conf t
R1(config)#int g0/1
R1(config-if)#ip address 192.168.0.1 255.255.255.0
R1(config-if)#no shut
R1(config-if)#

2. Configure the IP Helper command to point to the IP address on R2 10.1.2.1

R1(config-if)#
R1(config-if)#ip helper-address 10.1.2.1
R1(config-if)#end
R1#

Part 4 – Configure LAN hosts as DHCP Client

1. The Desktop PCs

  • in CML are currently set as DHCP clients. This can be verified with the command ifconfig

  • in Packet Tracer PCs may need to be enabled for DHCP this can be done in the "IP Configuration" window from desktop. The address can also be confirmed there but this isn't representative of a real Window OS. Being the case, it is good practice to go to the Command line Application and use the "ipconfig" command

2. This is not exactly commonplace but why the F not, lets set the switches SVI address for interface VLAN 1 to be obtained automatically.

a. Configure interface VLAN 1 to obtain an address via DHCP

S1#
S1#conf t
S1(config)#int vlan 1
S1(config-if)#ip address dhcp
S1(config-if)#no shut
S1(config-if)#end
S1#

b. Like before this can be verified with the show ip int brief command

S1#
S1#show ip int brief
Interface              IP-Address      OK? Method Status          Protocol
---[output omitted]---
Vlan1                  unassigned      YES DHCP   up              up
S1#

3. This presents a small problem... No matter how long you wait, your switch will not pick up an address.

This is because the DHCP server is on a different (remote) network. For a switch to communicate directly with a remote network it requires a default gateway.

a. Configure the Default Gateway as 192.168.0.1

S1#conf t
S1(config)#
S1(config)#ip default-gateway 192.168.0.1
S1(config)#end
S1#

*Jan  5 15:47:36.463: %DHCP-6-ADDRESS_ASSIGN: Interface Vlan1 assigned DHCP address 192.168.0.103, mask 255.255.255.0, hostname S1

S1#
S1#show ip int brief
Interface              IP-Address      OK? Method Status          Protocol
---[output omitted]---
Vlan1                  192.168.0.103   YES DHCP   up              up
S1#


Other Verifications


When configuring DHCP you may wish to verify a few things; What you have configured, what addresses are leased to who, any conflicts of addresses. This section will cover the verification


Overall DHCP configuration

Viewing your running configuration is always an easy way to reconfirm the commands you have entered. Let's use a pipe and view the DHCP section of the config.

R2#
R2#show running-config | section dhcp
ip dhcp excluded-address 10.1.2.1 10.1.2.252
ip dhcp excluded-address 10.1.2.254
ip dhcp excluded-address 192.168.0.1 192.168.0.100
ip dhcp excluded-address 192.168.0.110 192.168.0.252
ip dhcp excluded-address 192.168.0.254
ip dhcp pool P2P
 network 10.1.2.0 255.255.255.0
ip dhcp pool MyLAN
 network 192.168.0.0 255.255.255.0
 default-router 192.168.0.1
 dns-server 10.2.3.254
 domain-name mymindsmadness.co.uk
R2#

Although viewing the running config is one of the best tools in troubleshooting cisco IOS. Cisco like to make sure you know a few other outputs too. So, a great substitute command here is the show ip dhcp pool command, which on its own will show you every pool or you can specify which pool you want to see. for example, show ip dhcp pool MyLAN

R2#
R2#show ip dhcp pool MyLAN
Pool MyLAN :
 Utilization mark (high/low)    : 100 / 0
 Subnet size (first/next)       : 0 / 0 
 Total addresses                : 254
 Leased addresses               : 3
 Excluded addresses             : 5
 Pending event                  : none

 1 subnet is currently in the pool
 Current index        IP address range                    Leased/Excluded/Total
 192.168.0.1          192.168.0.1      - 192.168.0.254     3    / 5     / 254
R2#

Bindings

To see DHCP bindings use the show ip dhcp bindings command. This will inform you of the assigned IP address and the MAC address of the device/interface it is assigned to. In bold you can see the R1 G0/0 information

R2#show ip dhcp binding 
IP address       Client-ID/              Lease expiration        Type
                 Hardware address
10.1.2.253       0003.E4BB.9701           --                     Automatic
192.168.0.103    0060.3E63.C96C           --                     Automatic
192.168.0.102    00E0.A3E3.7507           --                     Automatic
192.168.0.104    000C.CFB8.A285           --                     Automatic
R2#

Recent Posts

See All

**WTFARP?

Comments


bottom of page