DHCP Service
DHCP (Dynamic Host Configuration Protocol)
DHCP (Dynamic Host Configuration Protocol) is a network management protocol used to automate the process of configuring devices on IP networks. DHCP allows devices (clients) to request and obtain IP addresses and other network configuration parameters (such as subnet mask, default gateway, and DNS servers) from a DHCP server, which significantly simplifies the administration of network settings.
In this short lab I will demonstrate how to deploy DHCP service on a router to automate IP addressing assignment.
Picture 1 displays a simple LAN topology of a router connected to an L3 multilayer switch and two clients on separate subnets, 10.1.10.0/24 and 10.1.20.0/24.
Router configuration (DHCP service)
Below we can see assigned interfaces from the router R1. The first interface, g0/0/0, is connected to the 10.1.1.254/24 subnet, while loopback is assigned with IP address 1.1.1.1.
R1>en
R1#sh ip inter brief
Interface IP-Address OK? Method Status Protocol
GigabitEthernet0/0/0 10.1.1.254 YES manual up up
GigabitEthernet0/0/1 unassigned YES unset administratively down down
Loopback0 1.1.1.1 YES manual up up
Vlan1 unassigned YES unset administratively down down
Setting up a DHCP service on a router takes a few steps. We will go through each step one by one.
We must first remove from the IP range pool the addresses we do not wish to be issued. We would like to exclude the 10.1.10.1 to 10.1.10.10 area in our scenario. Thus, a total of 10 addresses will be removed from the 10.1.10.0/24 subnet. It indicates that during dynamic assignment, this particular range of ten addresses will not be taken into account.
We write a single code line to exclude IP addressees ranges from the subnet. It has been done for VLAN 10.
R1(config)#ip dhcp excluded-address 10.1.10.1 10.1.10.10
R1(config)#exit
The same thing we are processing for VLAN 20.
R1#conf t
R1(config)#ip dhcp excluded-address 10.1.20.1 10.1.20.10
At this stage we are ready to create a pool of addresses for VLAN 10 and VLAN 20. To complete it, we need to specify the network, default router, and DNS server.
R1(config)#ip dhcp pool vlan10
R1(dhcp-config)#network 10.1.10.0 255.255.255.0
R1(dhcp-config)#default-router 10.1.10.1
R1(dhcp-config)#dns-server 10.1.1.254
R1(dhcp-config)#end
The pool range, default router, and DNS server were also created for VLAN 20, as well.
R1(config)#ip dhcp pool vlan20
R1(dhcp-config)#network 10.1.20.0 255.255.255.0
R1(dhcp-config)#default-router 10.1.20.1
R1(dhcp-config)#dns-server 10.1.1.254
R1(dhcp-config)#end
So, the DHCP service has been created for both VLANs, 10 and 20, on R1 router. Now, the IP addresses can be allocated as needed for devices connected to VLANs 10 and 20.
Enable CDP Protocol
CDP (Cisco Discovery Protocol) is a proprietary Layer 2 network discovery protocol developed by Cisco. It allows Cisco devices (such as switches, routers, and access points) to discover each other on the network and gather information about their neighbouring devices. This protocol operates at the Data Link Layer (Layer 2) of the OSI model and is used for exchanging information about network topology and device attributes such as device name, IP address, and hardware capabilities.
Enabling CDP on a Cisco switch allows administrators to identify and troubleshoot network issues.
When CDP is enabled on a Cisco switch, it will periodically send out CDP packets to its directly connected neighbours and receive CDP packets from them as well.
We can enable the CDP neighbours on the switch and router as shown in the scripts below:
S1(config)#cdp run
S1(config)#end
Now, we can discover that the switch is directly connected with the router using simple command: cdp neighbors.
S1#show cdp neighbors
Capability Codes: R - Router, T - Trans Bridge, B - Source Route Bridge
S - Switch, H - Host, I - IGMP, r - Repeater, P - Phone
Device ID Local Intrfce Holdtme Capability Platform Port ID
R1 Gig 1/0/1 135 R ISR4300 Gig 0/0/0
The steps we follow on the router R1. We need to initiate the CDP protocol using the command: cdp run, and next we are ready to check the neighbouring relationship.
R1#show cdp run
R1#show cdp neighbors
Capability Codes: R - Router, T - Trans Bridge, B - Source Route Bridge
S - Switch, H - Host, I - IGMP, r - Repeater, P - Phone
Device ID Local Intrfce Holdtme Capability Platform Port ID
S1 Gig 0/0/0 133 3650 Gig 1/0/1
On both devices (switch S1 and router R1), after typing cdp neighbors command, the CLI listed connected devices with some details of connected devices.
Implement Helper
In Cisco networking, the helper address on a Layer 3 switch is primarily used to enable DHCP relay for a VLAN or subnet. This feature is especially important when DHCP servers are located on a different network segment than the clients.
Here's how it works and why it's useful:
Facilitates DHCP Relay: When devices in a VLAN send DHCP requests, these requests are broadcast-based, and broadcasts don't cross Layer 3 boundaries by default. By configuring a helper address on the multilayer switch, you can relay these broadcasts to a specific DHCP server on another subnet. The switch forwards the request as a unicast message to the DHCP server, ensuring the client receives an IP address.
Supports Centralized DHCP Servers: In larger networks, having DHCP servers centrally located is often preferable. With the helper address, the Layer 3 switch can route requests to a DHCP server outside the client’s VLAN, simplifying IP address management.
Allows Multiple Protocols: Though commonly used for DHCP, the helper address can relay other types of broadcasts, like TFTP or DNS, by specifying protocols to forward in the configuration.
In short, the intention of using a helper address is to allow devices on a VLAN to receive DHCP addresses or other services from a server outside of their local subnet, enabling efficient network configuration and scalability.
In our example we use helper address to find the DHCP server on a different subnet.
Below we are adding the helper address for each VLAN (VLAN 10, VLAN 20). We are specifying the IP address of the helper.
S1(config)#interface vlan 10
S1(config-if)#ip helper-address 10.1.1.254
S1(config)#interface vlan 20
S1(config-if)#ip helper-address 10.1.1.254
S1(config-if)#end
Static Routing on Multilayer Switch
On the router we are ready to create a static route to be able to send packets to and from the switch.
The static route settings are a relatively simple task. We need to specify the network we want to go with the subnet masks and the next hop address. In our case, it will be the IP address of the router of each VLAN and router IP address.
R1(config)#ip route ?
A.B.C.D Destination prefix
R1(config)#ip route 10.1.10.0 255.255.255.0 10.1.1.1
R1(config)#ip route 10.1.20.0 255.255.255.0 10.1.1.1
R1(config)#
On the multilayer switch, we were able to set up virtual interfaces with the following interfaces:
Interface G1\0\2, VLAN 10, IP address 10.1.10.1/24
Interface G1\0\3, VLAN20, IP address 10.1.20.1/24
Check Connectivity
A router R1 should be able to ping with the switch virtual interfaces of VLAN 10 and VLAN 20 to confirm successful setup. Supposedly you will lose the first packet due to the ARP process, but the second ping will be fully successful with a100% rate of completion.
R1#ping 10.1.10.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.1.10.1, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 0/0/0 ms
R1#ping 10.1.20.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.1.20.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 0/0/0 ms
Routing path from the switch to loopback on the router
We need to add an extra route to the loopback on the router with the purpose of forwarding packets to the router using a static routing protocol.
First we need to enable routing on the multilayer switch. The command for enabling routing on the switch is "ip routing."
Next, we should add a static path to the loopback of the router IP with the destination of the router's default gateway (router’s interface). It sounds complicated, but it is not. In other words, we need to go to the destination on loopback through the router interface. This will help ensure proper routing of traffic between the loopback and the default gateway.
S1#conf t
S1(config)#ip route 1.1.1.1 255.255.255.255 10.1.1.254
S1(config)#end
We are set to verify the connection by pinging the loopback on 1.1.1.1.
S1#ping 1.1.1.1Type escape sequence to abort.Sending 5, 100-byte ICMP Echos to 1.1.1.1, timeout is 2 seconds:!!!!!Success rate is 100 percent (5/5), round-trip min/avg/max = 0/0/0 ms
We can utilise the popup window configuration of PC to identify if DHCP service for client (DORA) is settled down.
Picture 2 - PT software with PC-1 configuration and obtained dynamic IP address.
Picture 3 - ipconfig command from command line of PC-1
Picture 4 - connection from PC-1 to the virtual interface on the switch.
We are now prepared to verify whether the DHCP service is operational and operational by utilising router 1's DHCP settings commands.
R1#show ip dhcp binding
IP address Client-ID/ Lease expiration Type
Hardware address
R1#show ip dhcp binding
IP address Client-ID/ Lease expiration Type
Hardware address
10.1.10.101 0060.2F7A.9C7A -- Automatic
10.1.10.102 000A.4106.5786 -- Automatic
10.1.20.101 000C.8576.3D43 -- Automatic
Summary:
DHCP automatically assigns the addresses on the network, eliminating the manual work. This saves the administrator time and automates the process. By automating this process, it minimises the conflict, failure, and errors. DHCP also allows for efficient management of IP address allocations.This article presents the process of how to create and configure DHCP service for the subnetted VLANs. We did the configuration of the router and multilayer switch with a static route.Further, we tested the DHCP service by connecting a device to the network and successfully obtaining an IP address.