DHCP: how automatic IP assignment works
DHCP works through a four-step process abbreviated as DORA: Discover, Offer, Request, Acknowledge. A new device broadcasts a DHCP Discover, announcing that it needs an IP address. The DHCP server responds with a unicast Offer containing an available IP address and configuration parameters. The device broadcasts a Request to formally ask for the offered address. The server sends an Acknowledge confirming the lease.
A DHCP lease has a duration after which the client must renew. Renewal begins at 50 percent of the lease time by sending a unicast renewal request to the server. If the server does not respond, the client tries again at 87.5 percent. If still no response, the client broadcasts another DORA sequence at expiry to find any available server.
The DHCP server must be configured with a scope: the range of addresses available for assignment, the subnet mask, the default gateway, the DNS server addresses, and the lease duration. Excluded addresses within the scope are reserved for static assignment to servers and printers. If a client receives an APIPA address (169.254.x.x), it means DHCP failed and the client self-assigned a link-local address.
DHCP relay and DNS fundamentals
DHCP Discover messages are broadcasts, and routers do not forward broadcasts between subnets. In a network with multiple subnets and a single DHCP server, routers must be configured as DHCP relay agents (ip helper-address on Cisco). The relay agent converts the broadcast Discover into a unicast and forwards it to the DHCP server. The server knows which scope to use because the relay includes the subnet information in the forwarded packet.
DNS translates domain names to IP addresses. When you type example.com in a browser, your device sends a DNS query to its configured DNS server (the recursive resolver). If the resolver does not have the answer cached, it follows a hierarchy: first querying a root DNS server, then the authoritative server for the top-level domain (.com), then the authoritative server for example.com. The final answer is returned, cached for the duration of the TTL, and used to make the connection.
DNS records store different types of information. A records map a hostname to an IPv4 address. AAAA records map a hostname to an IPv6 address. CNAME records create an alias from one hostname to another. MX records identify mail servers for a domain. PTR records support reverse DNS lookups, mapping an IP address back to a hostname.
How to choose the correct answer
DORA steps: Discover (client broadcast, no IP yet), Offer (server unicast), Request (client broadcast), Acknowledge (server unicast). Both Discover and Request are broadcasts because the client has no IP yet when it sends Discover and wants all servers to know which offer it accepted.
APIPA address (169.254.x.x): DHCP failed. Client could not reach any DHCP server.
DHCP relay: needed when DHCP server and clients are on different subnets. Configured on the router with ip helper-address pointing to the DHCP server.
DNS record types: A = IPv4. AAAA = IPv6. CNAME = alias/redirect. MX = mail server. PTR = reverse lookup. SOA = start of authority for the zone. NS = name server for the zone.
DNS TTL: how long a resolver caches the answer. Lowering TTL before a planned DNS change ensures clients pick up the new record faster after the change.