What is DHCP Server: How to configure in Packet Tracer
Introduction
Normally, we assign an IP address to a client computer in two ways. The first one is static or manual assignment and the second one is dynamic. When we assign an IP address to a client computer manually, then it is called a static IP address. And, when we assign IP addresses in an automated way, it is called a dynamic process. For Dynamic processes or assignments, we use a DHCP server for it.
DHCP stands for dynamic host configuration protocol. DHCP is a networking protocol, whose task is to assign IP addresses in an automated way. It uses UDP port numbers 67 and 68. The port number 67 is for the server, while the port number UDP 68 is for the DHCP client.
Our client’s PC gets its IP address in two ways. i.e. manually (manually) and auto (dynamically). We will fill each field of IP in manual configuration. Although it’s easy when we have few devices, it becomes very difficult if our organization is large. So in this case we use the dynamic host configuration protocol server to assign an IP address to every computer. Dynamically, we are not assigning IP addresses to clients manually, but we are using some protocol or service, which is known as DHCP. So, this service is called DHCP Server.
Dynamic host configuration protocol server not only assigns IP addresses to the clients, but it also provides other IP address parameters such as subnet mask, default gateway, and DNS server as well. The network administrator configures the pool of IP addresses, and then the server assigns one IP address to the client upon request. The pool has a specific name.
How DHCP works
There are two types of devices in the DHCP service. One is the DHCP Server and the second one is the DHCP client. The server will provide IP addresses at the request of DHCP clients.
It uses the DORA process. DORA stands for Discover Offer Request and Acknowledgement. When the PC becomes start for the first time in the network. Then, it has no IP address. Also, the the PC doesn’t know what is the IP address of the DHCP server. So the PC will start to discover its IP address and the DHCP server assigns the IP addresses. So the first phase is Discovery.
In the discovery phase, the client PC will send a packet to the DHCP server. The client device doesn’t know either the DHCP server’s MAC address or its IP address. So, it set the destination MAC address as ffff.ffff.ffff and the destination IP as 255.255.255.255. Also, it will set 0.0.0.0 as its IP address in the source part. This Packet will add 67 as the destination port and 68 as the source port. At layer 7 it will add a DHCP header in it. At the last, it will send this packet to the DHCP server as a discovery message.
The server will reply to this message as Offer. In the Offer, it contains the IP address for that client’s PC. So, if the PC wants to get this IP address, then it will send a request message to the DHCP server. And, at the last, the DHCP server will set the client IP through an Acknowledgement message. So the DORA process will be completed.
Lab Topology for DHCP Server
We will use the below lab topology in the Cisco Packet Tracer:
Creating vlan 10 having the name marwat10. Assign IP address 192.168.10.11/24 to the vlan vlan marwat10.
Create DHCP pool marwat10 in the switch. Assign network 192.168.10.0/24 to the pool. Set the default router to 192.168.10.1 and the DNS server to 192.168.10.10. Also, if we exclude some IP addresses from the pool the DHCP server will not dynamically assign that to any client.
Configure the router interface fast ethernet 0/0 IP address as 192.168.10.1/24.
Now go to PC1 and assign an IP address to the PC dynamically through DHCP.
Assign an IP address to 2nd PC in the same way.
Ping PC2 and Router interface IP.
Similarly also ping PC2, PC3, and PC4 from PC1 to check connectivity among them.
The configuration of the DHCP was simple. It was the configuration for a single vlan. Suppose we have more than one vlan, then what will be the configuration for them?
Configure DHCP Server for multiple vlan
We will use the same topology for configuring DHCP for multiple vlans. We have already configured vlan 10 on the switch. However, We will maintain the same configuration but with a little modification in it. We will create one more vlan and give it a number vlan 20. We will assign IP address 192.168.20.11/24 to the vlan 20. Moreover, we will create the 2nd DHCP pool marwat20 on the switch. The network 192.168.20.0/24 will be assigned to it. The other configuration is in the screenshot below:
Assign interface fast ethernet 0/3-4 to the vlan 10, while assigning interface fastethernet 0/5-6 to the vlan 20. Also, configure the interface fastethernet 0/1 of the switch as a trunk port.
Remove the configured IP address from the router interface fastethernet 0/0. Configure the sub-interface on it. Under sub-interfaces, set its encapsulation dot1Q and, at the last, set its IP addresses.
Now go to PC1 and set its IP address through DHCP Server.
Repeat the same process for PC2.
Also, go to PC3 and set its IP address.
At the last Ping PC2, PC3.