四、DNS服务器配置
为了让局域网内部用户访问服务器方便一点,配置一个DNS服务器是十分有必要的,毕竟一个名字总比一串数字好记,下面我将服务器10.10.1.1配一个域名www.cx.com,ftp.cx.com,好,开始行动:
需要配置的文件:
/etc/named.conf
/etc/resolv.conf
/var/named/named.hosts
/var/named/named.local
/var/named/named.10.10
1]配置/etc/named.conf文件。此文件是dns引导文件,named进程在启动时要读取它。
vi /etc/named.conf
// generated by named-bootconf.pl
options {
directory "/var/named";
// query-source address * port 53;
};
zone "." IN {
type hint;
file "named.ca";
};
//----------------------手工添加如下两节------------------------------
zone "cx.com" IN {
type master;
file "named.hosts";
};
zone "10.10.in-addr.arpa" IN {
type master;
file "named.10.10";
};
//------------------------------------------------------------------------------
zone "0.0.127.in-addr.arpa" IN {
type master;
file "named.local";
};
// include "/etc/rndc.key";
以下的三个文件是DNS数据库文件,具体参数不作详解,请参考相关资料。
2]vi /var/named/named.local
$TTL 86400
@ IN SOA ns.cx.com. root.ns.cx.com. (
1997022700 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
IN NS ns.cx.com.
1 IN PTR localhost.
3]vi /var/named/named.hosts
@ IN SOA ns.cx.com. root.ns.cx.com. (
2002042302; serial
28800; refresh
14400; retry
3600000; expire
86400; minimu
)
IN NS ns.cx.com.
cx IN A 10.10.1.1
cx1 IN A 10.10.1.223
www IN CNAME ns.cx.com.
ftp IN CNAME cx
4]vi /var/named/named.10.10
@ IN SOA ns.cx.com. root.ns.cx.com. (
2002042302; serial
28800; refresh
14400; retry
3600000; expire
86400; minimu
)
IN NS ns.cx.com.
1 IN PTR ns.cx.com.
2 IN PTR ns1.cx.com.
5]编辑/etc/resolv.conf文件
vi /etc/resolv.conf
domain cx.com
nameserver 10.10.1.1
好,让我们来启动服务吧:
/etc/rc.d/init.d/named start
chkconfig –level 3 named on #将dns服务设置成系统服务,开机自启动
测试:ping cx.cx.com
ping www.cx.com
ping ftp.cx.com
或用nslookup,用法请参考nslookup –help。
点评下: 配置DNS时反向域名在同一个网段只能有一个...
在编辑 vi /var/named/named.host时候最好是copy模板里的文件,然后进行修改,原因是有时候系统不人手工加上的..