DNS server setup, forwarding, Master/Slave Configuration

Source: Internet
Author: User

1) DNS Service Establishment
Use bind to build the dns Service:
Yum install-y bind
Yum install-y bind-utils
Cp/etc/named. conf/etc/named. conf. bak
>/Etc/named. conf
Vim/etc/named. conf
123456789101112131415 options {
Directory "/var/named ";
};
Zone "." IN {
Type hint;
File "named. ca ";
};
Zone "localhost" IN {
Type master;
File "localhost. zone ";
};
Zone "0.0.127.in-addr. arpa" IN {
Type master;
File "named. local ";
};

Chown named/etc/named. conf
Cd/var/named/
Dig-t NS.> named. ca
Vim localhost. zone

123456789 @ in soa localhost. admin. localhost .(
2013081601
1 H
10 M
7D
1D
)
@ In ns localhost.
Localhost. in a 127.0.0.1

Vim named. loca
12345678910 $ TTL 86400
@ In soa localhost. admin. localhost .(
2013081601
1 H
10 M
7D
1D
)
@ In ns localhost.
1 in ptr localhost.

Here, our main configuration file and domain configuration file are basically set up. However, we should pay attention to it here. If your selinux is on, the next step will not be able to proceed. You can run the getenforce command to check whether it is disabled. So, you may close your selinux first. If you choose to disable it permanently, you can change selinux to disabled in/etc/SELINUX/config. OK, let's continue ....
Check whether the configuration is correct: named-checkconf
Checking resolution: named-checkzone "localhost"/var/named/localhost. zone
Anti-resolution: named-checkzone "0.0.127.in-addr. arpa"/var/named. local
If all are "OK", you can
Rndc-confgen-r/dev/urandom-a // This step generates rndc. key. If this key is not available, it cannot be started.
Chown named: named/etc/rndc. key
/Etc/init. d/named start
Netstat-lnp | grep named // check whether the named process has listened to port 53.
First test forward parsing: dig @ 127.0.0.1 localhost.
Then test anti-resolution: dig @ 127.0.0.1-x 127.0.0.1
All are normal, so I will add a domain name to try...
Added after vim/etc/named. conf

12345678 zone "abc.com" IN {
Type master;
File "abc.com. zone ";
};
Zone "137.168.192.in-addr. arpa" IN {
Type master;
File "192.168.zone ";
};

Edit the zone file vim/var/named/abc.com. zone.

1234567891011121314 $ TTL 600
@ In soa abc.com. root.abc.com .(
2013081611
1 H
10 M
7D
1D
)
In ns ns.abc.com.
In mx 10 mail.abc.com.
Ns in a 192.168.0.120
Www in a 192.168.137.73
Mail in a 192.168.137.10
Bbs in cname www.abc.com.

Here, I have to remind you that my host IP address is 192.168.0.120.
Edit the anti-resolution file: vim/var/named/192.168.zone

12345678910111213 $ TTL 600
@ In soa ns.abc.com. root.abc.com .(
2013081601
1 H
10 M
7D
1D
)
@ In ns ns.abc.com.
10 in ptr ns.abc.com.
20 in ptr mail.abc.com.
73 in ptr www.abc.com.
~

Check whether two configuration files have problems:
Named-checkzone "abc.com" abc.com. zone
Named-checkzone "137.168.192.in-addr. arpa" 192.168.zone
Restart the named service and test:
Dig @ 127.0.0.1 www.abc.com
Dig @ 127.0.0.1-x 192.168.137.11
Well, our DNS service is ready. However, we are not finished yet. continue walking ....
2) Configure DNS forwarding:
The DNS we configured can only parse the zone we defined. What we didn't define cannot be parsed.
If you configure DNS forwarding, you can resolve other domain names on the internet, provided that the domain name is used on the Internet, that is, the domain name has been resolved by a DNS server.
Vim/etc/named. conf // added in options {}
Forward first;
Forwarders {8.8.8.8 ;};
These two lines are used to configure forwarding. domain names that cannot be resolved by the DNS server will be forwarded to the DNS server 8.8.8.8 for resolution.
After forwarding is done, we continue to take the lead ....
3) configure the master and slave nodes:
On the slave server, yum install-y bind
Copy the configuration file on the master to the top, including/etc/named. conf,/var/named/localhost. zone,/var/named. local
After copying the file, modify the/etc/named. conf file. For details, refer:

12345678910111213141516171819202122232425 options {
Directory "/var/named ";
};
Zone "." IN {
Type hint;
File "named. ca ";
};
Zone "localhost" IN {
Type master;
File "localhost. zone ";
};
Zone "0.0.127.in-addr. arpa" IN {
Type master;
File "named. local ";
};
Zone "abc.com" IN {
Type slave;
File "slaves/abc.com. zone ";
Masters {192.168.0.120 ;};
};
Zone "137.168.192.in-addr. arpa" IN {
Type slave;
File "slaves/192.168.zone ";
Masters {192.168.0.120 ;};
};

Here we have to pay attention to another problem, that is, iptables. If port 53 is disabled, the master and slave cannot be synchronized, you can try to log on to the master using telnet 192.168.0.120 53. If you cannot log on, you need/etc/init. d/iptables stop or chkconfig iptables off is temporarily or permanently disabled. Of course, you can modify the iptables rule to open the 53 port. You can decide it by yourself ....
Generate rndc. key: rndc-confgen-r/dev/urandom-a from above
Chown named: named/etc/rndc. key
Start named from top:/etc/init. d/named start
After the Server Load balancer instance is successfully started, a server Load balancer directory will be generated under/var/named/. There will be two files, 192.168.zone and abc.com. zone, with the same content as those on the master.
Test from above: dig @ 127.0.0.1 www.abc.com
Test master-slave synchronization:
On the primary dns, change the file/var/named/abc.com. zone // and add a line at the end:
123 in a 1.1.1.1
In addition, you need to modify the numeric string in the third row. This is used for marking. Only when this number changes can the number be automatically changed. The number can only be larger but cannot be reduced, 2013081601-> 2013081602
Restart the master namd service:/etc/init. d/named restart
After testing, we found a problem, that is, synchronization is often slow, which is terrible. Therefore, we need to perform a special operation to add two lines to the zone of abc.com in/etc/named. conf on the master:
Optional Y yes;
Also-policy {192.168.0.121 ;};
This 121 is from the top ip address. Okay, that's it. I wish you success !!!

RHEL6 server build DNS Server

Linux RHEL 6.x DNS Server

Ubuntu DNS Server Configuration

Configure DNS server in Solaris

Use MySQL and DNS view for intelligent DNS in CentOS 6.3 x64

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.