![在 CentOS 5.9 上設定 Bind9 DNS 伺服器](https://rvso.com/image/623654/%E5%9C%A8%20CentOS%205.9%20%E4%B8%8A%E8%A8%AD%E5%AE%9A%20Bind9%20DNS%20%E4%BC%BA%E6%9C%8D%E5%99%A8.png)
我有一個安裝了 CentOS 5.9 32 位元的 OpenVZ VPS 伺服器。我還從本地提供者 (masterwebnet.com) 購買網域 sehattotal.com。目前 sehattotal.com 託管在 hostgator.com 上。
我的目的是在 VPS 伺服器中建立 DNS 伺服器並將我的網域定向到它。
所以我嘗試在我的伺服器中配置 Bind9,如下所示:
/etc/named.conf:
options {
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";
allow-query { any; };
allow-transfer { localhost; 0.0.0.0; };
recursion no;
dnssec-enable yes;
dnssec-lookaside . trust-anchor dlv.isc.org.;
};
logging
{
channel default_debug {
file "data/named.run";
severity dynamic;
};
};
zone "." IN {
type hint;
file "named.root";
};
zone "localdomain." IN {
type master;
file "localdomain.zone";
allow-update { none; };
};
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 "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; };
};
zone "sehattotal.com" IN {
type master;
file "sehattotal.com.zone";
allow-update { none; };
};
include "/etc/rndc.key";
/var/named/chroot/var/named/sehattotal.com.zone:
$TTL 86400
@ IN SOA ns1.sehattotal.com. root.sehattotal.com. (
2013122901 ;Serial
21600 ;Refresh
1800 ;Retry
604800 ;Expire
86400 ) ;Minimum TTL
@ IN NS ns1.sehattotal.com.
ns1 IN A 116.251.208.167
當我嘗試啟動命名服務時沒有錯誤。
問題我認為它不起作用,因為我無法 ping 通 ns1.sehatttotal.com。
有什麼建議嗎?
筆記: 目前 sehattotal.com 有 NS2227.HOSTGATOR.COM 和 NS228.HOSTGATOR.COM 我仍然無法將其更改為 NS1.SEHATTOTAL.COM,因為當我 ping 到 NS1.SEHATTOTAL.COM 時它返回:
Ping 要求找不到主機 ns1.sehatttotal.com。請檢查名稱並重試。
答案1
您的提供者未正確委派區域:
[me@risby tmp]$ whois sehattotal.com
[Querying whois.verisign-grs.com]
[Redirected to whois.tucows.com]
[Querying whois.tucows.com]
[whois.tucows.com]
Domain Name: SEHATTOTAL.COM
[...]
Name Server: NS2227.HOSTGATOR.COM
Name Server: NS2228.HOSTGATOR.COM
和
[root@bill ~]# dig NS2227.HOSTGATOR.COM
[...]
;; ANSWER SECTION:
NS2227.HOSTGATOR.COM. 43200 IN A 192.254.235.98
[...]
[root@bill ~]# dig NS2228.HOSTGATOR.COM
[...]
;; ANSWER SECTION:
NS2228.HOSTGATOR.COM. 43200 IN A 192.254.235.99
[...]
由於這兩個都不是您為您設定的 IP 位址ns1
,也就是說116.251.208.167
,我認為委託是不正確的。
僅僅註冊網域名稱和設定名稱伺服器並不能神奇地將兩者聯繫起來:必須告訴世界,當它查找網域時,它應該使用您的名稱伺服器(是的,將需要兩個,即使您只需列出相同的地址兩次)。這是由您的註冊商(在本例中為 tucows)提供的黏合劑來完成此操作。
我會否決這個問題,因為“沒有表現出任何研究努力”,但你足夠好,提供了完整的網域和地址,並且沒有模糊你的問題中的任何內容。謝謝你 - 這並沒有讓他們更容易回答。
答案2
看來你缺少反向 DNS 區域,
還要在resolve.conf檔中加入dns伺服器的ip
不要忘記在防火牆中允許 dns 流量
iptables -A OUTPUT -p udp -o eth0 --dport 53 -j ACCEPT
iptables -A INPUT -p udp -i eth0 --sport 53 -j ACCEPT
將 eth0 變更為偵聽 ip 的接口,或僅出於測試目的停止防火牆
service iptables stop
然後啟動指定的服務。
下面有一個很好的指南,您只需要設定主 DNS 部分。
http://www.unixmen.com/dns-server-installation-step-by-step-using-centos-6-3/