Linux dns Server Configuration

Source: Internet
Author: User
Tags nameserver

Common commands and troubleshooting tools:

View Processes

Ps aux | grep named

Start

Service named start (centos)

/Usr/local/bind/sbin/named-4 (redhat)

Kill

Killall named

View port

Netstat-ano | grep 53

Detection

Nslookup

Dig

Dig-x

Change dns

Vi/etc/resolv. conf

Change Nic

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


Centos System (then you will be happy, you can use yum to install, redhat directly pull down ):

I. Installation
# Rpm-qa | grep bind
# Rpm-qa | grep caching

# Yum install caching-nameserver

OK, centos is installed.

Check:

# Service named start

[Root @ localhost named] # ps aux | grep named
Named 14011 4.0 0.2 38852 3380? Ssl/usr/sbin/named-u named-c/etc/named. caching-nameserver.conf-t/var/named/chroot
Root 14021 0.0 0.0 4784 704 pts/1 R + grep named

Note: red and blue

Our named service configuration file is:/etc/named. caching-nameserver.conf

The zone file should be stored in:/var/named/chroot/var/named/

Ii. Configuration

Please explain it first, or you may be dizzy when you look at these configuration files:

192.168.10.62 will be our dns Server
192.168.10.188 will be our slave server

Abc. zone. db forward statement File

Reverse file Decoding for named.192.168.10

Service configuration file:

[Root @ localhost named] # vi/etc/named. caching-nameserver.conf

//
// Named. conf
//
// Provided by Red Hat bind package to configure the isc bind named (8) DNS
// Server as a caching only nameserver (as a localhost DNS resolver only ).
//
// See/usr/share/doc/bind */sample/for example named configuration files.
//

Options {
Listen-on port 53 {192.168.10.0/24 ;};
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 {192.168.10.0/24 ;};
Allow-query-cache {192.168.10.0/24 ;};
Recursion yes;

};

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

Zone "." IN {

Type hint;
File "/var/named. ca ";
};

Zone "mx1985.com." IN {

Type master;

File "/var/named/mx1985.zone. db ";
Allow-transfer {192.168.10.188 ;};
};

Zone "abc.com." IN {

Type master;

File "/var/named/abc. zone. db ";
Allow-transfer {192.168.10.188 ;};
};

Zone "10.168.192.in-addr. arpa" IN {
Type master;
File "/var/named/named.192.168.10 ";
Allow-transfer {192.168.10.188 ;};
};

Positive Solution file:

[Root @ localhost named] # vi/var/named/chroot/var/named/abc. zone. db

$ TTL 1D
@ In soa @ rname. invalid .(
0; serial
1D; refresh
1 H; retry
1 W; expire
3 H); minimum
In ns abc.com.
In ns slave.abc.com.
Abc.com. in a 192.168.10.62
Slave.abc.com. in a 192.168.10.188

Www in a 192.168.10.188
Aaa in a 192.168.10.188
Bbb in a 192.168.10.62

Reverse file:

[Root @ localhost named] # vi/var/named/chroot/var/named/named.192.168.10

$ TTL 1D
@ In soa @ rname. invalid .(
0; serial
1D; refresh
1 H; retry
1 W; expire
3 H); minimum
In ns abc.com.
In ns slave.abc.com.
62 in ptr abc.com.
188 in ptr slave.abc.com.

188 in ptr www.abc.com.
188 in PTR aaa.abc.com.
62 in PTR bbb.abc.com.
~
~

The redhat system is used as the slave service configuration (Please pull down the redhat configuration as the master server ):

We use 192.168.10.188 as the Server Load balancer instance. Now we can configure it.

Because I use RedHat, the installation instructions are as follows:

Let me share it.Installation Package

Http://pan.baidu.com/share/link? Consumer id = 90714652 & UK = 3222060313

# Tar-zxvf bind-9.9.2.tar.gz

# Cd bind-9.9.2

#./Configure -- prefix =/usr/local/bind -- enable-threads -- With-dlz-MySQL

