Build a Linux DNS Server

Source: Internet
Author: User

Environment: CentOS 6.3

Requirement: The example.com domain is created for internal and external queries. The Intranet environment 192.168.88.0/24, 10.1.0.0/16

1. Install

Yum install bind // chroot Is Not Installed

2. Main configuration file

/Etc/named. conf // master configuration file

Vi/etc/named. conf

Options {
Listen-on port 53 {any ;};
Directory "/var/named"; // path of the region file in this configuration file
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;

/* Path to isc dlv key */
Bindkeys-file "/etc/named. iscdlv. key ";

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

Logging {
Channel default_debug {
File "data/named. run ";
Severity dynamic;
};
};


View "internal" {// create an internal query view

Match-clients {192.168.0.0/16; 10.1.0.0/16;}; // specify the host that can be queried
Recursion yes;

Zone "." IN {
Type hint;
File "named. ca ";
};

Zone "example.com" IN {
Type master;
File "example.com. zone. internal ";
};

Zone "88.168.192.in-addr. arpa" IN {// note the naming method of the reverse region. I wrote 0.88168.192.in-addr. arpa incorrectly.
Type master;
File "88.168.192.zone ";
};

Include "/etc/named. rfc1912.zones"; // if there is an include, it should be included in each view
Include "/etc/named. root. key ";
};

View "external "{

Match-clients {any ;};
Recursion yes;

Zone "." IN {
Type hint;
File "named. ca ";
};

Zone "example.com" IN {
Type master;
File "example.com. zone. external ";
};

Zone "1.100.202.in-addr. arpa" IN {
Type master;
File "1.100.202.zone ";
};

Include "/etc/named. rfc1912.zones ";
Include "/etc/named. root. key ";
};


3. Create a region configuration file

Cp-p/var/named. empty/var/named/example.com. zone. internal

Cp-p/var/named. empty/var/named/example.com. zone. external

Cp-p/var/named. empty/var/named/88.168.192.zone

Cp-p/var/named. empty/var/named/1.100.202.zone // note that-p is used to keep the file attributes.

 

Example.com. zone. internal // The forward region file of the internal view
$ TTL 3 H
@ In soa ns1.example.com. root.example.com .(
2013051501; serial // The serial number. Add this value after you modify the configuration.
1D; refresh
1 H; retry
1 W; expire
3 H); minimum
In ns ns1.example.com.

In mx 5 mail.example.com.
Ns1 in a 192.168.88.110

Mail in a 192.168.88.111

Www in a 192.168.88.112

Bbs in cname www


Example.com. zone. external // external view forward region File
$ TTL 3 H
@ In soa ns1.example.com. root.example.com .(
2013051501; serial
1D; refresh
1 H; retry
1 W; expire
3 H); minimum
In ns ns1.example.com.
Ns1 in a 202.100.1.110

88.168.192.zone // reverse region file of internal view
$ TTL 3 H
@ In soa ns1.example.com. root.example.com .(
2013051501; serial
1D; refresh
1 H; retry
1 W; expire
3 H); minimum
In ns ns1.example.com.
110 in ptr ns1.example.com.

1.100.202.zone // reverse region file of the external view
$ TTL 3 H
@ In soa ns1.example.com. root.example.com .(
2013051501; serial
1D; refresh
1 H; retry
1 W; expire
3 H); minimum
In ns ns1.example.com.
110 in ptr ns1.example.com.

 

4. Configuration check

Named-checkconf/etc/named. conf

Named-checkzone example.com/var/named/example.com. zone. internal

Named-checkzone example.com/var/named/example.com. zone. external

Named-checkzone 88.168.192.in-addr. arpa 88.168.192.zone

Named-checkzone 1.100.202.in-addr. arpa 1.100.202.zone

 

5. Start the service

Service named start

6. Open the Firewall

Vi/etc/sysconfig/iptables

-A input-m state -- state NEW-m tcp-p tcp -- dport 53-j ACCEPT
-A input-m state -- state NEW-m udp-p udp -- dport 53-j ACCEPT // note that UDP must be enabled

7. Register System Services

Chkconfig-level 35 named on

8. Modify the local DNS configuration // do not directly modify/etc/resolver

Vi/etc/sysconfig/network-script/ifcfg-eth0

DNS1 = 127.0.0.1

9. Restart the network service.

Service network restart

 

Test

C: \> nslookup
Default Server: ns1.example.com
Address: 192.168.88.110

> Example.com
Server: ns1.example.com
Address: 192.168.88.110

Name: example.com

> 192.168.88.110
Server: ns1.example.com
Address: 192.168.88.110

Name: ns1.example.com
Address: 192.168.88.110

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.