Client broadcasts DHCPDISCOVER to find the DHCP server
DHCP server responds by DHCPOFFER
reserves an IP address for the client and makes a lease offer
response contains info like
Client ID (MAC Address)
IP address which is offered
subnet mask
lease duration
IP address of the DHCP server
A client can receive DHCP offers from multiple servers, but it will accept only one DHCP offer
Client receives the response and then broadcast DHCPREQUEST message requesting the offered address
The client must send the server identification option in the DHCPREQUEST message, indicating the server whose offer the client has selected
When other DHCP servers receive this message, they withdraw any offers that they have made to the client and return their offered IP address to the pool of available addresses
DHCP server acknowledges the request and reply with DHCPACK
Contains info like lease duration, IP address and any other configuration requested
sequenceDiagram
participant Client as Client
participant Server as DHCP Server 1
participant Server2 as DHCP Server 2
Client->>+Server: DHCPDISCOVER <br/>[broadcast]
Client->>+Server2: DHCPDISCOVER <br/>[broadcast]
Server-->>-Client: DHCPOFFER (Server 1)
Server2-->>-Client: DHCPOFFER (Server 2)
Client->>+Server: DHCPREQUEST (Server 1) <br/>[broadcast]
Client->>+Server2: DHCPREQUEST (Server 1) -- REJECTED<br/>[broadcast]
Server-->>-Client: DHCPACK (Server 1)
DHCP Server Configuration
IP allocation
Automatic allocation
This one will automatically assign an IP per client permanently.
The IP address will be designated for just one device, so if, in the future, many new devices get connected, the server could run out of IP addresses to give.
Dynamic allocation
This is the most common configuration. The server auto-assigns IP addresses to clients, but there is a time period.
After the time expires, the client needs to ask for a new IP address again. This will prevent the running out of IPs.
Manual allocation
Manually the network administrator will assign the IP address to the client.
Lease Duration Times
Refers to how long a device can use an IP address assigned by a DHCP server without needing to renew it
Shorter Lease time is suitable for dynamic networks, while longer ones provide stability
Connecting to the Internet
Every host need these 4 things to connect to internet:
IP Address
Subnet mask
Default Gateway
DNS Server IP
DHCP provides these 4 things
Manual assignment
It is possible to assign static IP manually instead of DHCP
If two devices were assigned the same IP address, Data would not be delivered reliably or properly, and might not be delivered at all