In the previous tutorial, we created a primary domain name server (ns1) for a test domain exmample. tst ). In this article, we will use the bind package in CentOS to create a secondary domain name server (NS2 ). When creating a secondary DNS server, the following factor tag is used: CentOS
In the previous tutorial, we created a primary domain name server (ns1) for a test domain exmample. tst ). In this article, we will use the bind package in CentOS to create a secondary domain name server (NS2 ).
When creating a secondary DNS server, consider the following factors.
- In the secondary domain name server, you do not need to manually create forward and reverse regional files. These regional files are regularly synchronized from the primary domain name server.
- When any region file on the primary domain name server is modified, the 'Serial' parameter should also be updated. The secondary DNS server will synchronize only when the serial of the region file above the primary server is modified.
Assume that the IP address of the secondary DNS server is 172.16.1.4. Let's install it.
Set host name
Just like the primary domain name server, the host name of the secondary domain name server should also be a fully qualified domain name (FQDN ).
- # vim /etc/sysconfig/network
- HOSTNAME=ns2.example.tst
Note that the host name set in this file will be used when the server is started. Therefore, if you modify the file after the system starts, the modification will not take effect immediately. The following command can be used to modify and take effect immediately when the system is running.
- # hostname ns2.example.tst
After setting, you can use the following command to view the host name.
- # hostname
- ns2.example.tst
Before proceeding to the following steps, make sure that the host names of all three servers are correctly set.
Install software package
Just like the primary server, you can use chroot or not to configure a secondary domain name server. Necessary software packages can be easily installed using yum.
Do not use chroot:
- # yum install bind
Use chroot:
- # yum install bind-chroot
Prepare a configuration file for the transfer of regional files
After using bind in CentOS to create a domain name server, the default settings allow all regional files to be synchronized by any server. For security, we need to configure the primary domain name server, which only allows synchronization of the secondary domain name server.
1. primary domain name server
Do not use chroot:
- # vim /etc/named.conf
Use chroot:
- # vim /var/named/chroot/etc/named.conf
- Zone "example. tst" IN {
- Type master;
- File "example-fz"; # file example-fz is on the primary domain name server ##
- Allow-update {none ;};
- Allow-transfer {172.16.1.4 ;}## allow transmission by the secondary domain name server ##
- };
-
- Zone "1.16.172.in-addr. arpa" IN {
- Type master;
- File "rz-172-16-1"; # file rz-172-16-1 on the primary domain server ##
- Allow-update {none ;};
- Allow-transfer {172.16.1.4 ;}## allow transmission by the secondary domain name server ##
- };
2. secondary domain name server
The default configuration file provided after software installation can be used to configure the secondary domain name server. However, we use another instance configuration file for configuration, because it is easy to adjust.
Do not use chroot:
- # cp /usr/share/doc/bind-9.8.2/sample/etc/named.rfc1912.zones /etc/named.conf
Use chroot:
- # cp /usr/share/doc/bind-9.8.2/sample/etc/named.rfc1912.zones /var/named/chroot/etc/named.conf
After executing the above command to copy the file, add the following content to the copied file.
- Options {
- Directory "/var/named ";
- Forwarders {8.8.8.8 ;};
-
- };
-
- Zone "example. tst" IN {
- Type slave; # This host serves as the domain name server ##
- File "example-fz"; # This file will be automatically created ##
- // Allow-update {none ;};
- Allow-transfer {172.16.1.3 ;}## define the master domain name server for transmission from when necessary ##
- Masters {172.16.1.3 ;};## define the primary domain name server ##
- };
-
- Zone "1.16.172.in-addr. arpa" IN {
- Type slave; # This host is defined as a secondary domain name server ##
- File "rz-172-16-1"; # This file will be automatically created ##
- // Allow-update {none ;};
- Allow-transfer {172.16.1.3 ;}## define the primary domain name server ##
- Masters {172.16.1.3 ;};
- };
End of Work
To ensure that no permissions are available, we need to make the following adjustments.
Do not use chroot:
- chmod 770 /var/named/
To use chroot, you must follow the following command to modify the permissions after the named service is started.
- # chmod 770 /var/named/chroot/var/named
Now everything is ready. we can restart the named service. Alternatively, make sure that the named service has been added to the start list.
- # service named restart
- # chkconfig named on
If there is no accident, the secondary domain name server should request the transmission of a region to the primary domain name server and generate its own/var/named directory. The log file/var/log/messages contains some useful information about the named service, including information about the regional file transfer process.
Test a secondary domain name server
We can use dig or nslookup for DNS testing. In this tutorial, we will use nslookup for demonstration. Necessary software packages can be installed through yum.
- # yum install bind-utils
- # nslookup
- > server 172.16.1.4
- Default server: 172.16.1.4
- Address: 172.16.1.4#53
-
- > example.tst
- Server: 172.16.1.4
- Address: 172.16.1.4#53
-
- Name: example.tst
- Address: 172.16.1.3
-
- > set type=mx
- > example.tst
- Server: 172.16.1.4
- Address: 172.16.1.4#53
-
- example.tst mail exchanger = 10 mail.example.tst.
-
- > exit
Troubleshooting prompt
-
We do not need to create any regional files on the secondary domain name server. All region files are synchronized with the primary domain name server.
-
The named service on the secondary domain name server regularly synchronizes with the primary server. If you want to perform a timely synchronization, run the "rncd retransfer" command ". As follows:
- # rndc retransfer example.tst
-
The secondary domain name server is updated only when the serial number of the region file on the primary server is changed.
-
Make sure that the user named can write the folder/var/named or/var/named/chroot/var/named (when chroot is used.
-
/Var/log/messages may contain useful information.
-
I have disabled SELinux.
-
Make sure that the firewall is open to the UDP53 port.
I hope this will help you.