linux搭建dns多域,搭建LINUX下的DNS多域解析主辅服务器

搭建LINUX下的DNS多域解析主辅服务器

内核版本: 2.6.18-128.el5

DNS主服务器IP:192.168.10.231

DNS辅服务器IP:192.168.10.34

1.2台服务器同时都安装bind相关软件包

yum -y install bind* caching-nameserver

2.修改主配置文件

cd /var/named/chroot/etc

cp -p named.caching-nameserver.conf named.conf

cp -p named.rfc1912.zones named.rfc1912.zones.bak (备份此文件,防止修改出错)

vim named.conf

修改此文件中127.0.0.1为any

修改localhost为any

保存退出

vim named.rfc1912.zones

如下例子

// named.rfc1912.zones:

//

// Provided by Red Hat caching-nameserver package

//

// ISC BIND named zone configuration for zones recommended by

// RFC 1912 section 4.1 : localhost TLDs and address zones

//

// See /usr/share/doc/bind*/sample/ for example named configuration files.

//

zone “.” IN {

type hint;

file “named.ca”;

};

zone “baidu.com” IN {

type master;

file “baidu.com.zone”;

allow-update { none; };

allow-transfer { 192.168.10.34; }; (这行是添加辅助服务器的IP,有多台辅助可以添加多个IP)

};

zone “baidu.net” IN {

type master;

file “baidu.net.zone”;

allow-update { none; };

allow-transfer { 192.168.10.34; };

};

zone “10.168.192.in-addr.arpa” IN {

type master;

file “10.168.192.in-addr.local”;

allow-update { none; };

allow-transfer { 192.168.10.34; };

};

保存退出

cd ../var/named

cp -p localdomain.zone baidu.com.zone

cp -p localdomain.zone baidu.net.zone

cp -p named.local 10.168.192.in-addr.local

vim baidu.com.zone

$TTL 6 (这里我让缓存为6秒钟,这里就是做快速解析生效的重要地方)

@ IN SOA localhost root (

2009110404 ; Serial (YYMMDDSN)

6 ; Refresh

60 ; Retry

4W ; Expiry

6 ) ; Minimum

IN NS baidu.com

IN MX 10 mail.baidu.com.

IN A 192.168.10.125

mail IN A 192.168.10.125

qq IN A 192.168.10.40

保存

用同样的方法编辑baidu.net.zone文件

再编辑反向解析文件

vim 10.168.192.in-addr.local

$TTL 6

@ IN SOA localhost. root.localhost. (

2009110302 ; Serial

28800 ; Refresh

14400 ; Retry

3600000 ; Expire

86400 ) ; Minimum

IN NS baidu.com.

IN NS baidu.net.

125 IN PTR www.baidu.com

125 IN PTR mail.baidu.com

231 IN PTR www.baidu.net.

40 IN PTR mail.baidu.net.

保存完毕

启动bind

service named start

主DNS服务器配置完毕

编辑配置文件

vim named.rfc1912.zones

// named.rfc1912.zones:

//

// Provided by Red Hat caching-nameserver package

//

// ISC BIND named zone configuration for zones recommended by

// RFC 1912 section 4.1 : localhost TLDs and address zones

//

// See /usr/share/doc/bind*/sample/ for example named configuration files.

//

zone “.” IN {

type hint;

file “named.ca”;

};

zone “baidu.com” IN {

type slave;

file “slaves/baidu.com.zone”;

masters { 192.168.10.231; };

};

zone “baidu.net” IN {

type slave;

file “slaves/baidu.net.zone”;

masters { 192.168.10.231; };

};

zone “10.168.192.in-addr.arpa” IN {

type slave;

file “slaves/10.168.192.in-addr.local”;

masters { 192.168.10.231; };

};

启动bind

如果发现启动不成功,请检查bind的权限

cd /var/named/chroot/var/named/slaves

chmod 775 /var/named/chroot/var/named/slaves

chown named.named /var/named/chroot/var/named/slaves

查看slaves文件夹下是否有baidu.com.zone文件了,他会自动下载下来

你可能感兴趣的:(linux搭建dns多域)