---------------------------------------
一、前言
二、环境
三、配置
四、案例
五、解析测试
---------------------------------------
一、前言
DNS 是域名系统 (Domain Name Server或Domain Name System) 的缩写,是因特网的一项核心服务,它作为可以将域名和IP地址相互映射的一个分布式数据库,能够使人更方便的访问互联网,而不用去记住能够被机器直接读取的IP数串。域名服务器是指保存有该网络中所有主机的域名和对应IP地址,并具有将域名转换为IP地址功能的服务器。DNS使用TCP与UDP端口号都是53,主要使用UDP,服务器之间备份使用TCP。
二、环境
系统:CentOS6.4 32位 IP:192.168.2.10/24
软件:
bind DNS安装文件
bind-chroot 为了提高DNS安全,配置文件限定在一个固定目录中
bind-utils 测试命令工具
三、配置
# setenforce 0 # service iptables stop # yum install bind bind-chroot bind-utils # service named start //正在产生钥匙,可能要稍等片刻 Generating /etc/rndc.key: [ OK ] Starting named: [ OK ] # cd /var/named/chroot/etc/ //一定要先启动DNS服务才能生成配置文件 # ls named.conf //主配置文件 named.rfc1912.zones //区域声明文件 # cd /var/named/chroot/var/named/ # ls named.localhost //区域样例文件 # vim /var/named/chroot/etc/named.conf //编辑主配置文件
四、案例
# vim /var/named/chroot/etc/named.rfc1912.zones //添加abc.com的区域声明文件
# cd /var/named/chroot/var/named/ # cp -p named.localhost abc.com.zone //拷贝样例文件 # vim abc.com.zone
# vim /etc/resolv.conf //DNS指向本机,便于本机测试 nameserver 192.168.2.10
五、解析测试(nslookup,dig,host)
1.本机解析测试
# nslookup www.abc.com Server: 192.168.2.10 Address: 192.168.2.10#53 Name: www.abc.com Address: 1.1.1.1 # nslookup ftp.abc.com Server: 192.168.2.10 Address: 192.168.2.10#53 Name: ftp.abc.com Address: 2.2.2.2 # nslookup mail.abc.com Server: 192.168.2.10 Address: 192.168.2.10#53 Name: mail.abc.com Address: 3.3.3.3 # nslookup pop3.abc.com Server: 192.168.2.10 Address: 192.168.2.10#53 pop3.abc.com canonical name = mail.abc.com. Name: mail.abc.com Address: 3.3.3.3 [root@localhost named]# nslookup smtp.abc.com Server: 192.168.2.10 Address: 192.168.2.10#53 smtp.abc.com canonical name = mail.abc.com. Name: mail.abc.com Address: 3.3.3.3 # dig www.abc.com ; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.17.rc1.el6 <<>> www.abc.com ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 47951 ;; 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 1.1.1.1 ;; AUTHORITY SECTION: abc.com. 86400 IN NS ns.abc.com. ;; ADDITIONAL SECTION: ns.abc.com. 86400 IN A 192.168.2.10 ;; Query time: 0 msec ;; SERVER: 192.168.2.10#53(192.168.2.10) ;; WHEN: Mon Mar 10 00:39:25 2014 ;; MSG SIZE rcvd: 78 # host www.abc.com www.abc.com has address 1.1.1.1 # dig -t mx abc.com ; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.17.rc1.el6 <<>> -t mx abc.com ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 54214 ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 2 ;; QUESTION SECTION: ;abc.com. IN MX ;; ANSWER SECTION: abc.com. 86400 IN MX 10 mail.abc.com. ;; AUTHORITY SECTION: abc.com. 86400 IN NS ns.abc.com. ;; ADDITIONAL SECTION: mail.abc.com. 86400 IN A 3.3.3.3 ns.abc.com. 86400 IN A 192.168.2.10 ;; Query time: 1 msec ;; SERVER: 192.168.2.10#53(192.168.2.10) ;; WHEN: Mon Mar 10 00:51:22 2014 ;; MSG SIZE rcvd: 95
2.客户机测试