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.
| 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. |
# 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.
DHCP automatically provides IP addresses and other network configuration parameters to client devices on a network.
# 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;
}
# 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; };
};
# 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
# 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