Start typing to search...

Configuring DHCPv4 in Packet Tracer

Learn how to configure DHCP in Packet Tracer. This guide walks through setting up the DHCP server how to configure clients to use it.

This article will demonstrate how to configure a Cisco DHCPv4 server and clients in Packet Tracer. You can skip the introduction and go straight to the demonstration here.

What is DHCP?

DHCP (Dynamic Host Configuration Protocol) assigns or “leases” IPv4 addresses from a pool of addresses for a limited time period to clients. When a lease expires and the client still exists within the network, the client is typically reassigned the same address. This ensures that addresses are made available when they are no longer needed by their previous owner.

When a client joins a network, it undergoes four steps to aquire a lease.

  1. Client: DHCP Discover DHCPDISCOVER The client sends a broadcast to discover available DHCP servers.
  2. Server: DHCP Offer DHCPOFFER The server responds and offers an available address from the pool.
  3. Client: DHCP Request DHCPREQUEST The client accepts the lease.
  4. Server: DHCP Acknowledgement DHCPACK The server acknowledges the acceptance of the lease.

Before a lease expires the client will send a new DHCPREQUEST directly to the DHCP server it got it’s original lease from. The DHCP server will then return a DHCPACK in response.

Configuring DHCP

The next section will cover the commands necessary to configure the DHCP server and clients.

DHCP server setup commands

Excluding IPv4 Addresses router(config)# ip dhcp exluded-address <low-address> <high-address>
Defining a DHCP Pool Name router(config)# ip dhcp pool <pool-name>
Define the address pool router(dhcp-config)# network <network-address> <subnet-mask>
Define the router or gateway address router(dhcp-config)# default-router address <ip address>
Define a DNS server router(dhcp-config)# dns-server address
Define the domain name router(dhcp-config)# domain-name <domain>
Define the duration of the lease router(dhcp-config)# lease <days hours minutes OR infinite>
Display the configuration router# show running-config | section dhcp
Display all leases router# show ip dhcp binding
Display information on DHCP messages router# show ip dhcp server statistics

Demonstration in Packet Tracer

Now we will demonstrate how this works in Packet Tracer. If you want to follow along you can download the .pkt file using this link: dhcpv4.pkt

alt text

1. Configure the DHCP server

The first thing we will do is exclude the first ten addresses from both R1’s and R2’s LANs in order to reserve them to ensure scalability.

R1> enable
R1# config t
R1(config)# ip dhcp excluded-address 192.168.10.1 192.168.10.10
R3(config)# ip dhcp excluded-address 192.168.30.1 192.168.30.10

Next we create DHCP pools on R2 for both LANs. We’ll call them R1-LAN and R3-LAN respectively.

R2(config)# ip dhcp pool R1-LAN
R2(dhcp-config)# network 192.168.10.0 255.255.255.0
R2(dhcp-config)# default-router 192.168.10.1
R2(dhcp-config)# dns-server 192.168.20.254
R2(dhcp-config)# ip dhcp pool R3-LAN
R2(dhcp-config)# network 192.168.30.0 255.255.255.0
R2(dhcp-config)# default-router 192.168.30.1
R2(dhcp-config)# dns-server 192.168.20.254

2. Configure the DHCP relay

As the DHCP server is not on the same LAN as the clients we need to configure forwarding for DHCP requests. The first thing we have to do is configure the helper address for the LAN interface on R1 and R2.

R1> enable
R1# config t
R1(config)# int g0/0
R1(config-if)# ip helper-address 10.1.1.2

Then repeat for R3.

R3> enable
R3# config t
R3(config)# int g0/0
R3(config-if)# ip helper-address 10.2.2.2

Now that requests can reach the DHCP server the clients can negotiate their IP address leases.

Tip
The clients IP configuration is set to static. Switch it to automatic so that they request a new lease.

3. Router DHCP client

In order to establish internet connectivity in this network, we need to configure R2 to recieve an IP address from the ISP. We can do so by enabling the dhcp client on the router.

R2(config)# int g0/1
R2(config-if)# ip address dhcp
R2(config-if)# no shutdown

We can verify that the router recieved an IP address using the following command.

R2# show ip interface brief

4. Test the connectivity

Now the PCs can ping eachother, we can test so in the Command-Line using ping.

alt text

Discussion