DNS server setup and configuration under CentOS6.5

Source: Internet
Author: User

DNS server setup and configuration under CentOS6.5

I. cache Domain Name Server

1. installation and configuration

[Root @ localhost ~] # Yum-y install bind-chroot bind-util bind-libs software package required by the DNS server

[Root @ localhost ~] # Vim/etc/named. conf main configuration file of the DNS server

Options {

Listen-on port 53 {192.168.1.24;}; use port 53 to listen to the ip address 192.168.1.24

Listen-on-v6 port 53 {: 1 ;}; listen to ipv6 IP address options

Directory "/var/named"; DNS root directory. Because bind-chroot is installed, the actual working directory of the service is/var/named/chroot/var/named.

Dump-file "/var/named/data/cache_dump.db"; Cache dump files

Statistics-file "/var/named/data/named_stats.txt"; records memory usage statistics

Memstatistics-file "/var/named/data/named_mem_stats.txt ";

Allow-query {any;}; The host that can be queried. The default value is localhost.

Recursion yes; recursive query

Dnssec-enable yes;

Dnssec-validation yes;

Dnssec-lookaside auto;

Bindkeys-file "/etc/named. iscdlv. key ";

Managed-keys-directory "/var/named/dynamic ";

};

Logging {named Service Log File Information

Channel default_debug {

File "data/named. run ";

Severity dynamic;

};

};

The configuration and information of the zone "." IN {root (.) domain (you can also use other upper-level domain name forwarding functions

Configure the cache Domain Name Server. You can learn it yourself)

Type hint;

File "named. ca ";

};

[Root @ localhost ~] # Ls-lh/etc/named. conf master Configuration File Permission (in red)

-Rw-r ----- 1 root named934 Aug 17 23:06/etc/named. conf

[Root @ localhost ~] # Service named restartDNS's service name is named

Stop named:. [OK]

Start named: [OK]

[Root @ localhost ~] # Netstat-ltunp | grep named

Tcp 0 0 192.168.1.24: 53 0.0.0.0: * LISTEN 8049/named

Tcp 0 0 127.0.0.1: 953 0.0.0.0: * LISTEN 8049/named

Tcp 0 0: 1: 53: * LISTEN 8049/named

Tcp 0 0: 1: 953: * LISTEN 8049/named

Udp 0 0 192.168.1.24: 53 0.0.0.0: * 8049/named

2. Client Test

[Root @ localhost ~] # Echo nameserver 192.168.1.24>/etc/resolv. conf

[Root @ localhost ~] # Digwww.baidu.com

; <> DiG 9.7.0-P2-RedHat-9.7.0-5.P2.el6 <> www.baidu.com

; Global options: + cmd

; Got answer:

;-> HEADER <-opcode: QUERY, status: NOERROR, id: 57864

; Flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 5, ADDITIONAL: 5

; Question section:

; Www.baidu.com. IN

; Answer section:

Www.baidu.com. 1200 in cname www.a.shifen.com.

Www.a.shifen.com. 300 in a 180.97.33.107

Www.a.shifen.com. 300 in a 180.97.33.108

; Authority section:

A.shifen.com. 1200 in ns ns5.a.shifen.com.

A.shifen.com. 1200 in ns ns3.a.shifen.com.

3. Notes

The client must communicate with the server (can be pinged) and disable selinux.

Ii. Primary Domain Name Server Configuration

1. configuration (a host can be shared with the Cache Server)

[Root @ localhost ~] # Vim/etc/named. conf

Options {

Listen-on port 53 {192.168.1.24;}; use port 53 to listen to the ip address 192.168.1.24

Listen-on-v6 port 53 {: 1 ;}; listen to ipv6 IP address options

Directory "/var/named"; DNS root directory, due to the installation of bind-chroot,

Therefore, the actual directory of the service is/var/named/chroot/var/named.

Dump-file "/var/named/data/cache_dump.db"; Cache dump files

Statistics-file "/var/named/data/named_stats.txt"; records memory usage statistics

Memstatistics-file "/var/named/data/named_mem_stats.txt ";

Allow-query {any;}; The host that can be queried. The default value is localhost.

Recursion yes; recursive query

Dnssec-enable yes;

Dnssec-validation yes;

Dnssec-lookaside auto;

Bindkeys-file "/etc/named. iscdlv. key ";

Managed-keys-directory "/var/named/dynamic ";

};

Logging {named Service Log File Information

Channel default_debug {

File "data/named. run ";

Severity dynamic;

};

};

Configuration and information of zone "." IN {root (.) domain

Type hint;

File "named. ca ";

};

Zone "wxw.com" IN {specified zone name

Type master; server type, master Domain Name

File "wxw.com _ zone"; forward resolution region file name wxw.com _ zone, created under the/var/named directory

Allow-transfer {192.168.1.124;}; specifies the IP address of the slave (Auxiliary) Domain Name Server

};

Zone "1.168.192.in-addr. arpa" IN {the IP address CIDR Block of the domain name is 192.168.1.0, which must be written IN the same format.

Type master;

File "192.168.1.zone"; reverse resolution file name 192.168.1.zone

Allow-transfer {192.168.1.124 ;};

};

[Root @ localhost ~] # Vim/var/named/wxw.com _ zone edit forward resolution File

$ TTL 1D

@ In soa ns1.wxw.com. mail.www.wxw.com .(

2014102101; serial

1D; refresh

1 H; retry

1 W; expire

3 H); minimum

@ In ns ns1.wxw.com. Domain Name address of the primary domain name

Ns1.wxw.com. in a 192.168.1.24 IP address of the primary domain name

@ In ns ns2.wxw.com. The domain name address of the slave Domain Name

Ns2.wxw.com. in a 192.168.1.124 from the IP address of the domain name

