一,什么是DNS
DNS 是计算机域名 (Domain Name System) 的缩写,它是由解析器和域名服务器组成的。域名服务器是指保存有该网络中所有主机的域名和对应IP地址,并具有将域名转换为IP地址功能的服务器。其中域名必须对应一个IP地址,而IP地址不一定有域名。
二,DNS安装
[root@linux ~]# yum -y install bind* caching-nameserver
三,DNS配置
[root@linux ~]# cd /var/named/chroot/etc/ [root@linux etc]# cp -p named.caching-nameserver.conf named.conf [root@linux etc]# cp -p named.rfc1912.zones named.rfc1912.zones.bak //做好备份
注意:这里别忘了加上-p,不然文件的所属用户组属性就会改变,启动named的时候会报错。看下面
[root@linux etc]# ll |grep named.conf -rw-r----- 1 root named 1206 11-03 17:58 named.conf //加上-p -rw-r----- 1 root root 1206 11-03 19:35 named.conf_bak //不加-p
1,配置named.conf
[root@linux etc]# cat named.conf //这个是我改过的文件 // // named.caching-nameserver.conf // // Provided by Red Hat caching-nameserver package to configure the // ISC BIND named(8) DNS server as a caching only nameserver // (as a localhost DNS resolver only). // // See /usr/share/doc/bind*/sample/ for example named configuration files. // // DO NOT EDIT THIS FILE - use system-config-bind or an editor // to create named.conf - edits to this file will be lost on // caching-nameserver package upgrade. // options { listen-on port 53 { any; }; //把localhost改成any listen-on-v6 port 53 { ::1; }; directory "/var/named"; dump-file "/var/named/data/cache_dump.db"; statistics-file "/var/named/data/named_stats.txt"; memstatistics-file "/var/named/data/named_mem_stats.txt"; // Those options should be used carefully because they disable port // randomization // query-source port 53; // query-source-v6 port 53; allow-query { any; }; allow-query-cache { any; }; }; logging { channel default_debug { file "data/named.run"; severity dynamic; }; }; view localhost_resolver { match-clients { any; }; match-destinations { any; }; recursion yes; include "/etc/named.rfc1912.zones"; };
把文件中的localhost改成any。
三,配置named.rfc1912.zones
[root@linux etc]# cat named.rfc1912.zones // named.rfc1912.zones: // // Provided by Red Hat caching-nameserver package // // ISC BIND named zone configuration for zones recommended by // RFC 1912 section 4.1 : localhost TLDs and address zones // // See /usr/share/doc/bind*/sample/ for example named configuration files. // zone "." IN { type hint; file "named.ca"; }; zone "localdomain" IN { type master; file "localdomain.zone"; allow-update { none; }; }; zone "localhost" IN { type master; file "localhost.zone"; allow-update { none; }; }; zone "0.0.127.in-addr.arpa" IN { type master; file "named.local"; allow-update { none; }; }; zone "0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa" IN { type master; file "named.ip6.local"; allow-update { none; }; }; zone "255.in-addr.arpa" IN { type master; file "named.broadcast"; allow-update { none; }; }; zone "0.in-addr.arpa" IN { type master; file "named.zero"; allow-update { none; }; }; zone "51yip.com" IN { //从这儿开始到下面是我加的,根上面的内容copy后改的 type master; file "51yip.com.zone"; allow-update { none; }; }; zone "1.168.192.in-addr.arpa" IN { type master; file "1.168.192.in-addr.local"; allow-update { none; }; };
如果是多个域名的话,在加一个
zone "51yip.net" IN { type master; file "51yip.net.zone"; allow-update { none; }; };
三,修改Zone的配置文件
[root@linux etc]# cd /var/named/chroot/var/named/ [root@linux named]# cp -p localdomain.zone 51yip.com.zone //[root@linux named]# cp -p localdomain.zone 51yip.net.zone //如果是多个域名就在copy一份 [root@linux named]# cp -p named.local 1.168.192.in-addr.local
1,修改51yip.com.zone
[root@linux named]# cat 51yip.com.zone $TTL 86400 @ IN SOA localhost root ( 42 ; serial (d. adams) 3H ; refresh 15M ; retry 1W ; expiry 1D ) ; minimum IN NS 51yip.com IN MX 10 mail.51yip.com www IN A 192.168.1.132 mail IN A 192.168.1.131 dns IN A 192.168.1.130
添加的内容,修改的内容,对比一下localhost.zone文件
2,修改1.168.192.in-addr.local
[root@linux named]# cat 1.168.192.in-addr.local $TTL 86400 @ IN SOA localhost. root.localhost. ( 1997022700 ; Serial 28800 ; Refresh 14400 ; Retry 3600000 ; Expire 86400 ) ; Minimum IN NS 51yip.com. 132 IN PTR www.51yip.com. 131 IN PTR mail.51yip.com. 130 IN PTR dns.51yip.com.
到这儿dns的简单配置就好了。
四,启动DNS
[root@linux named]# /etc/init.d/named start 启动 named: [确定]
五,测试DNS
1,正向解释
[root@linux named]# nslookup www.51yip.com Server: 192.168.1.130 Address: 192.168.1.130#53 Name: www.51yip.com Address: 192.168.1.132
2,反向解释
[root@linux named]# nslookup 192.168.1.131 Server: 192.168.1.130 Address: 192.168.1.130#53 131.1.168.192.in-addr.arpa name = mail.51yip.com.
转载请注明
作者:海底苍鹰
地址:http://blog.51yip.com/server/1348.html