April 3, 2017

How To Configure DHCP Server And DHCP Relay On Cisco Router In Packet Tracer

Updated by subhakaran Nitijanandhan
Dynamic host configuration protocol is known as DHCP which is used to automatically do the configuration process on the end devices. Sometimes you may think that why do we need that instead of configuring IP address, DNS and Default gateway manually. Obviously, that is not a good idea because of think of a moment that a company with thousands of hosts. Configuring those hosts manually is a time-consuming process that is why DHCP is all about. This protocol helps the host to get their IP address, default Gateway, and DNS. This is pretty cool right. DHCP can be configured in Server, Router and L3 switch. Here we will how to configure DHCP in Cisco router using Packet Tracer. In the first topology, DCHP Server router is a directly connected network.
configure dhcp on cisco router

 Creating subinterfaces on Gi0/0

According to the topology, 3 subinterfaces should be created on the physical interface Gig0/0. so that 3 VLANs can be able to go through this physical interface Gi0/0. VLAN tagging protocol is dot.q which is the IEEE standard. VLAN id should be typed correctly as follows. Below IP address is the default gateway for specific hosts. Basically, this process is for configuring Inter-VLAN routing.
Router>en
Router(config)#int gi0/0.10
Router(config-subif)#encapsulation dot1Q 10
Router(config-subif)#ip add 192.168.1.1 255.255.255.0

Router(config)#int gi0/0.20
Router(config-subif)#enc dot1Q 20
Router(config-subif)#ip add 192.168.2.1 255.255.255.0

Router(config)#int gi0/0.30
Router(config-subif)#encapsulation dot1Q 30
Router(config-subif)#ip add 192.168.3.1 255.255.255.0

Power On The Gi0/0 Interface

Now you should exit from the sub-interface and go to Gi0/0 and turn on the physical interface.

Router(config)#int gi0/0
Router(config-if)#no shut

Allowing The VLAN On The Specific Interface

Interface Gi0/1 on the switch must be in the trunk mode and each interface is set to be allowed each VLAN. VLAN will be created if not existed already.

Switch 0
Switch>
Switch>en
Switch(config)#int gi0/1
Switch(config-if)#switchport mode trunk

Switch(config-if)#int fa0/1
Switch(config-if)#switchport access vlan 10

Switch(config)#int fa0/2
Switch(config-if)#switchport access vlan 20

Switch(config)#int fa0/3
Switch(config-if)#switchport access VLAN 30

Creating DHCP Pools

Actually, this is the main part for this tutorial. The first step is creating one pool for one VLAN
So here we are creating 3 pools for 3 VLANS. VLAN 10, VLAN 20, VLAN 30 those are named for each pool.

Router 0
Router(config)#ip dhcp pool vlan10
Router(dhcp-config)#network 192.168.1.0 255.255.255.0
Router(dhcp-config)#default-router 192.168.1.1
Router(dhcp-config)#dns 8.8.8.8


Router(config)#ip dhcp pool vlan20
Router(dhcp-config)#network 192.168.2.0 255.255.255.0
Router(dhcp-config)#default-router 192.168.2.1
Router(dhcp-config)#dns 8.8.8.8

Router(config)#ip dhcp pool vlan30
Router(dhcp-config)#network 192.168.3.0 255.255.255.0
Router(dhcp-config)#default-router 192.168.3.1
Router(dhcp-config)#dns 8.8.8.8

Excluding  IP Addresses From The Pools

Here we excluding first 5 IP addresses from each pool so that Reserved IP addresses will not be assigned to hosts.
Router(config)#ip dhcp ex 192.168.1.1 192.168.1.5
Router(config)#ip dhcp ex 192.168.2.1 192.168.2.5
Router(config)#ip dhcp ex 192.168.3.1 192.168.3.5


dhcp request sucessful




 

Configuring DHCP Relay.

Everything is same here but DHCP server router is remotely connected which mean DHCP server router is not a directly connected network.
configure dhcp on cisco router

Configuring IP address on router 0

Router(config)#int gi0/1
Router(config-if)#ip add 172.17.0.1 255.255.252.0
Router(config-if)#no shutdown

Configuring IP address on router 1

Router 1
Router(config)#int gi0/2
Router(config-if)#ip add 172.17.0.2 255.255.252.0
Router(config-if)#no shut

Enabling Static Routing

Router 1 should know how it can reach the networks of 192.168.1.0, 192.168.2.0, 192.168.2.0
So that we are creating 3 routes that tell the router 1 it can reach these networks through the interface Gi0/1 of the router 0. we also use that interface id instead of that IP address.

Router(config)#ip route 192.168.1.0 255.255.255.0 172.17.0.1
Router(config)#ip route 192.168.2.0 255.255.255.0 172.17.0.1
Router(config)#ip route 192.168.3.0 255.255.255.0 172.17.0.1

Creating DHCP Pools on Router 1

Router(config)#ip dhcp pool vlan10
Router(dhcp-config)#network 192.168.1.0 255.255.255.0
Router(dhcp-config)#default-router 192.168.1.1
Router(dhcp-config)#dns 8.8.4.4
               
Router(config)#ip dhcp pool vlan20
Router(dhcp-config)#network 192.168.2.0 255.255.255.0
Router(dhcp-config)#default-router 192.168.2.1
Router(dhcp-config)#dns 8.8.4.4

Router(config)#ip dhcp pool vlan30
Router(dhcp-config)#network 192.168.3.0 255.255.255.0
Router(dhcp-config)#default-router 192.168.3.1
Router(dhcp-config)#dns 8.8.4.4

Excluding IP addresses

Router(config)#ip dhcp ex 192.168.1.1 192.168.1.5
Router(config)#ip dhcp ex 192.168.2.1 192.168.2.5
Router(config)#ip dhcp ex 192.168.3.1 192.168.3.5

Configuring IP Helper Address

This is little bit different IP address of DHCP server router will be placed on each subinterface of the Router 0 as IP helper agent's address.

Router(config)#int gi0/0.10
Router(config-subif)#ip  helper-address 172.17.0.2

Router(config)#int gi0/0.20
Router(config-subif)#ip  helper-address 172.17.0.2

Router(config)#int gi0/0.30
Router(config-subif)#ip  helper-address 172.17.0.2

configure dhcp server on cisco router