DHCP protocol
Using Dynamic Host Control Protocol , a DHCP Server typically hosted on one of the router in your network, assigns IP addresses to the clients who ask for it.
DHCP is a UDP based protocol. The server listens on UDP port 67, and the client listens on UDP port 68.
Handshake
Client Server
------- DISCOVER --------->
<------- OFFER -----------
------- REQUEST ---------->
<----- ACKNOWLEDGE ------->
During DHCP handshake, the client and server exchange following information crucial for connectivity:
- client’s ip address with subnet mask
- client’s hostname
- The network’s DNS server ip (if exists, almost always on the router)
- The domain name e.g. “.local”. Used for DNS resolution of the hostnames in local network. e.g. “mypc.local”
Once DHCP Server assigns an IP address to a client, it also takes care of updating the corresponding DNS server’s entry, adding a new entry containing the client's hostname and client's IP.
The local network’s DNS server is also running on your router (typically) on port 53.