@ In mx 10 mail.ww.wxw.com. email server domain name address

Mail.www.wxw.com. in a 192.168.1.4

Www.wxw.com. in a 192.168.1.2

Ftp.wxw.com in a 192.168.1.3

Win7.wxw.com. in a 192.168.1.20.

Linux.wxw.com. in cname ns1.wxw.com.

Smb.wxw.com. in cname ns1.wxw.com.

Dhcp.wxw.com. in cname ns1.wxw.com.

[Root @ localhost ~] # Vim/var/named/192.168.1.zone reverse parsing File

$ TTL 1D

@ In soa ns1.wxw.com. mail.www.wxw.com .(

2014102101; serial

1D; refresh

1 H; retry

1 W; expire

3 H); minimum

@ In ns ns1.wxw.com.

@ In ns ns2.wxw.com.

24 in ptr ns1.wxw.com.

124 in ptr ns2.wxw.com.

@ In mx 10 mail.www.wxw.com.

4 in ptr mail.www.wxw.com.

2 in ptr www.wxw.com.

3 in ptr ftp.wxw.com.

124 in ptr win7.wxw.com.

[Root @ localhost ~] # Service named restart

Stop named:. [OK]

Start named: [OK]

[Root @ localhost ~] # Cat/etc/resolv. conf

; Generated by/sbin/dhclient-script

Search wxw.com

Nameserver 192.168.1.24

2. Client Test

[Root @ localhost ~] # Dig www.wxw.com

; <> DiG 9.8.2rc1-RedHat-9.8.2-0.23.rc1.el6_5.1 <> www.wxw.com

; Global options: + cmd

; Got answer:

;-> HEADER <-opcode: QUERY, status: NOERROR, id: 13587

; Flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 2

; Question section:

Www.wxw.com. IN

; Answer section:

Www.wxw.com. 86400 in a 192.168.1.2

; Authority section:

Wxw.com. 86400 in ns ns2.wxw.com.

Wxw.com. 86400 in ns ns1.wxw.com.

; Additional section:

Ns1.wxw.com. 86400 in a 192.168.1.24

Ns2.wxw.com. 86400 in a 192.168.1.124

; Query time: 1 msec

; SERVER: 192.168.1.24 #53 (192.168.1.24)

; WHEN: Wed Oct 22 11:47:47 2014

; Msg size rcvd: 113

Iii. Build and configure a Domain Name Server

1. restart a linux virtual host (CentOS 6.5) with the NIC ip address 192.168.1.124.

2. service installation and configuration

[Root @ localhost ~] # Yum-y install bind-chroot bind-util bind-libs

[Root @ localhost ~] # Vim/etc/named. conf

Options {

Listen-on port 53 {192.168.1.124 ;};

Listen-on-v6 port 53 {: 1 ;};

Directory "/var/named"; dump-file "/var/named/data/cache_dump.db ";

Statistics-file "/var/named/data/named_stats.txt ";

Memstatistics-file "/var/named/data/named_mem_stats.txt ";

Allow-query {any ;};

Recursion yes;

Dnssec-enable yes;

Dnssec-validation yes;

Dnssec-lookaside auto;

Bindkeys-file "/etc/named. iscdlv. key ";

# Managed-keys-directory "/var/named/dynamic ";

};

Logging {named Service Log File Information

Channel default_debug {

File "data/named. run ";

Severity dynamic;

};

};

Configuration and information of zone "." IN {root (.) domain

Type hint;

File "named. ca ";

};

Zone "wxw.com" IN {specified zone name

Type slave; server type; slave is the slave Domain Name Server Option

File "wxw.com _ zone"; forward resolution region file name wxw.com _ zone, created under the/var/named directory

Masters {192.168.1.24;}; specifies the IP address of the Primary Domain Name Server

};

Zone "1.168.192.in-addr. arpa" IN {the IP address CIDR Block of the domain name is 192.168.1.0, which must be written IN the same format.

Type slave;

File "192.168.1.zone"; reverse resolution file name 192.168.1.zone

Masters {192.168.1.24 ;};

};

[Root @ localhost ~] # Chmod 770/var/named/

[Root @ localhost ~] # Ll/var/named/-d

Drwxrwx --- 6 root named 4096 Oct 22/var/named/

[Root @ localhost ~] # Service named restart

Stop named: [OK]

Start named: [OK]

3. Client Test

[Root @ localhost ~] # Dig @ 192.168.1.124 www.wxw.com

; <> DiG 9.7.0-P2-RedHat-9.7.0-5.P2.el6 <> @ 192.168.1.124 www.wxw.com

; (1 server found)

; Global options: + cmd

; Got answer:

;-> HEADER <-opcode: QUERY, status: NOERROR, id: 22358

; Flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 2

; Question section:

Www.wxw.com. IN

; Answer section:

Www.wxw.com. 86400 in a 192.168.1.2

; Authority section:

Wxw.com. 86400 in ns ns1.wxw.com.

Wxw.com. 86400 in ns ns2.wxw.com.

; Additional section:

Ns1.wxw.com. 86400 in a 192.168.1.24

Ns2.wxw.com. 86400 in a 192.168.1.124

; Query time: 1 msec

; SERVER: 192.168.1.124 #53 (192.168.1.124)

; WHEN: Wed Oct 22 10:49:58 2014

4. Notes:

(1) If the resolution is still not possible, please return to the/var/named directory of the Primary Domain Name Server to add permissions to the region configuration file (simply for the purpose of practice, add the maximum permission of 777)

(2) The above exercises are performed when the firewall is disabled and seLinux is disabled. If the firewall is enabled, you can add rules on your own.

4. There are also DNS servers configured based on the interface. We will not introduce them here. You can go to the manual training page on your own.

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.