DHCP is successor of BOOTP. DHCP and BOOT share same message format. RARP can also be used to distrbiute IP address to machine but other parameters cannot be distributed and RARP works in same physical network. In case of RARP network administrator have to manually assign IP address to each mac address. BOOTP doesnot have dynamic address allocation capability so DHCP came into picture.
DHCP and BOOTP uses UDP one reason is that TCP doesn’t support broadcast. Now as most to traffic is broadcast so the packets exchanged will be delivered to all hosts in the network, If client uses any random source port it is possible that that port may be used by any other host so the reply from the server might confuse that other host so just to avoid confusion client listen on standard udp port 67.
UDP is connectionless protocol so if the traffic is dropped in between retransmission is used.
DHCP message format:
| op (1) | htype (1) | hlen (1) | hops (1) |
| xid (4) |
| secs (2) | flags (2) |
| ciaddr (4) |
| yiaddr (4) |
| siaddr (4) |
| giaddr (4) |
| chaddr (16) |
| sname (64) |
| file (128) |
| options (variable) |
Client might have send multiple request and it might have receieved multiple response so to match request with response xid(Transaction ID) is used.
giaddr field is filled by DHCP relay agent. If there are multiple relay agent this field is field by first relay agent and if there are transit relay agent then they will not modify this field.
DHCP messages: There are 8 types of messages in DHCP.
DHCPNAck: This message can be sent in various situation.For example:
- When DHCP client is trying to renew the lease then this message can be sent. DHCPNAck will be sent sent by server if the client is trying to renew a lease after moving to some different network or Client is trying to renew its leease after lease has expired. Upon receiving DHCPNack client move to init state.
Whenever a DHCP client gets an IP address from DHCP server before using it client checks if that IP address have been used already or not. If it is being used then a DHCPDecline message is send to server. While renewing the DHCP lease gratitous ARP is not used to check if the IP address is already being used or not.
If a DHCP client want to release IP address that it has got from the dhcp server client will send a unicast DHCPrelease message to the server.
DHCPinform message can be used by a client to get few parameters from the dhcp server. Client might have receieved ip address information from some other mean but client needs other parameter for this client can use DHCPinform message to get the required parameters. DHCPinform message can be sent either to broadcast address if the DHCP server is not known or to unicast address if DHCP server is known.
There are following states in DHCP:
- Init:This is initial state. DHCP client will be in this state initially. DHCP client can be in this state if the DHCP lease expires.
- Selecting:In this state the client is waiting for the reply of the DHCP discover message from DHCP servers, means client is waiting for DHCP offer message from server/servers.
- Requesting:Client selects the offer it have received from the DHCP server and sends DHCP request message in the state.
- Bind:Client have received DHCPAck from the server and it means that now client have valid IP address and other DHCP parameters to use.
- Renewing: Client have the IP address and now it is try to renew the lease. In this state client send DHCPRequest message to the DHCP server who have offered the IP address and other information. Renewing of IP starts after half of the lease have expired.
- Rebinding: In this state client is not able to renew its lease with the DHCP server which have offered the DHCP information. Now DHCP client will try to send the DHCPRequest message to broadcast IP address and try to renew the lease to any of the avail DHCP server. Client trys to renew the lease with other DHCP server when 87.5% of the lease have expired. If no server replies or if a DHCPNack have been received then the DHCP client will immediately stops using the IP address and enters into INIT state.
- Init-Reboot: Client will be in this state if client reboots or powered up and have a valid lease from previous DHCP DORA process. Client will try to send and DHCPRequest message to verify if it can still use the same IP address. From this state client moved to Rebooting state.
- Rebooting:Client is waiting for reply of DHCPDiscover message sent in Init-Reboot state.
DHCP allocation method:
- Manual allocation: Network admin will allocate the IP address to devices manually DHCP will be used to convey that info to the end host.
- Automatic allocation: DHCP will assign IP address to end host and the lease will be permanent.
- Dynamic allocation: DHCP will allocate the IP address to end host from a pool for some period of time once the lease expires host has to renew the lease.
Timer in DHCP: DHCP server maintain the lease which it has allocated to client. Client keep track of the lease so that it can request for extension when needed. Client initate the lease extension.
- Renewal timer (T1): The value of this timer is 50% of the lease. Whenever 50% of the lease time is passed client initiate the process of renewal with the server who have assigned the IP address. Client sends DHCPRequest message direclty to the server who have issued address.
- Rebinding time(T2): The value of this time is 87.5% of the lease. After 87.5% of lease time client try to renew its lease to another DHCP server in the network as the renewal with the server who have assigned have failed. In this client will send a broadast DHCPRequest message.
Multiple DHCP offer:
If client gets multiple DHCP offer from various server then client might take the first offer that it have receieved or else it will wait for other DHCP server to reply and take the offer that suites best.
Offered address not avail on server:
If the ip address offered in DHCP offer is not avail then DHCP server will reply back with DHCPNack and then client might try to send DHCP request to another server if avail or else client will start the DHCP process from scratch.
Offered IP is in use:
Once client gets DHCPAck message client will verify if the offered address is being used by someone else or not this is done with the help of sending gratitous ARP if a reply comes then it mean that someone is using the IP address and DHCP client wil send DHCPDecline message to server and start the process from scratch.
What if client doesn’t get any reponse from any server while renewing/rebinding the IP address lease?
Client keep on trying to renew the IP address lease to the server who have give the address by sending unicast DHCPrequest message. If the T1 timer expires then client will try to send broadcast DHCPdiscover message. If still client doesn’t receive any reply then when lease expires client stops using IP address and fall back to init state.
|Option 150, 66||When a CISCO IP Phone boots up, if may not have its own IP address and it may not know the ip address of TFTP server. To get the IP address of the TFTP server Option 150,66 can be used. Option 150 can provide of list of IP address and option 66 can provide only one IP address of TFTP server|