Ethernet – How does DHCP assign an IP address

broadcastdhcpethernetip address

I understand that IP address is a unique address to identify a machine in a network. But for the first time when i Plug in say ethernet cable of a network to my PC's Ethernet Port, how the IP address is assigned? Let's rule out static IP address where you can configure manually.

How a DHCP assigns a IP address when i Plugin network cable for first time.

Best Answer

The basic process is quite simple. I'll only cover that and omit scenarios where several DHCP servers exist, error conditions crop up or discovery has to cross network boundaries.

  1. A new client on a network sends a DHCPDISCOVER via udp from address 0.0.0.0 to 255.255.255.255:67 (broadcast, port 67).
  2. If there is at least one DHCP servers listining in the network segment it responds with a DHCPOFFER to broadcast on port 68. DHCPOFFER includes all required settings for the client.
  3. The client now sends DHCPREQUEST to the DHCP server, still using the anonymous 0.0.0.0 address.
  4. The contacted DHCP server replies with a DHCPACK, which signals to the client that it may use the provided details.

For more information on the DHCP packet content and what to do in error cases read the Wikipedia article: https://en.wikipedia.org/wiki/DHCP

Related Topic