DHCP (DYNAMIC HOST CONFIGURATION PROTOCOL).

 

DHCP (DYNAMIC HOST CONFIGURATION PROTOCOL)

 

 

Table of Contents:-

    

1.   Introduction.

2.   Why do we need DHCP.

3.   What is DHCP.

4.   How does DHCP work.

5.   DHCP Relay Agent.

5.1.      Why do we need Relay Agent.

5.2.      How does Relay Agent work.

6.   Messages of DHCP.

7.   Questions asked from DHCP in the Network Engineer L1 Interview.

 

 

 

 

l INTRODUCTION:-

 

Dhcp is a protocol used to provide IPs to the host devices in a dynamic manner. In Dhcp we create a pool of IPs on the Dhcp server, the host devices reach out to the dhcp server to ask for a IP address to which dhcp server responds with providing an IP address to the host from the Dhcp pool.

- Dhcp uses UDP protocol and port 67/68 (67 for server and 68 for client).

- It works on Application layer of TCP/IP protocol suite.

 

l Why do we need DHCP:-

 

To answer this question first of all let me tell you that IP address can be provided to a device or host in 2 manners- Statically and dynamically.

In the static manner a person would manually access the host and configure the IP on the host whereas in the dynamic manner the Dhcp would be used to configure the host with the IP address. The host would itself reach out to the server and take IP from there.

Lets consider a scenario now- Suppose there are 100 hosts that needs to be given an IP address. Now, in this case if we use the static method then its gonna be a hectic and time taking process to access each device manually for a person and configure it with an IP address and also this process is prone to errors. So, we needed a solution to this problem and we came up with the Dhcp.

 

l How does DHCP work:-

 

Dhcp works on a client-server model where the clients reach out to the server for seeking IP address and the server provides the IP address to the client. DORA or Lease process is used by Dhcp to provide IP to the host. DORA process is a 4 step process-

 

1. Discover:-

 

When the client initiates the process of taking IP, it broadcasts the 1st message of DORA process that is discover message. The host sends this message to discover if there is any dhcp server present in the network.

 

There are some key points here to note, such as- source port, destination port, etc.

 

                    


 

2. Offer:-

 

Once the server receives the discover message the server replies with the offer message which is also a broadcast message.

 


                                       

 

 

3. DHCP Request:-

 

After getting the offer for the IP the client responds with the request message which is again a broadcast message. In this message the client would request for some specific parameters that the client wants to use. It contains a list of option codes for the desired parameters. The request parameters could be- Default Gateway IP, Router’s IP, DNS server IP, Domain name, IP of the Time server, etc.

 


 

4. Acknowledge:-

 

If Dhcp server is comfortable with the parameters asked by the client, it responds with the acknowledge message providing the asked parameters and this is also a broadcast message.

                                 


 

 

** After getting IP the client will perform ARP probe test using GARP to verify if the IP provided is valid and not being used by any other client in the network so as to avoid IP conflicts.

 

l DHCP RELAY AGENT:-

 

Relay agent is a device configured to listen for DHCP broadcast messages generated by the clients and then relay or forward those to Dhcp servers on different subnets or network.

 

- Why do we need Relay Agent:-

 

Lets consider a scenario- Suppose your Dhcp server is in the different network as that of the client. Now, in this case when the client sends the broadcast messages for server those messages won’t reach the server because when you need to communicate between different networks ( internetwork communication ) you would need a layer 3 device ( considering it to be router ) and router doesn’t forwards the broadcast traffic.

Now, this is a problem because you can’t have a DHCP server in all the networks. This is where the relay agent comes into play and resolves problem.

 

- How does relay agent work:-

 

The relay agent acts as a mediator in the communication of client and server for DORA process. The relay agent is the device being configured as a device that knows the exact IP of DHCP server.

- So, now when the client broadcasts the discover message, the relay agent receives it on behalf of the server and knowing the exact IP of the server it unicasts it to the server.

- Receiving the Discover message from the relay agent the server also unicasts the offer message to the relay agent which is received by the relay agent and broadcasted to the client afterwards.

- All the conversation of the DORA process goes on like this only when the server is in the different network as that of client.


 


 


 

l Messages of DHCP:-

 

 

TAG

LENGTH

OPTION VALUE

DHCP MESSAGE TYPE

 

 

53

 

 

 

1

1

DHCP Discover

2

DHCP Offer

3

DHCP Request

4

DHCP Decline

5

DHCP Ack.

6

DHCP NAK

7

DHCP Release

8

DHCP Inform

 

 

- DHCP Decline:-

 It is sent from client to server for declining the IP provided by the server after probe test and start DORA process again.

 

- DHCP NAK (Negative Acknowledgement):-

IF any server not being able to give the parameters for which requested by the client, it responds with NAK.

Example- If same client requested for IP two times, If the client has shifted to another subnet and requests IP from that subnet.

 

- DHCP Release:-

Sent when client wants to release its IP. Can also do it manually with a command and start the DORA process again.

# ip config/release.

 

- DHCP Inform:-

Client uses it to get more parameters from the server. Also if we assign IP manually to the client then also the client can use this message to inform other hosts about its IP.

 

** Lease- Time for how long information received from server is valid, once expired the tenant must have to reassign the lease.

 

 

l Interview questions for Network Engineer L1 from DHCP:-

 

## DISCLAIMER:- The questions asked in the interview are all scenario based and indirect, So you should try to understand the concept instead of cramming. You will be fortunate if you receive a direct question from the interviewer.

 

 

1. What is DHCP?

2. Define the DORA process and its steps?

3. What is relay agent?

4. Define the working of relay agent?

5. Lets suppose your Dhcp server is in another network as that of client how does the client gets IP in that case, describe the process?

- Ans- Mostly given this scenario to ask about the DHCP relay agent.

 

6. What are the source and destination ports when client reaches to the server and when the server replies to the client? Also source and destination ports could be asked with respect to messages?

7. What is the information sent in the offer message by the server?

8. What are the parameters requested by the client from the server?

9. The complete process in the scenario of relay agent, whether it be source and destination ports or unicasting and broadcasting, everything is important?

10. How many messages are there in Dhcp?

 

** Although first 4 questions are enough for the interview but to be more specific I have provided more questions. 

Comments

Popular posts from this blog

OSI and TCP/IP Model

DNS (DOMAIN NAME SYSTEM)

ARP (Address Resolution Protocol)