DNS S
DNS S
DNS S
bash
Copy code
sudo apt update
sudo apt install bind9 bind9utils bind9-doc
bash
Copy code
sudo yum install bind bind-utils
The main configuration file for BIND is typically located at /etc/bind/named.conf (on
Debian/Ubuntu) or /etc/named.conf (on CentOS/RHEL).
bash
Copy code
sudo nano /etc/bind/named.conf.options # Debian/Ubuntu
sudo nano /etc/named.conf # CentOS/RHEL
Within the configuration file, you can define options like DNS forwarding, directory, and
ACLs. Here’s an example of what this block may look like:
plaintext
Copy code
options {
directory "/var/cache/bind";
allow-query { any; };
recursion yes;
forwarders {
8.8.8.8; # Google DNS
8.8.4.4;
};
};
DNS zones contain the mapping of IP addresses to domain names. You’ll need to set up
forward and reverse lookup zones.
o Forward Lookup Zone (maps domain name to IP):
plaintext
Copy code
zone "example.com" {
type master;
file "/etc/bind/zones/db.example.com";
};
plaintext
Copy code
$TTL 604800
@ IN SOA ns1.example.com. admin.example.com. (
3 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ) ; Negative Cache TTL
; Name servers
@ IN NS ns1.example.com.
plaintext
Copy code
zone "1.168.192.in-addr.arpa" {
type master;
file "/etc/bind/zones/db.192.168.1";
};
plaintext
Copy code
$TTL 604800
@ IN SOA ns1.example.com. admin.example.com. (
3 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ) ; Negative Cache TTL
; Name servers
@ IN NS ns1.example.com.
; PTR records
10 IN PTR example.com.
bash
Copy code
sudo chown bind:bind /etc/bind/zones/db.example.com
sudo chown bind:bind /etc/bind/zones/db.192.168.1
bash
Copy code
sudo systemctl restart bind9 # Debian/Ubuntu
sudo systemctl restart named # CentOS/RHEL
bash
Copy code
sudo systemctl enable bind9 # Debian/Ubuntu
sudo systemctl enable named # CentOS/RHEL
To test the DNS server, you can use dig or nslookup commands from a client computer:
bash
Copy code
dig @your_server_ip example.com
bash
Copy code
dig @your_server_ip -x 192.168.1.10
Additional Notes
Firewall Rules: Ensure that port 53 (UDP/TCP) is open on your firewall.
Set Up Secondary DNS (Optional): For redundancy, set up a secondary DNS server that
pulls zone information from the primary server.
This setup should give you a functioning DNS server using BIND. Let me know if you need help
with specific aspects or advanced features!