Linux下配置DNS

1 所需配置文件:

/etc/named.conf 系统自带,需要配置
/etc/resolv.conf 系统自带,需要配置
/var/named/myqmail.com.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 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 “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.com” IN {
type master;
file “myqmail.com.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.com.db

说明:正向解析配置文件,即实现域名到IP的对应。源文件:

$TTL 86400
@ IN SOA www.myqmail.com. myqmail.com. (
2002103000 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
IN NS www.myqmail.com.
localhost IN A 127.0.0.1
www IN A 192.168.0.198

3.3 /var/named/db.192.168.0.198

说明:DNS反向解析配置文件,即实现IP地址很域名的映射。源文件:

$TTL 86400
@ IN SOA www.myqmail.com. myqmail.com. (
2002103000 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
IN NS www.myqmail.com.
198 IN PTR www.myqmail.com.

3.4 /etc/resolv.conf

说明:指定域名服务器的IP和搜索顺序。源文件:

search myqmail.com
nameserver 192.168.0.198

4 测试及管理办法

4.1 测试方法

1. 修改完DNS的配置文件,需要执行/etc/rc.d/init.d/named restart来使更改生效。

2. nslookup:测试正向、反向的解析是否正常

评论关闭