The CentOS DNS service builds the 30th session

Source: Internet
Author: User
Tags mx record

The CentOS DNS service builds the 30th session

The first half of the class

The second half of the class

I. DNS-related principles
DNS is an abbreviation for the domain Name System, which is a service mechanism that translates IP addresses into corresponding host names or converts host names to corresponding IP addresses.
which resolves the IP address through the domain name is called forward parsing, through the IP address to resolve the domain name is called reverse resolution. DNS uses TCP and UDP, the port number is 53, but it primarily uses UDP, and backup between servers uses TCP.
There are only 13 "root" Servers in the world, 1 primary root servers in the United States, and 12 other secondary root servers, and the DNS server can be divided into: Primary DNS, DNS, DNS server, DNS forwarding server according to roles.


Two. Using bind to build a DNS server

1. Install bind
Yum install-y bind//will install Bind-utils package by the way
Cp/etc/named.conf/etc/named.conf.bak
>/etc/named.conf
Vim/etc/named.conf
Add the following configuration:
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//Join

@ in SOA localhost. Admin.localhost. (
2013081601
1H
10M
7D
1D
)
@ in NS localhost.
localhost. In A 127.0.0.1

Vim named.local//Join

$TTL 86400
@ in SOA localhost. Admin.localhost. (
2013081601
1H
10M
7D
1D
)
@ in NS localhost.
1 in PTR localhost

Detect configuration problems: named-checkconf
Detection positive resolution: Named-checkzone "localhost"/var/named/localhost.zone
Detection back-parsing: Named-checkzone "0.0.127.in-addr.arpa"/var/named/named.local
Rndc-confgen-r/dev/urandom-a//This step is to generate Rndc.key, without this key, NAMD is not bootable.
Chown Named:named/etc/rndc.key
/etc/init.d/named start
NETSTAT-LNP |grep named//See if the named process is listening on port 53
First Test the forward parsing: Dig @127.0.0.1 localhost.
Then test back analysis: Dig @127.0.0.1-x 127.0.0.1

2. Add a domain name (zone)
vim/etc/named.conf//Increase
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 Zone File: vim/var/named/abc.com.zone//add
$TTL 600
@ in SOA abc.com. Root.abc.com. (
2013081601
1H
10M
7D
1D
)
In NS ns.abc.com.
In MX ten mail.abc.com.
NS in A 192.168.0.11
www in A 192.168.137.73
Mail in A 192.168.137.10
BBS in CNAME www.abc.com.

Edit anti-parsing file: Vim/var/named/192.168.zone//Add
$TTL 600
@ in SOA ns.abc.com. Root.abc.com. (
2013081601
1H
10M
7D
1D
)
@ in NS ns.abc.com.
Ten in PTR ns.abc.com.
One in PTR mail.abc.com.
In PTR www.abc.com.

There is a problem with detecting two configuration files individually:
Named-checkzone "ABC.com" Abc.com.zone
Named-checkzone "137.168.192.in-addr.arpa" 192.168.zone
Restart named service

Test Dig @127.0.0.1 www.abc.com
Dig @127.0.0.1-x 192.168.137.11

vi/etc/resolv.conf//Modify the IP for the DNS of your own machine

3. Configure DNS Forwarding
The DNS we configured is only able to parse our defined zone, which we do not define is unresolved.
DNS forwarding can be configured to resolve other Internet domain names, provided that the domain name in the Internet is indeed in use, that is, the domain name has been resolved by a DNS server.
vim/etc/named.conf//Add in options{}
Forward first;
Forwarders {8.8.8.8;};
These two lines are used to configure the forwarding, the DNS server cannot resolve the domain name will be forwarded to 8.8.8.8 this DNS server to parse.

4. Configure Master-Slave
On the server from Yum install-y bind
Copy the config file from the Lord to the top, where there are/etc/named.conf,/var/named/localhost.zone,/var/named/named.local
After copying it, revise the/etc/named.conf content reference from:
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.11;};
};

Zone "137.168.192.in-addr.arpa" in {
Type slave;
File "Slaves/192.168.zone";
Masters {192.168.0.11;};
};

Generate Rndc.key:rndc-confgen-r from top/dev/urandom-a
Chown Named:named/etc/rndc.key
Starting from the named:/etc/init.d/named start
Successful startup will generate a slaves directory under/var/named/, this directory will have 192.168.zone, abc.com.zone these two files, the content is the same as the Lord's
On the test from: Dig @127.0.0.1 www.abc.com

5. Test Master-Slave synchronization
Change file on Primary DNS/var/named/abc.com.zone//Add a line at the end:
123 in A 1.1.1.1
Also need to modify the third row of that number string, this is used to make the mark, only this number changes, can let from automatically follow the change, the number can only be bigger, cannot reduce, 2013081601 2013081602
Restart main NAMD service:/etc/init.d/named restart
After testing we found a problem, that is, it is very slow from often in the same step, which is very deadly. So we need to do a special operation, in the Lord's/etc/named.conf, the abc.com zone adds two lines:
Notify yes;
also-notify {192.168.0.12;};

The following knowledge points please configure your own learning
Configure a domain name (zone)
Bind configuration Views (view) http://wubinary.blog.51cto.com/8570032/1378363
Use Mydns to build a DNS server http://www.aminglinux.com/bbs/thread-186-1-1.html
Configure the DNS cache with DNSMASQ http://www.aminglinux.com/bbs/thread-5284-1-1.html
Understanding DNS Recursive and iterative queries http://jeffyyko.blog.51cto.com/28563/215293 http://jeffyyko.blog.51cto.com/28563/216962

Installing the Dig tool

Yum Install bind-utils

Resolve IP based on domain name

Dig www.aminglinux.com

Specify the IP of the DNS, or you can obtain the IP of the domain name www.aminglinux.com
Positive parsing

Dig @8.8. 8.8 www.aminglinux.com

Inverse parsing

Dig @8.8. 8.8 183.26. 39.112

Various domain name resolution records

NS record: The DNS server used to resolve your host IP, where the DNS server that resolves the domain name is your DNS server
A record: The records in the ip,hosts file of the Ip,bbs server for the IP www server of the Ip,mail server as specified by the Hosts file is a record
CNAME record: I am a change everyone follow me change, do not have a change a record CNAME forwarding, the original is abc.com I now change to bcd.com only need to modify the CNAME record
MX Record: Mail

NS records are defined, and NS records correspond to a record

Nonstop forwarding

Mydns The advantage is: do not have to authorize PHP or shell to modify the configuration file, unsafe, with MySQL, authorized users to modify the data in the database is more secure, PHP change MySQL

F

The CentOS DNS service builds the 30th session

Related Article

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.