linux下如何搭建简单的DNS Server
环境:lenovo PC, SUSE Linux 11.1 32bit,BIND 9.5.0-P2
安装步骤:
- 采用yast自动安装。安装内容包括:bind,bind-chrootenv ,bind-devel,bind-libs,bind-utils
配置步骤:
- whereis named,找到bind的配置文件所在目录。如下在/etc/named.conf
pandora-test:~ # whereis named
named:/usr/sbin/named/etc/named.conf/etc/named.d/usr/share/man/man8/named.8.gz
修改named.conf
2.1.去掉注释并修改监听端口:listen-onport53{172.16.39.86;};
2.2.添加域名解析和反向解析配置:
zone "p.com" in {
typemaster;
file"p.com.zone";
};zone "39.16.172.in-addr.arpa" in{
typemaster;
file"172.16.39.zone";
};2.3 添加2.2中所指定的域名解析和反向解析的具体配置文件。如:p.com.zone,172.16.39.zone
在文件夹/var/lib/named下进行添加
p.com.zone文件内容如下:
$TTL 1000
@INSOA@root(
42;serial(d.adams)
200S;refresh
4H;retry
1D;expiry
100S);minimum
@INNS172.16.39.86;
@INA172.16.39.86;
wwwA172.16.39.86;
pbossA172.16.39.86;
confluenceA172.16.39.86;
redisA172.16.39.86;
mysqlA172.16.39.86;
svnA172.16.8.159;
hudsonA172.16.8.159;
mvnrepoA172.16.8.159;
jira A 172.16.8.159;172.16.39.zone文件内容如下:
$TTL 1000
@INSOAlocalhost.root.localhost.(
42;serial(d.adams)
200;refresh
400;retry
6000;expiry
1000 ) ; minimumIN NS localhost.86 IN PTR www.p.com.
验证步骤:
1. 启动dns server 服务:service named start
2. 修改本地dns的配置,将首选dns的地址配置为运行dns server的服务器地址
3. 运行命令:nslookup www.p.com
返回结果如下:
服务器: www.p.com Address: 172.16.39.86
名称: www.p.com Address: 172.16.39.86
如果返回内容为:** server can't find ww.p.com: NXDOMAIN
则表示dns server配置有误,需检查相关配置