etc/hosts
文件的具体内容如下: # Do not remove the following line, or various programs # that require network functionality will fail. 127.0.0.1 localhost.localdomain localhost fc4 192.168.1.3 a.test.com a 192.168.1.1 b.test.cn b /etc/host.conf 文件: order hosts,bind 表示先用hosts文件做
解析,在用DNS解析 /etc/resolv.conf 文件: generated by NetworkManager, do not edit! search test.com nameserver 127.0.0.1 search test.cn nameserver 192.168.1.1 nameserver 61.144.56.100 /etc/named.conf 文件: // // named.conf for Red Hat caching-nameserver // options { directory "/var/named" dump-file "/var/named/data/cache_dump.db" statistics-file "/var/named/data/named_stats.txt" /* * 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 // controls { inet 127.0.0.1 allow { localhost} keys { rndckey} } zone "." IN { type hint file "named.ca" } zone "test.com"IN { type master file "test.com" allow-update { none} } zone "1.168.192.in-addr.arpa"IN { type master file "192.168.1.rev" allow-update { none} } zone "test.cn"IN { type master file "test.cn" 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} } include "/etc/rndc.key" 在/var/name/test.com 文件下: $TTL 86400 @ IN SOA a.test.com. root.a.test.com ( 42 serial (d. adams) 3H refresh 15M retry 1W expiry 1D ) minimum IN NS a.test.com. IN MX 10 mail.test.com. a IN A 192.168.1.3 mail IN A 192.168.1.3 //其中root.a.test.com的含义是管理员的邮箱 /var/name/test.cn 文件下: $TTL 86400 @ IN SOA b.test.cn. root.a.test.com ( 42 serial (d. adams) 3H refresh 15M retry 1W expiry 1D ) minimum IN NS b.test.cn. IN MX 10 mail.test.cn. b IN A 192.168.1.1 mail IN A 192.168.1.1 /var/name/192.168.1.rev 文件下: $TTL 86400 @ IN SOA 1.168.192.in-addr.arpa. root.test.com. ( 1997022700 Serial 28800 Refresh 14400 Retry 3600000 Expire 86400 ) Minimum IN NS a.test.com. IN NS b.test.cn. IN MX 10 mail.test.com. IN MX 10 mail.test.cn. 3 IN PTR a.test.com. 3 IN PTR mail.test.com. 1 IN PTR b.test.cn. 1 IN PTR mail.test.cn. 然后用/etc/init.d/named restart重启DNS服务,在重启过程中,我曾经出现过好几次的错误,按照出错的提示,会提示是named.conf文件第几行出错的。或者提示在那些包含文件例如test.cn这些文件里面的问题,然后一个一个排除。 最后还有一些nslookup的命令比较有用: set all用于显示使用nslookup工具这台机器上的DNS服务器的一些信息 set type=any会显示完整信息包括域中邮件服务器和主从DNS服务器的名字和IP地址 server 192.168.0.1更换查询的DNS服务器地址。分类: 电脑/网络 >> *** 作系统/系统故障
解析:
在查阅许多DNS配置手册后,无法是照办还是修改,我始终没有配置正确,总是正向解析无法解析.最后,在一次配置中,突然灵机一动,终于配置成功。(2002-12-12 11:47:50) By Angelhua
下面是我配置DNS的实例:
1 所需配置文件:
/etc/named.conf 系统自带,需要配置
/etc/resolv.conf 系统自带,需要配置
/var/named/myqmail.db 系统没有,自已创建
/var/named/db.192.168.0.198 系统没有,自已创建
/var/named/named.local 系统自带,不需要修改
/var/named/named.ca 系统自带,不需要修改
2 相关工具
nslookup
说明:检测DNS是否配置正确的工具,系统自带。
3 配置方案
3.1 /etc/named.conf
说明:DNS主配置文件,定义了域数据库信息的基本参数和源点,该文件可以存放在本地或远程的服务器上。源文件:
generated by named-bootconf.pl
options {
directory "/var/named"
/*
* If there is a firewall beeen you and nameservers you want
* to talk to, you might need to unment 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
controls {
i 127.0.0.1 allow { localhost} keys { rndckey}
}
zone "." IN {
type hint
file "named.ca"
}
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 "myqmail" IN {
type master
file "myqmail.db"
allow-update { none}
}
zone "0.168.192.in-addr.arpa" IN{
type master
file "db.192.168.0.198"
allow-update { none}
}
include "/etc/rndc.key"
3.2 /var/named/myqmail.db
说明:正向解析配置文件,即实现域名到IP的对应。源文件:
$TTL 86400
@ IN SOA myqmail. myqmail. (
*********** Serial
28800 Refresh
14400 Retry
3600000 Expire
86400 ) Minimum
IN NS myqmail.
localhost IN A 127.0.0.1
IN A 192.168.0.198
3.3 /var/named/db.192.168.0.198
说明:DNS反向解析配置文件,即实现IP地址很域名的映射。源文件:
$TTL 86400
@ IN SOA myqmail. myqmail. (
*********** Serial
28800 Refresh
14400 Retry
3600000 Expire
86400 ) Minimum
IN NS myqmail.
198 IN PTR myqmail.
3.4 /etc/resolv.conf
说明:指定域名服务器的IP和搜索顺序。源文件:
search myqmail
nameserver 192.168.0.198
4 测试及管理办法
4.1 测试方法
1. 修改完DNS的配置文件,需要执行/etc/rc.d/init.d/named restart来使更改生效。
2. nslookup:测试正向、反向的解析是否正常
5 小结
DNS服务是许多服务的基础,所以我刚开始linux服务器时,就着手配置DNS服务器。在不懂如何开始时,就拚命上网查相关配置文档。但我犯错了。因为我的DNS是用在局域网中,根本不连接Inter,仅仅限于局域网中为各个部门的各主机及服务器作解析用。但是许多网上资料都是针对有DNS服务器来配置的,也就是说是一种层层解析方式,与我的配置思路不一样。在耗用了许多时间的情况下,我终于成功地配置了自己的DNS服务器。希望我的配置实例对大家有很好的帮助。
以ubuntu为例子:
sudo /etc/resolv.conf
用#屏蔽原来的nameserver,然后添加新的DNS如下:
nameserver 8.8.8.8
nameserver 8.8.4.4
这里8.8.x.x是谷歌提供的域名解析服务,你可以设定你自己的。
评论列表(0条)