# Make

# Make install

Generate basic configuration file

#/Usr/local/bind/sbin/rndc-confgen>/usr/local/bind/etc/rndc. conf

# Tail-10 rndc. conf | head-9 | sed S/# \ // G> named. conf

Start

#/Usr/local/bind/sbin/named-4

Okay. Go to the slavedns configuration. Pay special attention to the path of this system.

Create a Server Load balancer directoryUsed to store zone files,

# Mkdir/usr/local/bind/etc/slaves

# Chmod 777-R slaves/

# Chown-R named. named slaves/

# Ll-d slaves
Drwxrwxrwx 2 named 4096 Jul 25 slaves (that's right)

[Root @ localhost etc] # vi named. conf

Key "rndc-key "{
Algorithm hmac-md5;
Secret "XfiakRq8MCb3uC6XwKDLQQ = ";
};

Controls {
Inet 127.0.0.1 port 953
Allow {127.0.0.1;} keys {"rndc-key ";};
};
Zone "." IN {

Type hint;
File "/usr/local/bind/etc/named. ca ";

};

Zone "abc.com." IN {

Type slave;

File "Slaves/ABC. Zone. DB ";

Masters {192.168.10.62 ;};

};

Zone "10.168.192.in-ADDR. Arpa" in {
Type slave;
File "Slaves/named.192.168.10 ";

Masters {192.168.10.62 ;};
};

Restart, and the zone file shared by the master will come.
#/Usr/local/bind/sbin/named-4

[Root @ localhost etc] # ll slaves/
Total 8
-RW-r -- 1 Root 349 Jul 25 14:18 ABC. Zone. DB
-RW-r -- 1 Root 446 Jul 25 14:38 named.192.168.10

Now we configure a master DNS server under RedHat, excluding the slave service.

Named. conf

[Root @ rhes6 ~] # Vi/usr/local/bind/etc/named. conf

//
// Named. conf
//
// Provided by Red Hat Bind package to configure the isc bind named (8) DNS
// Server as a caching only nameserver (as a localhost DNS resolver only ).
//
// See/usr/share/doc/Bind */sample/For example named configuration files.
//

Options {
Listen-on port 53 {192.168.10.0/24 ;};
Listen-on-v6 port 53 {: 1 ;};
Directory "/usr/local/bind/etc /";
PID-file "/usr/local/bind/var/run/named. PID ";
Allow-query {192.168.10.0/24 ;};
Allow-query-Cache {192.168.10.0/24 ;};
Recursion yes;
Allow-transfer {none ;};
};

Include "/usr/local/bind/etc/rndc. Key ";
Zone "." In {

Type hint;
File "/usr/local/bind/etc/named. ca ";

};

Zone "mx1985.com." In {

Type master;

File "mx1985.zone. DB ";

};

Zone "abc.com." In {

Type master;

File "abc. zone. db ";

};

Zone "10.168.192.in-addr. arpa" IN {
Type master;
File "named.192.168.10 ";
};


Forward statement File

[Root @ rhes6 ~] # Vi/usr/local/bind/etc/abc. zone. db

$ TTL 1D
@ In soa @ rname. invalid .(
0; serial
1D; refresh
1 H; retry
1 W; expire
3 H); minimum
In ns abc.com.
A 192.168.10.185

Www in a 192.168.10.188
Aaa in a 192.168.10.188
Bbb in a 192.168.10.188

Reverse file:

~
[Root @ rhes6 ~] # Vi/usr/local/bind/etc/named.192.168.10

$ TTL 1D
@ In soa @ rname. invalid .(
0; serial
1D; refresh
1 H; retry
1 W; expire
3 H); Minimum
In NS abc.com.
PTR 192.168.10.185

188 in PTR www.abc.com.
188 in PTR aaa.abc.com.

188 in PTR bbb.abc.com.

Change the DNS of all machines to the two servers.

# Vi/etc/resolv. conf

Mastername 192.168.10.62

Mastername 192.168.10.188

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.