Skip to main content

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:

  1. A user enters a domain name into their web browser.
  2. The operating system's DNS resolver sends a query to a DNS server.
  3. The DNS server looks up the IP address corresponding to the domain name.
  4. The DNS server returns the IP address to the resolver.
  5. 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):

  1. Discover: A client device broadcasts a DHCP Discover message to find a DHCP server.
  2. Offer: A DHCP server responds with a DHCP Offer message, which includes a proposed IP address and other configuration information.
  3. Request: The client broadcasts a DHCP Request message to accept the offer.
  4. 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