配置 DNS 服务器 |
时间:2015-01-18 来源:互联网 作者:佚名 |
|
对于用于网络快速更新的软件各版本,用对外开放的服务器来测试是具有一定危险性的,用内部网专门的一台计算机来测试是最好不过的了,因此就专门配置了一台用于内联网的服务器,也因此配置了一个为内联网用的简单 DNS 服务器,下面就介绍一下这个 DNS 的配置过程. 内联网主机服务器的主机名为 pc10,IP 是:192.168.1.10,启用 tcpip.cxm 作为域名. 整个过程需要配置以下几个配置文档: /etc/hosts /etc/host.conf /etc/resolv.conf /etc/named.conf /var/named/named.192.168.1 /var/named/named.tcpip.cxm 1.首先配置 /etc/hosts 指定 Ip 到主机的影射,下面是配置好的文档 ------------------------------------------------------- #IP Address Hostname Alias 127.0.0.1 localhost 192.168.1.10 pc10 pc10.tcpip.cxm -------------------------------------------------------- 2.接下来是 /etc/host.conf 的配置 -------------------------------------------------------- order hosts, bind multi on -------------------------------------------------------- 这个配置的意思是从 /etc/hosts 开始查询,然后是 DNS,如果是多个主机将全部返回 3.配置 /etc/resolv.conf -------------------------------------------------------- search tcpip.cxm nameserver 192.168.1.10 -------------------------------------------------------- 这儿配置的是 DNS 客户,search 指定的是客户默认域名,nameserver 则是指定使用的 DNS 服务器的 IP 地址,这里使用的是正在配置 DNS 服务器的主机 IP 地址:192.168.1.10 4.配置 /etc/named.conf ,这个文档的配置很重要 -------------------------------------------------------- // generated by named-bootconf.pl options { directory "/var/named"; /* * If there is a firewall between you and nameservers you want * to talk to, you might need to uncomment the query-source * directive below. Previous versions of BIND always asked * questions using port 53, but BIND 8.1 uses an unprivileged * port by default. */ // query-source address * port 53; }; // // a caching only nameserver config // zone "." { type hint; file "named.ca"; }; zone "0.0.127.in-addr.arpa" { type master; file "named.local"; }; zone "1.168.192.in-addr.arpa" { type master; file "named.192.168.1"; }; zone "tcpip.cxm" { type master; file "named.tcpip.cxm"; }; -------------------------------------------------------- 里面的 // 后和 /* */ 里的内容都是注释,尤其要注意里面的标点要正确,zone "1.168.192.in-addr.arpa" 是配置反序查找,而 zone "tcpip.cxm" 则是配置正序查找 5.创建区数据文件 /var/named/named.192.168.1,只需复制 /var/named/named.local 为 /var/named/named.192.168.1 进行修改(注意:是复制不是更名),修改后的内容如下: --------------------------------------------------------- @ IN SOA pc10.tcpip.cxm. hostnaster.pc10.tcpip.cxm. ( 1997022700 ; Serial 28800 ; Refresh 14400 ; Retry 3600000 ; Expire 86400 ) ; Minimum IN NS pc10.tcpip.cxm. 1 IN PTR pc10.tcpip.cxm. --------------------------------------------------------- 里面各个标点也必须正确! 6.创建数据文件 /etc/named.tcpip.cxm ,正确结果如下: --------------------------------------------------------- @ IN SOA pc10.tcpip.cxm. hostmaster.pc10.tcpip.cxm. ( 1997022700 ; Serial 28800 ; Refresh 14400 ; Retry 3600000 ; Expire 86400 ) ; Minimum IN NS pc10 pc10 IN A 192.168.1.10 www IN CNAME pc10 ---------------------------------------------------------- 这里 NS 是域名服务器, A 是地址记录,CNAME 是规范的名程也指替换,也就是说用 pc10.tcpip.cxm 与 www.tcpip.cxm 一样. 7.仔细检查确保正确后,重新启动 DNS 守护进程 named: #/etc/rc.d/init.d/named restart 8.检查 DNS 服务器 先 telnet 192.168.1.10 ,然后 ping 外部网址,再用 nslookup 正确的话 DNS 服务器配置成功.这时内部网的计算机都可用 192.168.1.10 作为域名服务器.
|
|
|
|