CentOS下搭建DNS server首选Bind软件。这里采用Bind v9做为例子(bind9.x提供IPv6 socket的DNS查询,支持IPv6资源记录。
首先下载及安装:
# wget http://ftp.isc.org/isc/bind9/9.3.6/bind-9.3.6.tar.gz
# tar -xzf bind-9.3.6.tar.gz
# cd bind-9.3.6
# ./configure -enable-ipv6 -with-openssl
# make && make install
运行 rpm -qa | grep bind 可查看安装bind的版本。
Bind软件安装后,会产生几个固有文件,分为两类:
一类是配置文件在/etc目录下;
一类是DNS记录文件在/var/named目录下。
加上其他相关文件,共同设置DNS server。
named.conf为默认的主配置文件(须手动建立),设置一般的named参数,指向该服务器使用的域数据库信息的源,这类源可以是本地磁盘文件或远程服务器。
纯粹为了试验,我在lab里建立了一个域名shanghai.myuseasp.net的IPv6 DNS server。
配置文件1 /etc/name.conf
// Red Hat BIND Configuration Tool
//
// Default initial "Caching Only" name server configuration
//
options {
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
/*
* If there is a firewall between you and nameservers you want
* to talk to, you might need to uncomment the query-source
* directive below. Previous versions of BIND always asked
* questions using port 53, but BIND 8.1 uses an unprivileged
* port by default.
*/
// query-source address * port 53;
listen-on-v6 { fc00:0:4491::18; };
listen-on { 10.1.0.18; };
};
// Red Hat BIND Configuration Tool
//
// Default initial "Caching Only" name server configuration
//
//This is for my testing
//This defines the secv6 domain name lookup
//Regular zone file is shanghai.myuseasp.net
zone "shanghai.myuseasp.net" IN {
type master;
file "shanghai.myuseasp.net.zone";
allow-update { any; };
};
/*
zone "." IN { // a caching only nameserver config
type hint;
file "named.ca";
};
zone "0.1.10.IN-ADDR.ARPA." IN { // this defines the loopback reverse name lookup
type master;
file "10.1.0.db";
};
zone "0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.1.9.4.4.0.0.0.0.0.0.c.f.ip6.arpa." IN { //// this defines the loopback reverse name lookup
type master;
file "fc00.0.4491.db";
allow-update { none; };
};
zone "localhost." IN { // this defines the loopback name lookup
type master;
file "localhost.zone";
allow-update { none; };
};
zone "0.0.127.in-addr.arpa." IN { // this defines the loopback reverse name lookup
type master;
file "named.local";
allow-update { none; };
};
zone "0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa." IN { // this defines the loopback reverse name lookup
type master;
file "named.ip6.local";
allow-update { none; };
};
*/
include "/etc/rndc.key";
看似内容很多,精简一下,除去注释,里面的内容只剩下:
options {
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
listen-on-v6 { fc00:0:4491::18; };
listen-on { 10.1.0.18; };
};
zone "shanghai.myuseasp.net" IN {
type master;
file "shanghai.myuseasp.net.zone";
allow-update { any; };
};
include "/etc/rndc.key";
现在要在目录/var/named里,创建一个名为shanghai.myuseasp.net.zone的文件,添加内容:
$ORIGIN .
$TTL 86400 ; 1 day
shanghai.myuseasp.net IN SOA useasp.shanghai.myuseasp.net. root.useasp.shanghai.myuseasp.net. (
10010 ; serial
21600 ; refresh (6 hours)
3600 ; retry (1 hour)
31536000 ; expire (52 weeks 1 day)
86400 ; minimum (1 day)
)
NS 10.1.0.18
$ORIGIN shanghai.myuseasp.net.
useasp A 10.1.0.18
ns 1D IN AAAA fc00:0:4491::18
1D IN A6 0 fc00:0:4491::18
shanghai.myuseasp.net. IN AAAA fc00:0:4491::18
useasp 1D IN AAAA fc00:0:4491::20
运行命令/etc/init.d/named restart重新启动服务。
从另外一台相连的有IPv6的机器
ping6 shanghai.myuseasp.net,会解析到地址fc00:0:4491::18
ping6 useasp.shanghai.myuseasp.net,会解析到地址fc00:0:4491::20。