网络环境
Hostname: zhengwing.org; mail.zhengwing.org; pop3.zhengwing.org; smtp.zhengwing.org.
IP add:192.168.254.254/24
Defaultgw:192.168.254.2
DNS server:192.168.254.2 ( Replace IP address to 192.168.254.123 when set completed. )
bind&&bind-tools安装
shell>USE=”dlz” emerge –av bind bind-tools
查看named.conf文件(默认配置)
shell> cat /etc/bind/named.conf
acl "xfer" {* If we have other name servers, place them here.none;};acl "trusted" {};options {listen-on { 127.0.0.1; };allow-query {trusted;};allow-query-cache {trusted;};allow-recursion {trusted;};allow-transfer {none;};allow-update {none;};forward first;forwarders {};};logging {channel default_log {print-time yes;print-severity yes;print-category yes;};category default { default_log; };category general { default_log; };};controls {};zone "." in {type hint;};zone "localhost" IN {type master;notify no;};zone "127.in-addr.arpa" IN {type master;notify no;}; |
配置DNS服务器,随便找台可以使用的DNS服务器
shell> echo "nameserver 192.168.254.2" >> /etc/resolv.conf
获取根目录服务器
shell> dig –t NS
拷贝根目录IP添加到/etc/resolv.conf
格式为:
nameserver 198.41.0.4
Nameserver 192.228.79.201
…………………………………
Nameserver 192.36.148.17
导入根目录地址到named.cache文件
shell> dig –t NS . > /var/bind/named.cache
shell> cat /var/bind/named.cache 如下图
配置完成
测试
shell> echo "nameserver 127.0.0.1" > /etc/resolv.conf
shell> /etc/init.d/named restart
shell> host
如图,正向与反向解析成功。
添加域名解析功能
1. 修改DNS配置文件,添加以下内容
shell> vi /etc/bind/named.conf
zone "zhengwing.org" IN {type master;file "pri/zhengwing.zone";allow-update {none;};notify no;};zone "254.168.192.in-addr.arpa" IN {type master;file "pri/192.168.254.zone";allow-update {none;};notify no;};
2. 添加解析文件
shell> cd /var/bind/pri
正向解析
shell> vi zhengwing.zone
$TTL 1W@ IN SOA zhengwing.org root.zhengwing.org. (2010091808 ; Serial28800 ; Refresh14400 ; Retry604800 ; Expire - 1 week86400 ) ; Minimum@ IN NS zhengwing.org.@ IN A 192.168.254.254mail IN CNAME zhengwing.org.smtp IN CNAME zhengwing.org.pop3 IN CNAME zhengwing.org.@ IN MX 5 mail.zhengwing.org.
反向解析 |
shell> vi 192.168.254.zone
$ORIGIN 254.168.192.in-addr.arpa.$TTL 1W@ 1D IN SOA zhengwing.org root.zhengwing.org. (2010092204 ; serial3H ; refresh15M ; retry1W ; expiry1D ); minimum@ 1D IN NS zhengwing.org.254 1D IN PTR zhengwing.org.254 1D IN PTR mail.zhengwing.org.254 1D IN PTR smtp.zhengwing.org.254 1D IN PTR pop3.zhengwing.org. |
11.3 测试
shell> /etc/init.d/named restart