DNS 服务器的搭建
项目内容:
搭建最基本的正向解析DNS服务器,满足最基本的DNS服务器配置
项目目的:
第一阶段的目的就是让你首先了解DNS server的目录结构和配置文件最基本配置,了解如何声明一个自己的域,以及了解与文件的书写格式。为后面配置更多功能的DNS服务器做好准备工作
步骤:
1、 安装必要软件
[root@localhost~]# yum install bind bind-chroot caching-nameserver –y
….
Installed:
DNS服务器的主程序包
bind-9.3.3-7.e15.i386.rpm
DNS安全包
bind-chroot-9.3.3-7.e15.i386.rpm
caching-only服务器的DNS主配文件
caching-nameserver-9.3.e15.i386.rpm
2、 配置
1)修改主配置文件
[root@localhost~]# cd /var/named/chroot/
[ root@localhost chroot]#ls
dev etc proc var
[root@
localhost chroot]#cd etc/
[root@ localhost etc]#ls
localtime named.caching-nameserver.conf named.rfc1912.zones rndc.key
[root@localhost etc]# cp -a named.caching-nameserver.conf named.conf
[root@ localhost etc]# vim named.conf
为了简化配置,将下面几项改成any
# grep "any" named.conf
listen-on port 53 { any; }; #监听端口
allow-query { any; }; #查询地址
match-clients { any; }; #客户端
match-destinations { any; }; #查询目的地址
2)声明一个域
[root@localhoat etc]# ls
localtime named.caching-nameserver.conf named.conf named.rfc1912.zones rndc.key
[root@localhost etc]# vim named.rfc1912.zones
[root@localhost etc]# tail -5 named.rfc1912.zones
zone "abc.com" IN {
type master;
file "abc.com.db";
allow-update { none; };
};
[root@localhost etc]#
3)建立对应的正解区域文件
[root@localhost etc]# cd ../var/named/
[root@localhost named]# pwd
/var/named/chroot/var/named
[root@localhost named]# ls
abc.com.db data localhost.zone named.ca named.local slaves
localdomain.zone named.broadcast named.ip6.local named.zero
[root@localhost named]#
[root@localhost named]# vim abc.com.db
$TTL 86400
@ IN SOA @ ns.abc.com. root (
42 ; serial (d. adams)
3H ; refresh
15M ; retry
1W ; expiry
1D ) ; minimum
IN NS ns.abc.com.
www IN A 192.168.1.100
ftp IN A 192.168.1.100
mail IN A 192.168.1.100
@ IN MX 10 mail
pop3 IN CNAME mail
smtp IN CNAME mail
[root@localhsot named]#
4)修改区域文件的权限
[root@Dns_master named]# chown :named abc.com.db
5)检查配置文件语法
[root@Dns_master named]# named-checkconf/var/named/chroot/etc/named.conf #检测配置文件是否有法错误
[root@Dns_master named]#
3、重新启动named服务
[root@Dns_master named]# service named restart
停止 named: [确定]
启动 named: [确定]
[root@Dns_master named]#
4、测试
首先添加DNS服务器记录
[root@localhost named]# vim /etc/resolv.conf
nameserver 192.168.1.100
[root@Dns_master named]#
[root@localhost named]# dig www.abc.com
; <<>> DiG 9.3.3rc2 <<>> www.abc.com
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 6148
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 1
;; QUESTION SECTION:
;www.abc.com. IN A
;; ANSWER SECTION:
www.abc.com. 86400 IN A 192.168.1.100
;; AUTHORITY SECTION:
abc.com. 86400 IN NS ns.abc.com.
;; ADDITIONAL SECTION:
ns.abc.com. 86400 IN A 192.168.1.100
;; Query time: 5 msec
;; SERVER: 192.168.101.99#53(192.168.101.99)
;; WHEN: Mon Sep 26 01:13:57 2011
;; MSG SIZE rcvd: 79
[root@Dns_master named]# host www.abc.com
www.abc.com has address 192.168.1.100
[root@localhost named]# ping www.abc.com
PING www.abc.com (192.168.1.100) 56(84) bytes of data.
64 bytes from Dns_master (192.168.1.100): icmp_seq=1 ttl=64 time=0.017 ms
64 bytes from Dns_master (192.168.1.100): icmp_seq=2 ttl=64 time=0.013 ms
说明搭建成功。