
我想將伺服器的 IP 設定為 DNS,然後能夠將 myproject.com、www.myproject.com 和 *.applications.com 等網域指向我將在 apache 中託管這些檔案的相同伺服器。
我安裝了 macports,這是我的設定檔:/opt/local/etc/named.conf
// Declares control channels to be used by the rndc utility.
//
// This must be enabled on Mac OS X Server for Server Status to provide valid
// information! (Remove the leading slashes to enable.)
//
// **** STUFF YOU MIGHT NEED TO ENABLE ****
//
controls {
unix "/var/run/ndc" perm 0600 owner 0 group 0;
inet 127.0.0.1 port 54 allow {any; };
};
// It is recommended that 127.0.0.1 be the only address used.
// This also allows non-privileged users on the local host to manage
// your name server.
options {
directory "/opt/local/var/named";
// uncomment the following lines to turn on DNS forwarding,
// and change the forwarind ip address(es) :
//forward first;
//forwarders {
// 123.123.123.123
// 123,123.123.123;
//};
listen-on-v6 { none; };
listen-on { 127.0.0.1; };
// to allow only specific hosts to use the DNS server:
//allow-query {
// 127.0.0.1;
//};
dnssec-validation auto;
pid-file "/opt/local/var/run/named.pid";
};
//
// a caching only nameserver config
zone "." IN {
type hint;
file "db.cache";
};
zone "localhost" IN {
type master;
file "db.localhost";
allow-update { none; };
};
zone "0.0.127.in-addr.arpa" IN {
type master;
file "db.127.0.0";
allow-update { none; };
};
所以我希望能夠使所有這些指向安裝了 bind 的同一伺服器:
www.myproject.com
myproject.com
*.applications.com
我怎樣才能做到這一點?我還想問如何才能獲得關於bind的好的文件或書籍。我在網路上找到的文件要么技術性太強,要么過於簡化。
或者是否有更簡單的介面來使用綁定?
答案1
您需要編輯named.conf來新增一個區域,例如:
zone "myproject.com" IN {
type master;
file "myproject.com.zone";
allow-update { none; };
}
/opt/local/var/named
然後在named中建立一個區域檔案myproject.com.zone
。該文件應如下所示:
$ORIGIN myproject.com.
$TTL 21600
@ 3600 SOA <your ns A record>. (
sysadmins.stackoverflow.com. ; address of responsible party
2011072601 ; serial number
3600 ; refresh period
600 ; retry period
604800 ; expire time
60 ) ; minimum ttl
NS <YOUR_NS_A_RECORD>.
A <YOUR_IP>
* IN A <YOUR_IP>
通配符是您最好的選擇,因為這樣您就不必再擔心它了。
我強烈建議您獲取一份副本DNS 和綁定
答案2
這就是區域文件中對我有用的內容,我使用了 Zypher 在named.conf中建議的內容
$TTL 10800
myproject.com. IN SOA myservername.myproject.com. admin.mymyproject.com. (
2011071800 ;Serial
86400 ;Refresh
3600 ;Retry
604800 ;Expire
345600 ;Negative caching TTL
)
www.projects.com. IN A <SERVER IP>
projects.com. IN NS myservername.myproject.com.
projects.com. IN A <SERVER IP>
www IN CNAME myproject.com.