How To Setup Local 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 the DNS server software:
For Ubuntu/Debian users:
sudo apt-get install bind9
For Red Hat/CentOS users:
sudo yum install bind
2. Configure the DNS server:
Edit the configuration files for the DNS server.
For Ubuntu/Debian users:
sudo nano /etc/bind/named.conf.local
For Red Hat/CentOS users:
sudo nano /etc/named.conf
Add the following lines to the configuration file:
zone “example.com” {
type master;
file “/etc/bind/db.example.com”;
};
3. Create the zone files:
Create a file for each domain you are hosting.
For Ubuntu/Debian users:
sudo nano /etc/bind/db.example.com
For Red Hat/CentOS users:
sudo nano /var/named/db.example.com
Add the following lines to the file:
$TTL 86400
@ IN SOA ns1.example.com. hostmaster.example.com. (
1 ; serial
3600 ; refresh
1800 ; retry
604800 ; expire
86400 ) ; minimum
IN NS ns1.example.com.
IN NS ns2.example.com.
IN A 192.168.1.1
IN MX 10 mail.example.com.
4. Restart the DNS server:
For Ubuntu/Debian users:
sudo /etc/init.d/bind9 restart
For Red Hat/CentOS users:
1. Install BIND: The first step to setting up your own DNS server is to install the Berkeley Internet Name Daemon (BIND). This can be done with the command “sudo apt–get install bind9”.
2. Configure named.conf: Open the name configuration file using an editor such as vi. This file can typically be found in /etc/bind.
3. Create Zone Files: The next step is to create a zone file for each domain you want your server to host. These zone files will contain information about the domain such as IP address mappings and other records.
4. Set Up Reverse DNS Lookup: This is necessary to provide reverse DNS lookups. To do this, you need to create a file for each IP address range that will require reverse DNS.
5. Create a Listen–on Statement: To ensure that your DNS server is accessible to your network, you will need to add a listen–on statement to designate an IP address and port on which the server will listen.
6. Test Your DNS Server: You should now test the server by running a few basic DNS queries. If all works correctly, you’re finished and your DNS server is now up and running.