0

Configuring Basic DHCPv4 server on a Cisco Router

The Dynamic Host Configuration Protocol (DHCP) is a network protocol that lets network administrators manage and automate the assignment of IP addresses. Without DHCP, the administrator must manually assign and configure IP addresses, preferred DNS servers, and default gateways. As the network grows in size, this becomes an administrative problem when devices are moved from one internal network to another.

In this lab, we are going to configure a basic DHCPv4 Server on a Cisco Router. We will configure the dhcp server to assign parameter such as ip addresses, default gateway, dns servers and the domain-name (optional).

Build the topology

The topology consists of the below devices in the network;

  • A Cisco IOL L3 Router image running Version 15.5(2)T
  • A Cisco IOL L2 Switch image running Version Version 15.2
  • A windows 7 client machine
  • An Ubuntu 18 client machine.

Configure the gateway interface

As a first step we are going to configure out gateway interface on our Cisco Router.

NB You can learn how to configure basic settings a Cisco router including hostname, passwords e.t.c here

Without further ado, let’s jump straight in.
Configure the gateway interface of our router with the IP 10.10.10.1 and mask 255.255.255.0 as below

Gateway#
Gateway#conf t
*May 20 11:45:01.053: %SYS-5-CONFIG_I: Configured from console by console
Gateway#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Gateway(config)#
Gateway(config)#
Gateway(config)#int e0/0
Gateway(config-if)#
Gateway(config-if)#descrip
Gateway(config-if)#description LINK-TO-LAN
Gateway(config-if)#ip add 10.10.10.1 255.255.255.0
Gateway(config-if)#
Gateway(config-if)#no shut
Gateway(config-if)#
Gateway(config-if)#exit
Gateway(config)#
Gateway(config)#
Gateway(config)#exit
Gateway#
*May 20 11:45:35.254: %LINK-3-UPDOWN: Interface Ethernet0/0, changed state to up
*May 20 11:45:36.259: %LINEPROTO-5-UPDOWN: Line protocol on Interface Ethernet0/0, changed state to up
Gateway#
*May 20 11:45:36.737: %SYS-5-CONFIG_I: Configured from console by console
Gateway#

Configure basic DHCPv4 settings

Next, we are simply going to configure this Cisco router to automatically assign IP addresses to our client machines inside our LAN network.
The configurations are as per below

Gateway#
Gateway#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Gateway(config)#
Gateway(config)#ip dh
Gateway(config)#ip dhcp ex
Gateway(config)#ip dhcp excluded-address 10.10.10.1 10.10.10.50
Gateway(config)#
Gateway(config)#ip dhcp
Gateway(config)#ip dhcp poo
Gateway(config)#ip dhcp pool LABCORP
Gateway(dhcp-config)#
Gateway(dhcp-config)#network
Gateway(dhcp-config)#network 10.10.10.0 255.255.255.0
Gateway(dhcp-config)#
Gateway(dhcp-config)#defaul
Gateway(dhcp-config)#default-router 10.10.10.1
Gateway(dhcp-config)#dns
Gateway(dhcp-config)#dns-server 8.8.8.8 208.67.222.222
Gateway(dhcp-config)#domain-name labcorp.com
Gateway(dhcp-config)#
Gateway(dhcp-config)#
Gateway(dhcp-config)#
Gateway(dhcp-config)#
Gateway(dhcp-config)#
Gateway(dhcp-config)#leas
Gateway(dhcp-config)#lease ?
  <0-365>   Days
  infinite  Infinite lease

Gateway(dhcp-config)#lease 3
Gateway(dhcp-config)#
Gateway(dhcp-config)#
Gateway(dhcp-config)#
Gateway(dhcp-config)#exit
Gateway(config)#
Gateway(config)#

In the above configurations, we first specify our excluded addresses using the command # ip dhcp-excluded address and specified the range for excluded addresses. This is for the purposes of manually assigning addresses to Servers and such.
From here, we create a dhcp pool for our LAN users and we specify the following parameters;

  • dns-server – our dns-server which can also be our router or if you have a seperate dns server in the network
  • domain-name – our domain which we have set as labcorp.com but this is not mandatory
  • lease time – by default, the lease time is 2 days, but we have modified it to 3.
  • default-router– this is the same as specifying the default gateway which is our router.

Verify the DHCPv4 on our cleint machines

We can head over to our Windows 7 and our Ubuntu machines to confirm they have received ip addresses starting from 10.10.10.50.

windows client with ip from dhcp
ubuntu client with ip from dhcp

You can verify that can ping the gateway as well as each other.

ping success
ping success

With that, we have come to end of this lab and you should be able to configure DHCPv4 server on our Cisco Router.

In another article we are going to cover configuring Stateless and Stateful DHCPv6 on a Cisco Router.

bl4ckwidow

Co-Founder of Labing Overload. I am a Web Developer/Network Engineer turned CyberSecurity Engineer. FOSS enthusiast. Cisco Technologies enthusiast. Network Penetration Tester.

Leave a Reply

Your email address will not be published. Required fields are marked *