How To Install And Configure Dns Server In Linux?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
1. Install BIND
Install the BIND package by running the following command:
sudo apt-get install bind9
2. Configure BIND
Once the installation is complete, you need to configure BIND. The main configuration file of BIND is ‘/etc/bind/named.conf’. This file controls all the settings for the DNS server.
Open the file in a text editor and make the following changes:
a) Change the ‘listen-on’ directive to the IP address of the DNS server.
b) Change the ‘allow-query’ directive to the IP addresses of the hosts that will query the DNS server.
c) Change the ‘allow-recursion’ directive to the IP addresses of the hosts that will be allowed to perform recursive queries.
d) Change the ‘forwarders’ directive to the IP addresses of the DNS servers that will be used for forwarding requests.
3. Create Zone Files
Once you have configured BIND, you need to create the zone files for your domains. Each domain will need its own zone file. The zone files are located in the ‘/etc/bind/zones’ directory.
Create a new file for each domain and add the appropriate records for that domain.
4. Reload BIND
Once you have created the zone files, you need to reload BIND. You can do this by running the following command:
sudo service bind9 reload
5. Test the DNS Server
Once you have reloaded BIND, you can test the DNS server by using the ‘dig’ command. This command will allow you to query the DNS server to see if it is working correctly.
For example, you can use the following command to query the DNS server for the ‘A’ record of a domain:
dig @<dns_server_ip> <domain> A
If the DNS server is configured correctly, it should return the appropriate ‘A’ record for the domain.
1. Install the DNS software:
# apt-get update
# apt-get install bind9
2. Configure the /etc/bind/named.conf.options file:
Open the file using a text editor, for example:
# nano /etc/bind/named.conf.options
3. Review the configuration and make sure that the forwarders are configured correctly:
forwarders {
8.8.8.8;
8.8.4.4;
};
4. Configure the DNS zone:
Open the file using a text editor, for example:
# nano /etc/bind/named.conf.local
Add the following entries:
zone “example.com” {
type master;
file “/etc/bind/zones/db.example.com”;
};
Create the zone file (db.example.com):
# nano /etc/bind/zones/db.example.com
Add the following entries:
$TTL 86400
@ IN SOA ns1.example.com. admin.example.com. (
2019020101 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
86400 ) ; Negative Cache TTL
;
@ IN NS ns1.example.com.
@ IN A 192.168.1.10
ns1 IN A 192.168.1.10
5. Create the reverse lookup zone:
Create the file /etc/bind/zones/db.192.168.1
# nano /etc/bind/zones/db.192.168.1
Add the following entries:
$TTL 86400
@ IN SOA ns1.example.com. admin.example.com. (
2019020102 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
86400 ) ; Negative Cache TTL
;
@ IN NS ns1.example.com.
1.0 IN PTR example.com.
6. Restart the bind service:
# systemctl restart bind9