Understanding DHCP discovery specific subnet
I am learning networking and in class we are talking about DHCP. I understand that when a host just joins a network it does not have an ip yet so it sends out a dicovery message.
we are using wireshark to see the in's and out's of the DHCP message. One thing I don't get is why is my host broadcasting to 255.255.255.255. What is happening? What is prompting my DHCP server or this case my router responding?
I hope some one can explain this to me.
Network Broadcasting
Network interface cards are usually programmed to listen for three types of messages. They are messages sent to their specific address, messages broadcast to all NICs, and messages that qualify as a multicast for the specific card. There are three types of addressing:
- Unicast - A transmission to a single interface card.
- Multicast - A transmission to a group of interface cards on the network.
- Broadcast - A transmission to all interface cards on the network. RFC 919 and 922 describe IP broadcast datagrams.
- Limited Broadcast - Sent to all NICs on the some network segment as the source NIC. It is represented with the 255.255.255.255 TCP/IP address. This broadcast is not forwarded by routers so will only appear on one network segment.
- Direct broadcast - Sent to all hosts on a network. Routers may be configured to forward directed broadcasts on large networks. For network 192.168.0.0, the broadcast is 192.168.255.255. \
A DHCP client starts the DHCP process by issuing a DHCPDISCOVER message to its local subnet on UDP port 67. Since the client does not know what subnet it belongs to, the Limited Broadcast address is used (destination address 255.255.255.255). If the DHCP server is located on a different subnet, a DHCP-relay agent must be used.
How Dynamic Host Configuration Protocol (DHCP) Works
DHCP works by leasing IP Addresses and IP information to network clients for a period of time.
For the lease to happen, the following negotiation process occurs:
- During the boot process, a client computer that is configured as a DHCP client sends out a broadcast packet called "DHCP Discovery". This Discover packet contains the client's computer name and Media Access Control (MAC) address so the DHCP servers can respond to it. Basically, the Discover packet says, "I'm looking for a DHCP server who can lease an IP Address".
- DHCP servers on the network respond to the broadcast with a "DHCP Offer". In essence, the "DHCP Offer" says, "I am a DHCP server and I have a lease for you". If several DHCP servers respond to the request, the client accepts the first offer that it receives.
- The client responds via a broadcast message called a "DHCP Request". This message basically says, "I accept your lease offer and would like an IP Address" If other DHCP servers made offers, they also see their lease offers were not accepted by the broadcast message, so they rescind their offers.
- The DHCP server whose offer was accepted responds with a "DHCP Acknowledgment" message, which acknowledges the lease acceptance and contains the client's IP Addresses lease as well as other IP Addressing information that you configure the server to provide. The client is now a TCP/IP client and can participate on the network.
The DCHP Lease Life Cycle
The use of dynamic address allocation in DHCP means a whole new way of thinking about IP Addresses.
- A client no longer owns an IP Address, but rather leases it.
- This means that when a client machine is set to use DHCP dynamic addressing, it can never assume that it has an IP Address on a permanent basis.
- Each time it powers up, it must engage in communications with a DHCP server to begin or confirm the lease of an IP Address.
- It also must perform other activities over time to manage this lease and possibly terminate it.
Typically, a client can keep its IP Address for several days (or whatever you configure). When half the lease time expires, the client attempts to renew its lease for the IP Address. After a client obtains the lease for an IP Address, it attempts to keep the lease by renewing it over and over. If unsuccessful, the client simply must get a new IP Address lease.
DHCP leases follow a "life cycle", which generally consists of the following phases:
- Allocation: A client begins with no active lease, and hence, no DHCP-assigned IP Address. It acquires a lease through a process of allocation.
- Reallocation: If a client already has an IP Address from an existing lease, then when it reboots or starts up after being shut down, it will contact the DHCP server that granted it the lease to confirm the lease and acquire operating parameters. It is similar to the full allocation process but shorter.
- Normal Operation: Once a lease is active, the client functions normally, using its assigned IP Address and other parameters during the "main part" of the lease. The client is said to be bound to the lease and the address.
- Renewal: After a certain portion of the lease time has expired, the client will attempt to contact the server that initially granted the lease, to renew the lease so it can keep using its IP Address.
- Rebinding: If renewal with the original leasing server fails (because, for example, the server has been taken offline), then the client will try to rebind to any active DHCP server, trying to extend its current lease with any server that will allow it to do so.
- Release: The client may decide at any time that it no longer wishes to use the IP Address it was assigned, and may terminate the lease, releasing the IP Address. This may be done if a device is moving to a different network, for example.
This diagram illustrates the DHCP life cycle using an example that spans three leases:
- The initial lease has a duration of eight days and begins at Day 0.
- The T1 and T2 timers are set for 4 days and 7 days respectively.
- When the T1 timer expires the client enters the renewal period, and successfully renews at Day 5 with a new 8-day lease.
- When the second lease T1 timer expires, the client is unable to renew with the original server.
- It enters the rebinding period when its T2 timer goes off, and is granted a renewed 8-day lease with a different server.
- Three days into this lease it is moved to a different network and no longer needs the leased IP Address, and voluntarily releases it.
Further Reading
- Wikipedia: Dynamic Host Configuration Protocol
- DHCP FAQ
- Microsoft: DHCP (Dynamic Host Configuration Protocol) Basics
- DNS, BIND, DHCP, LDAP and Directory Services