一.修改Linux主机名
1.hostname 主机名
[root@ns named]# hostname ifs.com
2.vi /etc/hosts
[root@ns named]# vi /etc/hosts 127.0.0.1 ns.ifs.com ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 ~
3.vim /etc/sysconfig/network
[root@ns named]# vi /etc/sysconfig/network NETWORKING=yes HOSTNAME=ns.ifs.com
二.安装DNS rpm包。
bind-9.8.2-0.17.rc1.el6.x86_64
bind-libs-9.8.2-0.17.rc1.el6.x86_64
bind-utils-9.8.2-0.17.rc1.el6.x86_64
三.编辑DNS主配置文件 /etc/named.conf
options { directory "/var/named"; }; zone "." IN { type hint; file "named.ca"; }; zone "localhost" IN { type master; file "localhost.zone"; }; zone "0.0.127.in-addr.arpa" IN { type master; file "named.local"; };
四.编辑区域文件
1.localhost.zone
$TTL 600 @ IN SOA localhost. admin.localhost. ( 2014626 ; serial 1D ; refresh 1H ; retry 1W ; expire 3H ) ; minimum IN NS localhost. localhost. IN A 127.0.0.1
2.named.local
$TTL 1D @ IN SOA localhost. admin.localhost. ( 2014626 ; serial 1D ; refresh 1H ; retry 1W ; expire 3H ) ; minimum IN NS localhost. 1 IN PTR localhost.
3.更改区域文件的属组
chown :named named.local localhost.zone
五.启动named服务,测试本机正,反向解析。
service named start
netstat -tunlp |grep :53
[root@ns named]# dig -t NS localhost ; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.17.rc1.el6 <<>> -t NS localhost ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 47295 ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1 ;; QUESTION SECTION: ;localhost. IN NS ;; ANSWER SECTION: localhost. 600 IN NS localhost. ;; ADDITIONAL SECTION: localhost. 600 IN A 127.0.0.1 ;; Query time: 2 msec ;; SERVER: 10.194.210.42#53(10.194.210.42) ;; WHEN: Thu Jun 26 19:23:23 2014 ;; MSG SIZE rcvd: 57
[root@ns named]# dig -x 127.0.0.1 ; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.17.rc1.el6 <<>> -x 127.0.0.1 ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 10960 ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 1 ;; QUESTION SECTION: ;1.0.0.127.in-addr.arpa. IN PTR ;; ANSWER SECTION: 1.0.0.127.in-addr.arpa. 86400 IN PTR localhost. ;; AUTHORITY SECTION: 0.0.127.in-addr.arpa. 86400 IN NS localhost. ;; ADDITIONAL SECTION: localhost. 600 IN A 127.0.0.1 ;; Query time: 1 msec ;; SERVER: 10.194.210.42#53(10.194.210.42) ;; WHEN: Thu Jun 26 19:24:19 2014 ;; MSG SIZE rcvd: 93
六.增加要解析的区域
1.编辑DNS配置文件
options { directory "/var/named"; }; zone "." IN { type hint; file "named.ca"; }; zone "localhost" IN { type master; file "localhost.zone"; }; zone "0.0.127.in-addr.arpa" IN { type master; file "named.local"; }; zone "foxyt.net" IN { type master; file "foxyt.zone"; };
2.增加要解析的区域文件foxyt.zone
$TTL 600 $ORIGIN foxyt.net. @ IN SOA ns.foxyt.net. admin.foxyt.net ( 20140626 1H 10M 1W 1D ) IN NS ns IN MX 10 mail ns IN A 10.194.210.42 mail IN A 10.194.210.42 www IN A 1.1.1.1 ftp IN A 2.2.2.2
3.重新载入named服务
service named reload
七.修改本机DNS
[root@ns named]# vi /etc/resolv.conf # Generated by NetworkManager nameserver 10.194.210.42
八.正向解析测试
[root@ns named]# dig -t A www.foxyt.net ; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.17.rc1.el6 <<>> -t A www.foxyt.net ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 7569 ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 1 ;; QUESTION SECTION: ;www.foxyt.net. IN A ;; ANSWER SECTION: www.foxyt.net. 600 IN A 1.1.1.1 ;; AUTHORITY SECTION: foxyt.net. 600 IN NS ns.foxyt.net. ;; ADDITIONAL SECTION: ns.foxyt.net. 600 IN A 10.194.210.42 ;; Query time: 3 msec ;; SERVER: 10.194.210.42#53(10.194.210.42) ;; WHEN: Thu Jun 26 19:40:44 2014 ;; MSG SIZE rcvd: 80
本文出自 “技術成就夢想” 博客,请务必保留此出处http://zhuqianwei.blog.51cto.com/4025227/1431331
原文地址:http://zhuqianwei.blog.51cto.com/4025227/1431331