DHCP and DNS Server Setup and Configuration
Dynamic Host Configuration Protocol (DHCP)
DHCP (Dynamic Host Configuration Protocol) is a TCP/IP standard designed to simplify the administration of IP configuration for network equipment.
A DHCP server receives requests from clients requesting IP network settings.
DHCP Server Components
- Scope: An administrative grouping of computers or clients in a subnet using DHCP service.
- Range: A group of IP addresses in a given subnet (e.g., 192.168.0.1 to 192.168.0.254) that the DHCP server can grant to clients.
- Concession or Lease: A specified time period during which a client computer can use an assigned IP address.
- IP Address Reservation: Reserving specific IP addresses to always assign the same IP to certain client PCs.
DHCP Server Commands (Ubuntu)
Install DHCP Server:sudo apt-get install dhcp3-server
Configuration File:/etc/dhcp3/dhcpd.conf
Start DHCP Server:sudo /etc/init.d/dhcp3-server start
Stop DHCP Server:sudo /etc/init.d/dhcp3-server stop
Restart DHCP Server:sudo /etc/init.d/dhcp3-server restart
Domain Name System (DNS) Server
A DNS server resolves PC names to IP addresses. It maintains a database of IP addresses and corresponding computer names within a domain.
DNS Server Concepts
- Direct Search Area (Forward Lookup Zone): Resolves a domain name to an IP address.
- Reverse Lookup Zone: Resolves an IP address to a domain name (e.g., “What is the DNS name of the computer using the IP address 192.168.0.20?”).
- DNS Forwarder: A DNS server designated by internal DNS servers to resolve external domain names outside the local domain.
The dnsmasq package is a simple DNS server suitable for small networks. The bind package is a complete DNS server used by many DNS servers on the internet.
DNS Server Commands (Ubuntu)
Install dnsmasq:sudo apt-get install dnsmasq
Start/Restart dnsmasq:sudo /etc/init.d/dnsmasq restart
Stop dnsmasq:sudo /etc/init.d/dnsmasq stop
Edit Configuration (Set DHCP Range):sudo nano /etc/dnsmasq.conf
Add: dhcp-range=192.168.1.201,192.168.1.230,24h
IP Lease File:/var/lib/misc/dnsmasq.leases
Configure Client Hostname:
Edit /etc/dhcp3/dhclient.conf
Add: send host-name aula1pc1
Start BIND DNS Server:sudo /etc/init.d/bind9 start
Stop BIND DNS Server:sudo /etc/init.d/bind9 stop
Restart BIND DNS Server:sudo /etc/init.d/bind9 restart
IP Lease File (dnsmasq):/var/lib/misc/dnsmasq.leases
File Forward Lookup Zone
Example: Classroom “aula5” with 12 PCs (IPs 192.168.0.101-112, names aula5pc1-aula5pc10), a web server (PC11), and an email/DNS server (PC12).
DNS Configuration File (/etc/bind/ieslapaloma.db
):
; BIND data file for ieslapaloma.com
;
@ IN SOA ieslapaloma.com. root.ieslapaloma.com. (
1 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ; Default TTL
);
IN NS dns.ieslapaloma.com.
IN MX 10 mail.ieslapaloma.com.
aula5pc1 IN A 192.168.0.101
aula5pc2 IN A 192.168.0.102
aula5pc3 IN A 192.168.0.103
aula5pc4 IN A 192.168.0.104
aula5pc5 IN A 192.168.0.105
aula5pc6 IN A 192.168.0.106
aula5pc7 IN A 192.168.0.107
aula5pc8 IN A 192.168.0.108
aula5pc9 IN A 192.168.0.109
aula5pc10 IN A 192.168.0.110
www IN A 192.168.0.111
dns IN A 192.168.0.112
mail IN A 192.168.0.112
File Reverse Lookup Zone
To enable reverse lookups (IP to name), create the following file:
Reverse DNS Configuration File (/etc/bind/192.rev
):
; BIND reverse data file for 192.168.0.0
;
@ IN SOA ieslapaloma.com. root.ieslapaloma.com. (
1 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ; Default TTL
);
IN NS dns.ieslapaloma.com.
101 IN PTR aula5pc1.ieslapaloma.com.
102 IN PTR aula5pc2.ieslapaloma.com.
103 IN PTR aula5pc3.ieslapaloma.com.
104 IN PTR aula5pc4.ieslapaloma.com.
105 IN PTR aula5pc5.ieslapaloma.com.
106 IN PTR aula5pc6.ieslapaloma.com.
107 IN PTR aula5pc7.ieslapaloma.com.
108 IN PTR aula5pc8.ieslapaloma.com.
109 IN PTR aula5pc9.ieslapaloma.com.
110 IN PTR aula5pc10.ieslapaloma.com.
111 IN PTR www.ieslapaloma.com.
112 IN PTR dns.ieslapaloma.com.
112 IN PTR mail.ieslapaloma.com.