Network Kings

DHCP & DHCP LAB

What is DHCP server?

DHCP stands for dynamic host configuration protocol. DHCP server automatically assigns IP address to the hosts. You can configure DHCP server in a router and in a server.

Why we use DHCP server?

In smaller networks, we can configure IP address manually for individual host. But in larger network, we don’t configure IP address manually; it is a very consuming job. So, in larger network to assign automatically IP address to hosts we configure DHCP server.

IP addresses provided by DHCP server are not fixed; they are dynamic address and changing with time.

So, only for client devices (like PCs, phone) we use DHCP server, for other devices like router, switch and server we configure IP address manually.

DHCP server use UDP 67 port.

DHCP client use UDP 68 port.

What is DORA  process?

Word DORA is acronym from Discover Offer Request Acknowledge. DORA process includes 4 messages that are exchanged between DHCP server and client. It defines the step-by-step procedure how a host learns an IP address from a DHCP server.

Discover
Offer
Request
Acknowledge

Discover Message: In dora process, first message is discover message that DHCP client is used to discover a DHCP server on the network. If there are more 1 DHCP server on the network then client adds a DHCP server identifier field in the request message.  

It is client-server message. As, client don’t know server IP address, it broadcasts the message to 255.255.255.255. At this time, client also doesn’t have IP address, so source IP address is 0.0.0.0.

Source IP – 0.0.0.0, Source port no -68

Destination IP – 255.255.255.255, Destination port no – 67

Offer Message:In the response of discover message, DHCP server send an offer message to client. It is a unicast message, as now server knows about client MAC address. In this message server offer a pool of available IP to the client.

Source IP – IP address of DHCP server, Source port – 67  (DHCP Server)

Destination IP- 255.255.255.255  , Destination IP – 68 (DHCP client)

Request Message: After receiving offer message, client send a request message to DHCP server. This message tells the server that I (client) am Ok with IP address that you sent me in offer message. Please assign this address to me.

Source IP – 0.0.0.0, Source port – 67  (DHCP Server)

Destination IP- 255.255.255.255, Destination IP – 68 (DHCP client)

Acknowledge Message: This is the last message in the dora process, that is sent by server in the response of request message. In this message server sends the IP address and other network parameters detail. This is a unicast message.

Source IP – IP address of DHCP server, Source port – 67  (DHCP Server)

Destination IP- 255.255.255.255,  Destination IP – 68 (DHCP client)

What is APIPA address?

APIPA stands for automatically private IP addressing. APIPA is a class B IP address range from 169.254. 0.0 to 169.254. 255.255 (reserved for Microsoft) that is self generated by the host when a DHCP server is either permanently or temporarily unavailable.

When a DHCP client boots up, it first looks for a DHCP server in order to obtain an IP address and subnet mask. If the client is unable to find the information, it uses APIPA to automatically configure itself.

What is APIPA address?

 

APIPA address assignment.

In above image, a clear message is showing DHCP failed and APIPA is being used. After some time when DHCP issue is resolved, PC gets an IP address from DHCP.

Many people have a question, can we ping with APIPA address. What you think yes or no? Let me show you result with proof- we can ping with APIPA address but only inside a network, can’t ping outside the LAN network.

Here is the proof:

What is APIPA address?

 

Ping reply with APIPA address within same LAN.
What is APIPA address?

 

Can’t ping with APIPA address outside the LAN.

What is DHCP Relay Agent?

DHCP relay agent is any TCP/IP host which is used to forward request and replies between DHCP server and DHCP client when the server is on the different network.

Syntax of Command: interface

                                           ip helper-address

For example, we have to configure DHCP relay agent on interface fa0/0 and server IP is 192.168.30.1.

Then above commands should be written like this-

                                                             int fa0/0

                                                           ip helper-address 192.168.30.1


                   #### DHCP LAB ####

Now we will perform a lab, in this lab we will configure R1 as a DHCP server that will provide IP address to the PCs of LAN1 as well as LAN2 and also configure R2 as DHCP relay agent.

DHCP Relay Agent

To do this lab you need to perform 4 steps-

  1. Design the topology.
  2. Do configuration, assign IP to router interfaces, configure static route, configure R1 as DHCP server and R2 as DHCP relay agent.
  3. Verify the connectivity using ping command.

Step 1:Design the topology.

To perform this lab, I used packet tracer. To design this topology, I used 2 routers (2811) and 2 switches (2960), 3 laptops and 1 server. To do connection fast, use automatically connection choose wire (yellow color with zigzag).


Step 2: Do configuration

To configure commands, you need to access the CLI of router. Click on the router, a window will pop up, then click on the CLI. Congrats, now you are in CLI. When you first time enter in CLI. There is a message continue with configuration dialog? (yes/no) type no.

#### R1 Configuration #####

enable
configure terminal
hostname R1
int fa0/0
ip address 192.168.20.1 255.255.255.0
no shutdown
int fa0/1
ip address 192.168.30.1 255.255.255.0
no shutdown
ip route 192.168.10.0 255.255.255.0 192.168.30.2
ip dhcp excluded-address 192.168.20.1 192.168.20.10
ip dhcp pool A
network 192.168.20.0 255.255.255.0
default-router 192.168.20.1
ip dhcp excluded-address 192.168.10.1 192.168.10.10
ip dhcp pool B
network 192.168.10.0 255.255.255.0
default-router 192.168.10.1

#### R2 configuration ####

enable
configure terminal
hostname R2
int fa0/0
ip address 192.168.10.1 255.255.255.0
no shutdown
int fa0/1
ip address 192.168.30.2 255.255.255.0
no shutdown
ip route 192.168.20.0 255.255.255.0 192.168.30.1
int fa0/0
ip helper-address 192.168.30.1


Step 3: Check connectivity using ping command.

I got ping reply, below I put a screen capture of result. So my lab is successful, now it’s your turn.

DHCP Relay Agent

Commands used in this lab:

To configure IP address to fa0/0 interface of R1 we use below commands

int fa0/0
ip address 192.168.20.1 255.255.255.0
no shutdown

Similar way configure IP address to Fa0/1 interface of R1

int fa0/1
ip address 192.168.30.1 255.255.255.0
no shutdown

To configure static route we use

ip route 192.168.10.0 255.255.255.0 192.168.30.1

Syntax: ip route

We use above command in R1 router to set the route between LAN1 to LAN2. So, here R1 is in LAN1, so in network id field we will mention network id of LAN2 i.e. 192.168.10.0 and in subnet mask field subnet mask of 192.168.10.0 network and in the next-hop address field IP address of next hop of R1 in the way of 192.168.10.0 network.

To configure DHCP pool

ip dhcp pool A
network 192.168.20.0 255.255.255.0
default-router 192.168.10.1

Syntax: ip dhcp pool

Syntax: network

Syntax: default-router

In this lab we configure 2 DHCP pools, pool A for LAN1 and pool B for LAN2.