DNS & DHCP
DNS (Domain Name System) and DHCP (Dynamic Host Configuration Protocol) are two essential services in modern networks.
DNS Concept and Workflow
DNS is the service that translates human-readable domain names (e.g., www.google.com) into machine-readable IP addresses (e.g., 172.217.14.228).
Workflow:
- A user enters a domain name into their web browser.
- The operating system's DNS resolver sends a query to a DNS server.
- The DNS server looks up the IP address corresponding to the domain name.
- The DNS server returns the IP address to the resolver.
- The browser uses the IP address to connect to the web server.
Check DNS Resolution
You can use the dig and nslookup commands to query DNS servers.
-
Using
dig:dig www.google.com -
Using
nslookup:nslookup www.google.com
DHCP Concept and Workflow
DHCP is a network management protocol used on Internet Protocol (IP) networks for automatically assigning IP addresses and other communication parameters to devices connected to the network.
Workflow (DORA process):
- Discover: A client device broadcasts a DHCP Discover message to find a DHCP server.
- Offer: A DHCP server responds with a DHCP Offer message, which includes a proposed IP address and other configuration information.
- Request: The client broadcasts a DHCP Request message to accept the offer.
- Acknowledge: The DHCP server sends a DHCP Acknowledge message to confirm the lease.
DHCP Lease Debugging
You can debug DHCP lease issues by examining system logs and lease files.
-
Check system logs for DHCP messages:
journalctl | grep -i dhcp -
View the DHCP lease file: The location of the lease file varies. On many systems, it can be found at
/var/lib/dhcp/dhclient.leases.cat /var/lib/dhcp/dhclient.leases