Almost everybody uses Internet either in their homes and offices, and we get connected via an Internet modem, DSL, LAN or Wireless LAN connection.
All you need to do is to open up your modem application interface and click on connect, and for cable users, you plug in your network cable to your computer. In a matter of seconds, you are connected to the Network and to the Internet.
Have you ever wondered how that modem or cable connected to the service provider? Ever wondered about the series of process that went down within that short time before you could gain access to the network?
I think you do!
Well, DHCP makes all that possible.
What is DHCP?
DHCP is a network protocol used to configure network devices so they can communicate on an IP network. DHCP client uses DHCP protocol to acquire configuration information, such as an IP address, a default route, DNS server address and other needed configuration settings from the server.
This IP addresses are released and renewed when the devices leaves and re-joins the network.
Your ISP has a DHCP server. They can assign IPs by modem or computer MAC addresses. When your modem comes online, it communicates to the network indicating it is looking for an IP address. DHCP server listens to the communication and starts talking to the modem. At this point, the modem or computer transmits its MAC address to the DHCP server, and in return is assigned an IP address. With the IP address, a modem can now connect to the network and to the internet.
ISPs usually use DHCP to allow customers to join the internet with minimum effort. Likewise, home network equipment like broadband routers (Wired/Wireless) offer DHCP support for added convenience in joining home computers/devices to the LAN.
DHCP environments require a DHCP server set up with the appropriate configuration parameters for the given network. Devices running the DHCP client software can then automatically retrieve these settings from the server as required.
Using DHCP on a network means System Administrators do not need to configure these parameters individually for each client device connecting to the network.
The above explains how your modem, computer and devices connect to the network/internet.
Now, let’s see the DHCP Client/server interaction when allocating a new network address.
DHCP Client/Server Interaction
DHCP configuration is accomplished through the following sequence of steps:
1. The DHCP client broadcasts a DHCPDISCOVER message on the local subnet.
2. All servers on the subnet receive the DHCPDISCOVER message1. If the servers have any IP addresses available, they broadcast a DHCPOFFER message. The use of "serial numbers" in the packets lets the client know that a certain DHCPOFFER corresponds to a certain DHCPDISCOVER.
3. The DHCP client receives all DHCPOFFER messages. Different servers may offer the client different network parameters. The client selects the best DHCPOFFER, and throws away the rest. The client then broadcasts a DHCPREQUEST message, filling in the "server identifier" field of the DHCPREQUEST with the IP address of the server whose DHCPOFFER it has chosen.
4. The servers all receive the DHCPREQUEST. They all look to see if their IP address is in the "server identifier" field of the message. If a server does not find its IP address there, it knows the client has rejected its DHCPOFFER. If the server does find its IP address there, it can proceed in one of two ways. If the IP address is still available, and everything is going well, the server broadcasts a DHCPACK to the client. If there is some sort of trouble, the server sends a DHCPNAK instead.
5. The client receives either a DHCPACK or a DHCPNAK from the server it selected. If the client receives a DHCPACK, then all is well, and it has now obtained an IP address and network parameters. If the client receives a DHCPNAK, it can either give up or it can restart the process by sending another DHCPDISCOVER. If, for some reason, the client receives a DHCPACK but is still not satisfied, it can broadcast a DHCPDECLINE to the server.
DHCP is very interesting; imagine the stress we would be going through to connect to a local or wireless network without the DHCP service.