DNS and DHCP Guide

Table of Contents

Domain Name System (DNS)

DNS Overview

DNS is a hierarchical naming system for computers, services, and resources connected to the Internet or private network. It translates domain names into IP addresses.

Key DNS Components:
  • DNS Servers (Name Servers)
  • DNS Records
  • DNS Zones
  • DNS Cache

DNS Record Types

Record Type Purpose Example
A Maps hostname to IPv4 example.com. IN A 192.0.2.1
AAAA Maps hostname to IPv6 example.com. IN AAAA 2001:db8::1
CNAME Alias of one name to another www IN CNAME example.com.
MX Mail exchange example.com. IN MX 10 mail.example.com.
PTR Reverse DNS lookup 1.2.0.192.in-addr.arpa. IN PTR example.com.

DNS Configuration

# Example zone file (example.com.zone)
$TTL 86400
@       IN      SOA     ns1.example.com. admin.example.com. (
                        2023083001  ; Serial
                        3600        ; Refresh
                        1800        ; Retry
                        604800      ; Expire
                        86400 )     ; Minimum TTL

@       IN      NS      ns1.example.com.
@       IN      NS      ns2.example.com.
@       IN      A       192.0.2.1
www     IN      A       192.0.2.1
mail    IN      A       192.0.2.2
@       IN      MX  10  mail.example.com.

Dynamic Host Configuration Protocol (DHCP)

DHCP Overview

DHCP automatically provides IP addresses and other network configuration parameters to client devices on a network.

DHCP Process (DORA):
  1. Discover (Client broadcasts request)
  2. Offer (Server responds with IP)
  3. Request (Client requests specific IP)
  4. Acknowledge (Server confirms IP)

DHCP Configuration Parameters

  • IP Address
  • Subnet Mask
  • Default Gateway
  • DNS Servers
  • Lease Duration
  • Domain Name

Configuration Examples

DHCP Server Configuration

# Example DHCP configuration (dhcpd.conf)
subnet 192.0.2.0 netmask 255.255.255.0 {
    range 192.0.2.100 192.0.2.200;
    option routers 192.0.2.1;
    option domain-name-servers 192.0.2.2, 192.0.2.3;
    option domain-name "example.com";
    default-lease-time 86400;
    max-lease-time 172800;
}

# DHCP Reservation
host printer {
    hardware ethernet 00:11:22:33:44:55;
    fixed-address 192.0.2.50;
}

DNS Server Configuration

# Example named.conf
options {
    directory "/var/named";
    allow-query { any; };
    recursion yes;
    forwarders {
        8.8.8.8;
        8.8.4.4;
    };
};

zone "example.com" IN {
    type master;
    file "example.com.zone";
    allow-update { none; };
};

Troubleshooting

DNS Troubleshooting Tools

# DNS lookup
nslookup example.com

# Detailed DNS query
dig example.com

# DNS server test
dig @8.8.8.8 example.com

# Reverse DNS lookup
nslookup 192.0.2.1

DHCP Troubleshooting

# View DHCP lease
ipconfig /all        # Windows
dhclient -v         # Linux

# Release DHCP lease
ipconfig /release    # Windows
dhclient -r         # Linux

# Renew DHCP lease
ipconfig /renew     # Windows
dhclient           # Linux
Common Issues:
  • DNS resolution failures
  • DHCP address conflicts
  • Incorrect DNS records
  • DHCP pool exhaustion
  • Zone transfer failures

Best Practices

DNS Best Practices

  • Implement DNS redundancy
  • Use secondary DNS servers
  • Regular backup of DNS records
  • Implement DNSSEC
  • Monitor DNS performance

DHCP Best Practices

  • Configure DHCP failover
  • Use appropriate lease times
  • Reserve addresses for critical devices
  • Monitor DHCP scope utilization
  • Regular DHCP log review
Security Considerations:
  • Restrict zone transfers
  • Implement DHCP snooping
  • Use DHCP authentication
  • Monitor for rogue DHCP servers
  • Regular security updates