Domain Name System (DNS) and Dynamic Host Configuration Protocol (DHCP) are foundational network services that enable seamless address resolution and network configuration in Linux environments.
DNS maps human-readable domain names to IP addresses, facilitating efficient resource location, while DHCP automates the assignment of IP addresses and other network parameters to devices. Proper configuration and management of DNS and DHCP clients and servers are vital for reliable network connectivity and service accessibility.
DNS Client Configuration
Linux systems typically use /etc/resolv.conf for DNS resolver configuration, specifying nameservers:
nameserver 8.8.8.8
nameserver 8.8.4.41. The file can be overwritten by network managers like NetworkManager or resolvconf.
2. systemd-resolved provides a local DNS stub listener on 127.0.0.53 for caching and forwarding.
3. DNS lookup and troubleshooting tools include dig, nslookup, and host.
Static and Dynamic DNS Resolution
Static DNS: IP addresses are manually mapped to hostnames using /etc/hosts, which overrides DNS lookups for the system.
Example entry:
192.168.1.10 myserver.localDynamic DNS (DDNS): Enables automatic updates of DNS records by clients or DHCP servers to DNS servers, facilitating dynamic address changes without manual intervention.
DNS caching is common to improve lookup performance and reduce network traffic.
DHCP Configuration Concepts
DHCP automates the assignment of network configuration details such as IP addresses, subnet masks, default gateways, DNS servers, and lease durations, reducing the need for manual configuration. DHCP client software, including tools like dhclient or systemd-networkd, handles requesting, renewing, and releasing IP leases on client systems.
On the server side, DHCP configurations define address pools, lease times, and additional options to ensure consistent and efficient network management.
Example DHCP server snippet:
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.100 192.168.1.200;
option routers 192.168.1.1;
option domain-name-servers 8.8.8.8, 8.8.4.4;
default-lease-time 600;
max-lease-time 7200;
}Network Service Management
1. Services like named for DNS and dhcpd for DHCP run as background daemons.
2. Use systemctl to start, enable, stop, or check these service statuses:
sudo systemctl start named
sudo systemctl enable dhcpd
sudo systemctl status named3. Log files and journal entries help monitor and troubleshoot DNS/DHCP services.