A Computer using TCP/IP protocol suit require following configuration information to participate in a network :-
- IP Address
- Subnet mask/net mask
- Default Gateway
- Name Server/preferred or alternate DNS
Now a days DHCP is used as an standard way to assign IP addresses to the systems for accessing the Internet/Intranet. Initially RARP was used for dynamic IP address assigning then BOOTP came into existance and finally DHCP is used for the same.
RARP —-> BOOTP ——-> DHCP
- DHCP was first used as a standard track protocol in Oct, 1993.
- It is extension of Bootstrap Protocol (BOOTP)
- BOOTP require manual intervention (effort) to add configuration information for each computer.
- BOOTP does not provide a mechanism to reclaim the used IP address.
- BOOTP is also the replacement for RARP
- RARP is datalink layer protocol which make implementation of RARP server difficult on many server plateform (windows, MAC etc).
- RARP also require that a RARP server be present same network.
- Each computer has a unique physical Address (MAC Add).
- RARP read computer MAC Address and send an RARP request (in frame) over the network , asking from someone to replay (RARP reply message ) with IP address .
- RARP request can not be forwarded by routers (hardware level broadcast). So, RARP Server must be present on same physical Ethernet network (of its client).
- RARP uses broadcast server of DLL.
- RARP only provide IP Address while a computer require other information like mask , Gateway, DNS etc.
BOOTP server can be anywhere in the internet and also provide all the configuration information (IP, mask, Gateway and DNS).
limitation: It is Static configuration protocol i.e. binding of MAC to IP already defined manually in form of table at BOOTP server.
- A computer move from one physical network to another.
- A new host needs a temporary IP address.
In BOOTP binding is static and fixed until changed by admin so assigned IP can’t be used in above 2 situation. so DHCP is used.
DHCP is a Client-Server protocol which is used to provide the following information to a computer that is booted for 1st time.
- IP Address
- Subnet mask
- IP of router (default gateway)
- IP of name server (DNS)
DHCP allows a network Admin to supervise and distribute IP address from a central point and automatically assign a new IP when a computer move to different place in the network.
- DHCP Client: RFC 2131 compatible network device able to communicate with DHCP server.
- DHCP Server: maintain scope, reservations and options.
- DHCP relay agent.
DHCP Operations: DHCP operates in following modes –
- Automatic: DHCP assigns a permanent IP Address to a client.
- Dynamic: Assigns an IP for limited period of time
- Manual: Admin assign a client with IP address and DHCP simply assign that address to that client. (but assigned IP will be within IP range configured in DHCP server).
DHCP Operation Principle ( How DHCP works): DHCP uses 4 way Handshake process for assigning IP address.
How does DHCP work?
1. DHCP client broadcast the IP discovery message on subnet to discover available DHCP server.
DHCP Discover packet says, “I’m looking for a DHCP server who can lease an IP address.”
2. No. of DHCP servers respond with “IP lease offer message” which contain MAC address of client , offered IP, lease duration, subnet mask and IP of DHCP server.
DHCP OFFER says, “I am a DHCP server and I have a lease for you.”
3. After receiving IP lease offer, DHCP client send DHCPREQUEST to inform all the other DHCP servers that it has accepted an offer.
DHCP REQUEST message says, “I accept your lease offer and would like an IP address.”
- DHCP client receives IP lease offer message from some DHCP servers.
- DHCP client compare the offers with the settings that it has requested.
- DHCP client then broadcast DHCPREQUEST msg containing the IP address of the DHCP server that made the offer.
- This broadcast DHCPREQUEST msg inform all other DHCP servers that a DHCP server is selected.
- When other DHCP servers receives DHCPREQUEST msg they withdraw IP lease that they offered and return it to the pool of valid IP address.
4. DHCP server sends an ACK (DHCP ACK Packet) to DHCP client. The client is now a TCP/IP client and can participate on the network.
DHCP ACK Packet include –
- Lease duration and
- Offered IP Address
- Destination IP Address
- Client hardware Address
- Subnet mask.
DHCP Server within Same Network
1. DHCP server is passively open at port 67 and wait for client.
2. DHCP client request in active open mode at port 68.
- DHCP request message is encapsulated in a UDP datagram with source port 68 and destination port 67.
- This datagram is encapsulated in an IP packet with source IP (DHCP Client) as all 0’s (because don’t know its IP address) and all 1’s (broadcast address) as destination IP address because it does not know DHCP servers IP address.
DHCP Server on a different network
Broadcast packet can not pass through any router (Broadcast within the subnet). So, A router receiving such a request packet discard it. To solve this problem , one of the host that knows the unicast address of DHCP server, listen the broadcast message on port 67, such host is known as relay agent.
2. When relay agent receive this broadcast message or packet, it encapsulates this request message to unicast packet and send it to the DHCP server.
3. DHCP server send the replay to relay agent and relay agent send it to the DHCP client.