纯转发的DNS服务器配置
准备在公网搭建2台DNS服务器,给其他客户和设备提供DNS转发服务,DNS服务器本身不提供解析任务。网上查询了下,BIND好像可以设置成单独的caching-server模式。
DNS服务器端配置:
yum install bind caching-nameserver
services named start
域名ns1.test.com
cp -p /etc/named.caching-nameserver.conf /etc/named.conf
cat /etc/named.conf
[root@dns named]# cat /etc/named.conf
//
// named.caching-nameserver.conf
//
// Provided by Red Hat caching-nameserver package to configure the
// ISC BIND named( 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 { 127.0.0.1; };
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";
forwarders { 10.155.3.241; };
// 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";
};
在dns 服务器本地设置/etc/resolv.conf namesever 127.0.0.1 可以解析到外部域名。当其他客户机将DNS 服务器地址设置成这台地址的时候,解析不到。
难道是没开启抓发功能,还是其他地方要做配置?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
这个有可能啊
怎么配置?
网上参考了下,配置的差不多了,客户机可以用这个DNS,但是在服务器端却有很多错误提示,不知道怎么回事:
tail -f /var/named/data/named.run
isc_socket_create: fcntl/reserved: Too many open files
isc_socket_create: fcntl/reserved: Too many open files
isc_socket_create: fcntl/reserved: Too many open files
isc_socket_create: fcntl/reserved: Too many open files
isc_socket_create: fcntl/reserved: Too many open files
isc_socket_create: fcntl/reserved: Too many open files
isc_socket_create: fcntl/reserved: Too many open files
isc_socket_create: fcntl/reserved: Too many open files
network unreachable resolving 'centosi3.centos.org/AAAA/IN': 2001:500:48::1#53
network unreachable resolving 'centosi3.centos.org/AAAA/IN': 2001:500:f::1#53
network unreachable resolving 'centosi3.centos.org/AAAA/IN': 2001:500:c::1#53
^[enetwork unreachable resolving 'ns2.cernet.net/A/IN': 2001:503:a83e::2:30#53
network unreachable resolving 'mirrors.jiangnan.edu.cn.aerohive-hz.com/A/IN': 2001:503:a83e::2:30#53
network unreachable resolving 'ns2.cernet.net/AAAA/IN': 2001:503:a83e::2:30#53
network unreachable resolving 'ns2.cernet.net/A/IN': 2001:503:a83e::2:30#53
network unreachable resolving 'NS1.CUHK.EDU.hk/A/IN': 2405:3000:3:60::1#53
network unreachable resolving 'NS1.CUHK.EDU.hk/A/IN': 2405:3000:3:60::1#53
network unreachable resolving 'NS1.CUHK.EDU.hk/AAAA/IN': 2405:3000:3:60::1#53
network unreachable resolving 'NS1.CUHK.EDU.hk/AAAA/IN': 2405:3000:3:60::1#53
这些域名也不是客户端发出来的,自动出现的
现在在客户机PING域名能解析到IP,但是解析时间非常慢,一般至少5秒以上。不知道是哪里的问题。named.conf配置文件如下:
# cat /etc/named.conf
//
// named.caching-nameserver.conf
//
// Provided by Red Hat caching-nameserver package to configure the
// ISC BIND named( 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 { 10.155.3.241; };
// 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";
// forward only;
forwarders { 192.168.0.1; }; // dns server地址
recursion yes;
allow-recursion { any; };
// 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";
#};
zone "." IN {
type hint;
file "named.ca";
};
zone "localhost" IN {
type master;
file "localhost.zone";
#file "localhost.zone";
allow-update {none;};
};
zone "0.0.127.in-addr.arpa" {
type master;
file "named.local";
#file "named.zero";
allow-update {none;};
};
多次解释同一个域名,只是第一次解释时慢吧?
目前把查询转发到192.168.0.1,如果这台服务器慢的话,你的named server 也快不到哪里。
我一般把查询直接转发到ISP 的DNS 服务器,或根服务器,也不见得慢啊。
谢谢,你说的没错,我把named.conf里的 forwarders 改成我的ISP DNS,客户机解析的时候速度就很快了。
例如: forwarders { 218.108.248.200; }; //杭州网通DNS
但是有个问题,万一ISP DNS挂了怎么办呢?不知道能否设置多个DNS
如果要指向到根服务器应该怎么设置?当前如果把forwarders指向到我自己的DNS SERVER本机,即192.168.0.1,速度虽然慢,但还是可以解析的,我看了下本机/var/named/named.ca,也是保存了所有根服务器地址的。
# more named.ca
; <<>> DiG 9.5.0b2 <<>> +bufsize=1200 +norec NS . @a.root-servers.net
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 7033
;; flags: qr aa; QUERY: 1, ANSWER: 13, AUTHORITY: 0, ADDITIONAL: 20
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;. IN NS
;; ANSWER SECTION:
. 518400 IN NS D.ROOT-SERVERS.NET.
. 518400 IN NS E.ROOT-SERVERS.NET.
. 518400 IN NS F.ROOT-SERVERS.NET.
. 518400 IN NS G.ROOT-SERVERS.NET.
. 518400 IN NS H.ROOT-SERVERS.NET.
. 518400 IN NS I.ROOT-SERVERS.NET.
. 518400 IN NS J.ROOT-SERVERS.NET.
. 518400 IN NS K.ROOT-SERVERS.NET.
. 518400 IN NS L.ROOT-SERVERS.NET.
. 518400 IN NS M.ROOT-SERVERS.NET.
. 518400 IN NS A.ROOT-SERVERS.NET.
. 518400 IN NS B.ROOT-SERVERS.NET.
. 518400 IN NS C.ROOT-SERVERS.NET.
;; ADDITIONAL SECTION:
A.ROOT-SERVERS.NET. 3600000 IN A 198.41.0.4
A.ROOT-SERVERS.NET. 3600000 IN AAAA 2001:503:ba3e::2:30
B.ROOT-SERVERS.NET. 3600000 IN A 192.228.79.201
C.ROOT-SERVERS.NET. 3600000 IN A 192.33.4.12
D.ROOT-SERVERS.NET. 3600000 IN A 128.8.10.90
E.ROOT-SERVERS.NET. 3600000 IN A 192.203.230.10
F.ROOT-SERVERS.NET. 3600000 IN A 192.5.5.241
F.ROOT-SERVERS.NET. 3600000 IN AAAA 2001:500:2f::f
G.ROOT-SERVERS.NET. 3600000 IN A 192.112.36.4
H.ROOT-SERVERS.NET. 3600000 IN A 128.63.2.53
H.ROOT-SERVERS.NET. 3600000 IN AAAA 2001:500:1::803f:235
I.ROOT-SERVERS.NET. 3600000 IN A 192.36.148.17
J.ROOT-SERVERS.NET. 3600000 IN A 192.58.128.30
J.ROOT-SERVERS.NET. 3600000 IN AAAA 2001:503:c27::2:30
K.ROOT-SERVERS.NET. 3600000 IN A 193.0.14.129
K.ROOT-SERVERS.NET. 3600000 IN AAAA 2001:7fd::1
L.ROOT-SERVERS.NET. 3600000 IN A 199.7.83.42
M.ROOT-SERVERS.NET. 3600000 IN A 202.12.27.33
M.ROOT-SERVERS.NET. 3600000 IN AAAA 2001:dc3::35
;; Query time: 110 msec
;; SERVER: 198.41.0.4#53(198.41.0.4)
;; WHEN: Tue Feb 26 15:05:57 2008
;; MSG SIZE rcvd: 615