2015年5月19日 星期二
2013年12月11日 星期三
臺中市教育網路中心 定時連線測試 首頁/DNS [梧棲國中]量測記錄
首頁v6調整了下列文件
原先的首頁v4死當
哪裡做錯
參考了
一、httpd.conf 監聽埠設定
原本v4的全介面監聽 Listen 80 和 v6 的介面監聽 [::]:80 如果要同時監聽 v4 + v6
一定要 By IP設定,不能再使用懶人法::80 或 [::]:80
例如我有 v4 2個介面 + v6 2個介面 則要設四條,注意v6位址一定要用[ ] 框起:
Listen MailScanner has detected a possible fraud attempt from "127.0.0.1" claiming to be 127.0.0.1:80
Listen MailScanner has detected a possible fraud attempt from "163.17.38.83" claiming to be 163.17.38.83:80
Listen [2001:288:5400:2::83]:80
Listen [2001:288:5400:2::1]:80
如果所有介面都要監聽,則只設定一條,其餘刪除:
Listen 80
二、VH的話無變更,和v4相同
以中縣網的 ipv6.tcc.edu.tw為例:
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /home/ipv6/html
ServerName ipv6.tcc.edu.tw
CustomLog /var/log/http-access/ipv6.tcc.edu.tw combined
ErrorLog /var/log/http-error/ipv6.tcc.edu.tw
ServerAlias ip6.tcc.edu.tw
</VirtualHost>
注意這裡的 <, >已被換成全型的,請自換回半型字
三、DNS 也要設定
DNS 加上 AAAA 記錄
ipv6.tcc.edu.tw. IN AAAA 2001:288:5400:2::1
四、網頁瀏覽方法
用網址不改變習慣
http://ipv6.tcc.edu.tw/
用 IP6記得加中括號把位址包起來 [ ]
http://[2001:288:5400:2::1]/
原先的首頁v4死當
哪裡做錯
臺中市教育網路中心 定時連線測試 首頁/DNS [梧棲國中]量測記錄
首頁 | www.wcjs.tc.edu.tw |
DNSv4 | 163.17.209.1, |
DNSv6 | 2001:288:5421:0:0:0:0:1, |
時間 | 首頁v4 | DNSv4 | 首頁v6 | DNSv6 |
---|---|---|---|---|
2012-10-18 9:00 | 1 | 1 | 0 | 1 |
2012-10-18 8:00 | 1 | 1 | 0 | 1 |
2012-10-18 7:00 | 1 | 1 | 0 | 1 |
一、httpd.conf 監聽埠設定
原本v4的全介面監聽 Listen 80 和 v6 的介面監聽 [::]:80 如果要同時監聽 v4 + v6
一定要 By IP設定,不能再使用懶人法::80 或 [::]:80
例如我有 v4 2個介面 + v6 2個介面 則要設四條,注意v6位址一定要用[ ] 框起:
Listen MailScanner has detected a possible fraud attempt from "127.0.0.1" claiming to be 127.0.0.1:80
Listen MailScanner has detected a possible fraud attempt from "163.17.38.83" claiming to be 163.17.38.83:80
Listen [2001:288:5400:2::83]:80
Listen [2001:288:5400:2::1]:80
如果所有介面都要監聽,則只設定一條,其餘刪除:
Listen 80
二、VH的話無變更,和v4相同
以中縣網的 ipv6.tcc.edu.tw為例:
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /home/ipv6/html
ServerName ipv6.tcc.edu.tw
CustomLog /var/log/http-access/ipv6.tcc.edu.tw combined
ErrorLog /var/log/http-error/ipv6.tcc.edu.tw
ServerAlias ip6.tcc.edu.tw
</VirtualHost>
注意這裡的 <, >已被換成全型的,請自換回半型字
三、DNS 也要設定
DNS 加上 AAAA 記錄
ipv6.tcc.edu.tw. IN AAAA 2001:288:5400:2::1
四、網頁瀏覽方法
用網址不改變習慣
http://ipv6.tcc.edu.tw/
用 IP6記得加中括號把位址包起來 [ ]
http://[2001:288:5400:2::1]/
2013年11月6日 星期三
設定防止DNS查詢特殊網域
設定防止DNS查詢特殊網域
軟體: BIND
下面使用 CentOS來示範
1. 修改 named.conf
#vi /var/named/chroot/etc/named.conf
加入想要阻擋的「網址名稱」(目前有3個, 未來若還有會增加)
zone "world.rickstudio.ru" { type
master; file "dummy-block"; };
zone "juice.losmibracala.org" {
type master; file "dummy-block"; };
zone "web1.51.la" { type master;
file "dummy-block"; };
2. 新增dummy-block檔案
#vi /var/named/chroot/var/named/dummy-block
內容如下(紅色部分請修改為自己學校的內容):
$TTL 24h
@
IN SOA server.xxes.tc.edu.tw. hostmaster.xxes.tc.edu.tw. (2003052800 86400
300 604800 3600 )
@
IN NS server.xxes.tc.edu.tw.
@
IN A 127.0.0.1
*
IN A 127.0.0.1
-----------------------------------------
08-Nov-2013 10:30:52.012 client 163.17.x.y#61440:
query: web1.51.la IN A + (163.17.a.b)
-----------------------------------------
設定防止DNS查詢特殊網域及分析log
臺中市教育網路中心 黃國順
2013/11/12
下面使用
CentOS來示範
軟體:
BIND
1. 修改 named.conf (紅色部分請修改為符合自己學校的內容)
#vi /var/named/chroot/etc/named.conf
1-1.在options 段加入允許遞迴查詢的網段(部分版本較舊的BIND不支援此功能)
options {
allow-recursion {
127.0.0.1/32; 192.168.x.0/24; 140.128.x.0/24; 2001:288:52xx::/48; };
};
1-2. 加入想要阻擋的特殊「網址名稱」(目前有4個, 未來若還有會增加)
zone "world.rickstudio.ru" { type master; file
"dummy-block"; };
zone "juice.losmibracala.org" { type master; file
"dummy-block"; };
zone "web1.51.la" { type master; file "dummy-block";
};
zone "webimg.51.la" { type master; file
"dummy-block"; };
zone "slade.safehousenumber.com" { type master; file
"dummy-block"; };
註: 最後一個test.com是為了測試才加入, 測試後請刪除。
1-3. 為了找出有問題的電腦IP要加入logging段
logging {
channel
default-log {
file "/var/log/default-log"
versions 10 size 20m ;
severity
info;
print-time yes;
};
channel lamer-log
{
file
"/var/log/lamer-log" versions 3 size 10m ;
severity info;
print-severity yes;
print-time yes;
print-category yes;
};
channel query-log
{
file
"/var/log/query-log" versions 10 size 10m ;
severity
info;
print-time yes;
};
channel
security-log {
file
"/var/log/security-log" versions 3
size 1m ;
severity
info;
print-severity yes;
print-time yes;
print-category yes;
};
category
lame-servers { lamer-log; };
category security{
security-log;};
category queries {
query-log;};
category default
{default-log;};
};
2. 新增dummy-block檔案
#vi /var/named/chroot/var/named/dummy-block
內容如下(紅色部分請修改為自己學校的內容):
$TTL 24h
@ IN SOA server.xxes.tc.edu.tw. hostmaster.xxes.tc.edu.tw. (20131110 86400
300 604800 3600 )
@ IN NS
server.xxes.tc.edu.tw.
@ IN A
127.0.0.1
* IN A
127.0.0.1
3. 重新啟動named及測試
#service named restart
#nslookup
>test.com
Name: test.com
Address: 127.0.0.1
若test.com回應為127.0.0.1便是有效了。
4. 查詢是否能正常產生query-log
#ls -la /var/named/chroot/var/log
drwxrwx--- 2 named named 4096 11月 10 22:30 .
drwxr-x--- 6 root
named 4096 9月 9 12:01 ..
-rw-r--r-- 1 named named
887182 11月 10 22:13
default-log
-rw-r--r-- 1 named named
2531058 11月 10 22:36
lamer-log
-rw-r--r--
1 named named 15233110 11月 10 22:38 query-log
-rw-r--r-- 1 named named
2282 11月 10 03:01
security-log
5. 新增分析程式 /root/filter.sh
內容如下
#!/bin/bash
# search_path參數為BIND log存放路徑
search_path=/var/named/chroot/var/log
test -e $search_path/filter-result || touch
$search_path/filter-result
test -e $search_path/filter-result-temp || touch
$search_path/filter-result-temp
for FILENAME in $(find $search_path -mmin -10 -name 'query-*'
-print | sed 's/^\.\///'); do
IFS=","
export IFS;
#要過濾的特殊網址請加在words參數中, 並以「,」隔開
words="juice.losmibracala.org,web1.51.la,world.rickstudio.ru,webimg.51.la,slade.safehousenumber.com"
# echo $FILENAME
for word in $words; do
grep $word $FILENAME
>> $search_path/filter-result-temp
done
done
sort $search_path/filter-result-temp >
$search_path/filter-result-temp2
mv $search_path/filter-result-temp2
$search_path/filter-result-temp
comm -2 -3 $search_path/filter-result-temp $search_path/filter-result >
$search_path/filter-result-mail
cat $search_path/filter-result-mail >>
$search_path/filter-result
rm -f $search_path/filter-result-temp
6. 設定filter.sh具有執行權並測試
#chmod +x filter.sh
#/root/filter.sh
7. 查看過濾結果filter-result
#cat /var/named/chroot/var/log/filter-result
內容格式如下:

這樣我們就可以找出有問題的IP了: 163.17.x.y
8. 設定 crontab 每10分鐘定時執行filter.sh一次
#crontab -e
加入下面這一行
*/10 * * * * /root/filter.sh
2012年10月17日 星期三
台中市IPv6 DNS反解設定--Bind9 次要群組 [網際技術::IPv6]
台中市IPv6 DNS反解設定--Bind9
台中市的IPv6 反解已於4/1全部設定完畢,學校端只要依照下面的範例設定即可設定IPv6的反解,接下來以豐南國中作為設定的範例:
豐南國中設定參數: name server(NS): dns.fnjh.tc.edu.tw. manager email: admin.dns.fnjh.tc.edu.tw. IPv6 網段: 2001:288:542F::/48 反解區域: F.2.4.5.8.8.2.0.1.0.0.2.ip6.arpa |
zone "F.2.4.5.8.8.2.0.1.0.0.2.ip6.arpa" { type master; file "../master/2001.288.542F.rev"; }; |
2001.288.542F.rev 內容為:
$ttl 38400 @ IN SOA dns.fnjh.tc.edu.tw. admin.dns.fnjh.tc.edu.tw. ( 1165291452 10800 3600 604800 38400 ) @ IN NS dns.fnjh.tc.edu.tw. ; 2001:288:542F:0:0:0:0:X $ORIGIN 0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.F.2.4.5.8.8.2.0.1.0.0.2.ip6.arpa. 1.0.0.0 IN PTR dns.fnjh.tc.edu.tw. ; 以下學校依自己狀況設定 2.0.0.0 IN PTR www.fnjh.tc.edu.tw. 0.1.0.0 IN PTR rest.fnkj.tc.edu.tw. |
# dig -x 2001:288:542F::1
; <<>> DiG 9.3.6-P1-RedHat-9.3.6-4.P1.el5 <<>> -x 2001:288:542F::1
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 30073
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 1
;; QUESTION SECTION:
;1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.f.2.4.5.8.8.2.0.1.0.0.2.ip6.arpa. IN PTR
;; ANSWER SECTION:
1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.f.2.4.5.8.8.2.0.1.0.0.2.ip6.arpa. 38400 IN PTR dns.fnjh.tc.edu.tw.
;; AUTHORITY SECTION:
f.2.4.5.8.8.2.0.1.0.0.2.ip6.arpa. 38400 IN NS dns.fnjh.tc.edu.tw.
;; ADDITIONAL SECTION:
dns.fnjh.tc.edu.tw. 15918 IN A 163.17.43.1
;; Query time: 3 msec
;; SERVER: 163.17.40.3#53(163.17.40.3)
;; WHEN: Mon Apr 9 10:28:09 2012
;; MSG SIZE rcvd: 152
如果看到 ANSWER 有顯示正確的內容,代表設定正確了!
2012年1月17日 星期二
單純的 cache-only DNS 伺服器與 forwarding 功能
19.3.3 單純的 cache-only DNS 伺服器與 forwarding 功能
在下一小節開始介紹正、反解 zone 的資料設定之前,在這個小節當中,我們先來談一個單純修改設定檔,而不必設計 zone file 的環境,那就是不具有自己正反解 zone 的僅進行快取的 DNS 伺服器。
那如果連 . 都不想要呢?那就得要指定一個上層 DNS 伺服器作為你的 forwarding (轉遞) 目標,將原本自己要往 . 查詢的任務,丟給上層 DNS 伺服器去煩惱即可。 如此一來,我們這部具有 forwarding 功能的 DNS 伺服器,甚至連 . 都不需要了!因為 . 有記錄在上層 DNS 上頭了嘛!
如同剛剛提到的,cache only 的 DNS 並不存在資料庫 (其實還是存在 . 這個 root 領域的 zone file), 因此不論是誰來查詢資料,這部 DNS 一律開始從自己的快取以及 . 找起,整個流程與圖 19.1-4 相同。那如果具有 forwarding 功能呢?果真如此,那即使你的 DNS 具有 . 這個 zone file,這部 DNS 還是會將查詢權『委請』上層 DNS 查詢的,這部 DNS 伺服器當場變成用戶端啦!查詢流程會變這樣喔:

圖 19.3-1、具有 forwarding 功能的 DNS 伺服器查詢方式
觀察上圖的查詢方向,你會發現到,具有 forwarding 機制時,查詢權會委請上層 DNS 伺服器來處理,所以根本也不需要 .
這個位置所在的 zone 啦。一般來說,如果你的環境需要架設一個 cache-only 的 DNS 伺服器時,其實可以直接加上
forwarding 的機制,讓查詢權指向上層或者是流量較大的上層 DNS 伺服器即可。那既然 cache only 的伺服器並沒有資料庫,
forwarding 機制甚至不需要 . 的 zone ,那幹嘛還得要架設這樣的 DNS 呢?是有理由的啦!
這是什麼意思呢?很簡單啊!就是你自己利用自己的防火牆主機上的 DNS 服務去幫你的 Client 端解譯 hostname <--> IP 囉!因為防火牆主機可以設定放行自己的 DNS 功能,而 Client 端就設定該防火牆 IP 為 DNS 伺服器的 IP 即可!哈哈!這樣就可以取得主機名稱與 IP 的轉譯啦!所以,通常架設 cache only DNS 伺服器大都是為了系統安全囉。
在下一小節開始介紹正、反解 zone 的資料設定之前,在這個小節當中,我們先來談一個單純修改設定檔,而不必設計 zone file 的環境,那就是不具有自己正反解 zone 的僅進行快取的 DNS 伺服器。
什麼是 cache-only 與 forwarding DNS 伺服器呢?
那如果連 . 都不想要呢?那就得要指定一個上層 DNS 伺服器作為你的 forwarding (轉遞) 目標,將原本自己要往 . 查詢的任務,丟給上層 DNS 伺服器去煩惱即可。 如此一來,我們這部具有 forwarding 功能的 DNS 伺服器,甚至連 . 都不需要了!因為 . 有記錄在上層 DNS 上頭了嘛!
如同剛剛提到的,cache only 的 DNS 並不存在資料庫 (其實還是存在 . 這個 root 領域的 zone file), 因此不論是誰來查詢資料,這部 DNS 一律開始從自己的快取以及 . 找起,整個流程與圖 19.1-4 相同。那如果具有 forwarding 功能呢?果真如此,那即使你的 DNS 具有 . 這個 zone file,這部 DNS 還是會將查詢權『委請』上層 DNS 查詢的,這部 DNS 伺服器當場變成用戶端啦!查詢流程會變這樣喔:
圖 19.3-1、具有 forwarding 功能的 DNS 伺服器查詢方式
什麼時候有架設 cache-only DNS 的需求?
這是什麼意思呢?很簡單啊!就是你自己利用自己的防火牆主機上的 DNS 服務去幫你的 Client 端解譯 hostname <--> IP 囉!因為防火牆主機可以設定放行自己的 DNS 功能,而 Client 端就設定該防火牆 IP 為 DNS 伺服器的 IP 即可!哈哈!這樣就可以取得主機名稱與 IP 的轉譯啦!所以,通常架設 cache only DNS 伺服器大都是為了系統安全囉。
實際設定 cache-only DNS server
編輯主要設定檔: /etc/named.conf
雖然我們具有 chroot 的環境,不過由於 CentOS 6.x 已經透過啟動腳本幫我們進行檔案與目錄的掛載連結,所以請你直接修改 /etc/named.conf 即可呦!不要再去 /var/named/chroot/etc/named.conf 修改啦! 在這個檔案中,主要是定義跟伺服器環境有關的設定,以及各個 zone 的領域及資料庫所在檔名。 在鳥哥的這個案例當中,因為使用了 forwarding 的機制,所以這個 cache-only DNS 伺服器並沒有 zone (連 . 都沒有),所以我們只要設定好跟伺服器有關的設定即可。設定這個檔案的時候請注意:
- 註解資料是放置在兩條斜線『 // 』後面接的資料
- 每個段落之後都需要以分號『 ; 』來做為結尾!
鳥哥將這個檔案再簡化如下的樣式:
[root@www ~]# cp /etc/named.conf /etc/named.conf.raw [root@www ~]# vim /etc/named.conf // 在預設的情況下,這個檔案會去讀取 /etc/named.rfc1912.zones 這個領域定義檔 // 所以請記得要修改成底下的樣式啊! options { listen-on port 53 { any; }; //可不設定,代表全部接受 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; }; //可不設定,代表全部接受 recursion yes; //將自己視為用戶端的一種查詢模式 forward only; //可暫時不設定 forwarders { //是重點! 168.95.1.1; //先用中華電信的 DNS 當上層 139.175.10.20; //再用 seednet 當上層 }; }; //最終記得要結尾符號!
- listen-on port 53 { any; };
監聽在這部主機系統上面的哪個網路介面。預設是監聽在 localhost,亦即只有本機可以對 DNS 服務進行查詢,那當然是很不合理啊! 所以這裡要將大括號內的資料改寫成 any。記得,因為可以監聽多個介面,因此 any 後面得要加上分號才算結束喔! 另外,這個項目如果忘記寫也沒有關係,因為預設是對整個主機系統的所有介面進行監聽的。
- directory "/var/named";
意思是說,如果此檔案底下有規範到正、反解的 zone file 檔名時,該檔名預設應該放置在哪個目錄底下的意思。預設放置到 /var/named/ 底下。由於 chroot 的關係,最終這些資料庫檔案會被主動連結到 /var/named/chroot/var/named/ 這個目錄。
- dump-file, statistics-file, memstatistics-file
與 named 這個服務有關的許多統計資訊,如果想要輸出成為檔案的話,預設的檔名就如上所述。鳥哥自己很少看這些統計資料, 所以,這三個設定值寫不寫應該都是沒有關係的。
- allow-query { any; };
這個是針對用戶端的設定,到底誰可以對我的 DNS 服務提出查詢請求的意思。原本的檔案內容預設是針對 localhost 開放而已, 我們這裡改成對所有的用戶開放 (當然啦,防火牆也得放行才行)。不過,預設 DNS 就是對所有用戶放行,所以這個設定值也可以不用寫。
- forward only ;
這個設定可以讓你的 DNS 伺服器僅進行 forward,即使有 . 這個 zone file 的設定,也不會使用 . 的資料, 只會將查詢權交給上層 DNS 伺服器而已,是 cache only DNS 最常見的設定了!
- forwarders { 168.95.1.1; 139.175.10.20; } ;
既然有 forward only,那麼到底要對哪部上層 DNS 伺服器進行轉遞呢?那就是 forwarders (不要忘記那個 s) 設定值的重要性了!由於擔心上層 DNS 伺服器也可能會掛點,因此可以設定多部上層 DNS 伺服器喔!每一個 forwarder 伺服器的 IP 都需要有『 ; 』來做為結尾!
很簡單吧!至於更多的參數我們會在後續篇幅當中慢慢介紹的。這樣就已經設定完成了最簡單的 cache only DNS server 了!
啟動 named 並觀察服務的埠口
啟動總不會忘記吧?趕快去啟動一下吧!同時啟動完畢之後,觀察一下由 named 所開啟的埠口,看看到底哪些埠口會被 DNS 用到的!
# 1. 啟動一下 DNS 這玩意兒! [root@www ~]# /etc/init.d/named start Starting named: [ OK ] [root@www ~]# chkconfig named on # 2. 到底用了多少埠口呢? [root@www ~]# netstat -utlnp | grep named Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 192.168.100.254:53 0.0.0.0:* LISTEN 3140/named tcp 0 0 192.168.1.100:53 0.0.0.0:* LISTEN 3140/named tcp 0 0 127.0.0.1:53 0.0.0.0:* LISTEN 3140/named tcp 0 0 127.0.0.1:953 0.0.0.0:* LISTEN 3140/named tcp 0 0 ::1:953 :::* LISTEN 3140/named udp 0 0 192.168.100.254:53 0.0.0.0:* 3140/named udp 0 0 192.168.1.100:53 0.0.0.0:* 3140/named udp 0 0 127.0.0.1:53 0.0.0.0:* 3140/named
檢查 /var/log/messages 的內容訊息 (極重要!)
named 這個服務的記錄檔就直接給他放置在 /var/log/messages 裡面啦,所以來看看裡面的幾行登錄資訊吧!
[root@www ~]# tail -n 30 /var/log/messages | grep named Aug 4 14:57:09 www named[3140]: starting BIND 9.7.0-P2-RedHat-9.7.0-5.P2.el6_0.1 -u named -t /var/named/chroot <==說明的是 chroot 在哪個目錄下! Aug 4 14:57:09 www named[3140]: adjusted limit on open files from 1024 to 1048576 Aug 4 14:57:09 www named[3140]: found 1 CPU, using 1 worker thread Aug 4 14:57:09 www named[3140]: using up to 4096 sockets Aug 4 14:57:09 www named[3140]: loading configuration from '/etc/named.conf' Aug 4 14:57:09 www named[3140]: using default UDP/IPv4 port range: [1024, 65535] Aug 4 14:57:09 www named[3140]: using default UDP/IPv6 port range: [1024, 65535] Aug 4 14:57:09 www named[3140]: listening on IPv4 interface lo, 127.0.0.1#53 Aug 4 14:57:09 www named[3140]: listening on IPv4 interface eth0, 192.168.1.100#53 Aug 4 14:57:09 www named[3140]: listening on IPv4 interface eth1, 192.168.100.254#53 Aug 4 14:57:09 www named[3140]: generating session key for dynamic DNS Aug 4 14:57:09 www named[3140]: command channel listening on 127.0.0.1#953 Aug 4 14:57:09 www named[3140]: command channel listening on ::1#953 Aug 4 14:57:09 www named[3140]: the working directory is not writable Aug 4 14:57:09 www named[3140]: running
Tips:
如果你在 /var/log/messages 裡面一直看到這樣的錯誤資訊:
couldn't add command channel 127.0.0.1#953: not found
那表示你還必需要加入 rndc key ,請參考本章後面的 利用 RNDC 指令管理 DNS 伺服器 的介紹,將他加入你的 named.conf 中!
測試:
如果你的 DNS 伺服器具有連上網際網路的功能,那麼透過『 dig www.google.com @127.0.0.1 』這個基本指令執行看看, 如果有找到 google 的 IP ,並且輸出資料的最底下顯示『 SERVER: 127.0.0.1#53(127.0.0.1) 』的字樣, 那就代表應該是成功啦!其他更詳細的測試請參考:19.2 小節的內容
BIND9 – Master / Slave DNS 基本設定備忘
- named.conf 重點內容
- Slave 主機向 Master 要求傳送 Zone File 的時機
- Zone File 檔案結構
named.conf 重點內容
Master:Slave 主機向 Master 要求傳送 Zone File 的時機
vi /etc/named.confSlave:
acl “trusted” { 127.0.0.1; 192.168.1.0/24; };
options {
allow-recursion { trusted; }; //避免變成 Open DNS};
allow-transfer { none; }; //預設禁止 Zone Transfer
notify no; //預設不通知轄區 DNS Server
zone “mydomain.com” in {
type master;};
file “mydomain.com.zone”;
allow-transfer { slave.ip.address; };
notify yes;
zone “1.168.192.in-addr.arpa” in {
type master;};
file “192.168.1.zone”;
allow-transfer { slave.ip.address; };
notify yes;
vi /etc/named.conf
zone “mydomain.com” in {
type slave;};
file “slave/mydomain.com.zone”;
masters { master.ip.address; };
zone “1.168.192.in-addr.arpa” in {
type slave;};
file “slave/192.168.1.zone”;
masters { master.ip.address; };
- master 主機上的 named 啟動、Reload 時, 發送 dns notify 信號通知 NS 主機 (除本身外) 比對 zone file serial, 且 master serial 大於 slave serial 時.
- slave 主機上的 named 啟動時, 發現 master serial 大於 slave serial, 或無 zone file 存在時.
- slave 主機每隔 refresh 時間, 向 master 查詢 zone file serial, 發現 master serial 大於 slave serial 時.
Forward Lookup / 正解Resources:
Reverse Lookup / 反解
$TTL 1W @ IN SOA master_dns_fqdn zone_admin ( 2006092001 ;serial 2D ;refresh 4H ;retry 6W ;expire 1W ) ;TTL IN NS master_dns_fqdn IN NS slave_dns_fqdn IN MX 10 mail_server_fqdn master_dns_hostname IN A ip_address slave_dns_hostname IN A ip_address mail_server_hostname IN A ip_address some_hostname IN CNAME another_hostname_has_A_record
Ref: Microsoft Support – Description of DNS Reverse Lookups
$TTL 1W @ IN SOA master_dns_fqdn zone_admin ( 2006092001 ;serial 2D ;refresh 4H ;retry 6W ;expire 1W ) ;TTL IN NS master_dns_fqdn entry_in_*.in-addr.arpa IN PTR some_host_fqdn
ex1. zone: 20.10.150.in-addr.arpa
in the zone file: 1 IN PTR ms1.mydomain.com
retult: ms1.mydomain.com=150.10.20.1ex2. zone: 10.150.in-addr.arpa
in the zone file: 2.20 IN PTR ms1.mydomain.com
retult: ms1.mydomain.com=150.10.20.2
Root Domain Zone File: ftp://ftp.internic.net/domain/named.root
- BIND Official Website
- PHP5 網管實驗室 – 於 Fedora Core 上的 bind 設定
- 鳥哥的 Linux 私房菜 – 簡易 DNS 伺服器設定
- Study Area – 架設 DNS
您还可能感兴趣的内容
2012年1月16日 星期一
bind 9設定
【CentOS】 bind9-提供Domain Name與IP對應的服務
鳥哥的 Linux 私房菜
第十九章、主機名稱控制者: DNS 伺服器
1 //
2 // Sample named.conf BIND DNS server 'named' configuration fil e
3 // for the Red Hat BIND distribution.
4 //
5 // See the BIND Administrator's Reference Manual (ARM) for det ails, in:
6 // file:///usr/share/doc/bind-*/arm/Bv9ARM.html
7 // Also see the BIND Configuration GUI : /usr/bin/system-confi g-bind and
8 // its manual.
9 //
10 options
11 {
12 // Those options should be used carefully because they disable port
13 // randomization
14 // query-source port 53;
15 // query-source-v6 port 53;
16
17 // Put files that named is allowed to write in the dat a/ directory:
18 directory "/var/named"; // the default
19 dump-file "data/cache_dump.db";
20 statistics-file "data/named_stats.txt";
21 memstatistics-file "data/named_mem_stats.txt";
22
23 };
24 logging
25 {
26 /* If you want to enable debugging, eg. using the 'rndc t race' command,
27 * named will try to write the 'named.run' file in the $d irectory (/var/named).
28 * By default, SELinux policy does not allow named to mod ify the /var/named directory,
29 * so put the default debug log file in data/ :
30 */
31 channel default_debug {
32 file "data/named.run";
33 severity dynamic;
34 };
35 };
36 //
37 // All BIND 9 zones are in a "view", which allow different zon es to be served
38 // to different types of client addresses, and for options to be set for groups
39 // of zones.
40 //
41 // By default, if named.conf contains no "view" clauses, all z ones are in the
42 // "default" view, which matches all clients.
43 //
44 // If named.conf contains any "view" clause, then all zones MU ST be in a view;
45 // so it is recommended to start off using views to avoid havi ng to restructure
46 // your configuration files in the future.
47 //
48 view "localhost_resolver"
49 {
50 /* This view sets up named to be a localhost resolver ( cachin g only nameserver ).
51 * If all you want is a caching-only nameserver, then you need only define this view:
52 */
53 match-clients { localhost; };
54 match-destinations { localhost; };
55 recursion yes;
56 # all views must contain the root hints zone:
57 include "/etc/named.root.hints";
58
59 /* these are zones that contain definitions for all th e localhost
60 * names and addresses, as recommended in RFC1912 - th ese names should
61 * ONLY be served to localhost clients:
62 */
63 include "/etc/named.rfc1912.zones";
64 };
65 view "internal"
66 {
67 /* This view will contain zones you want to serve only to "int ernal" clients
68 that connect via your directly attached LAN interfaces - "l ocalnets" .
69 */
70 match-clients { localnets; };
71 match-destinations { localnets; };
72 recursion yes;
73 // all views must contain the root hints zone:
74 include "/etc/named.root.hints";
75
76 // include "named.rfc1912.zones";
77 // you should not serve your rfc1912 names to non-loca lhost clients.
78
79 // These are your "authoritative" internal zones, and would probably
80 // also be included in the "localhost_resolver" view a bove :
81
82 zone "my.internal.zone" {
83 type master;
84 file "my.internal.zone.db";
85 };
86 zone "my.slave.internal.zone" {
87 type slave;
88 file "slaves/my.slave.internal.zone.db";
89 masters { /* put master nameserver IPs here */ 127.0.0.1; } ;
90 // put slave zones in the slaves/ directory so named can update them
91 };
92 zone "my.ddns.internal.zone" {
93 type master;
94 allow-update { key ddns_key; };
95 file "slaves/my.ddns.internal.zone.db";
96 // put dynamically updateable zones in the sla ves/ directory so named can update them
97 };
98 };
99 key ddns_key
100 {
101 algorithm hmac-md5;
102 secret "use /usr/sbin/dns-keygen to generate TSIG keys ";
103 };
104 view "external"
105 {
106 /* This view will contain zones you want to serve only to "ext ernal" clients
107 * that have addresses that are not on your directly attached LAN interface subnets:
108 */
109 match-clients { any; };
110 match-destinations { any; };
111
112 recursion no;
113 // you'd probably want to deny recursion to external c lients, so you don't
114 // end up providing free DNS service to all takers
115
116 allow-query-cache { none; };
117 // Disable lookups for any cached data and root hints
118
119 // all views must contain the root hints zone:
120 include "/etc/named.root.hints";
121
122 // These are your "authoritative" external zones, and would probably
123 // contain entries for just your web and mail servers:
124
125 zone "my.external.zone" {
126 type master;
127 file "my.external.zone.db";
128 };
129 };
----------------------------------
鳥哥的 Linux 私房菜
第十九章、主機名稱控制者: DNS 伺服器
DNS BIND 安裝設定
http://ipv6.tcc.edu.tw/
相關文件:
1 //
2 // Sample named.conf BIND DNS server 'named' configuration fil e
3 // for the Red Hat BIND distribution.
4 //
5 // See the BIND Administrator's Reference Manual (ARM) for det ails, in:
6 // file:///usr/share/doc/bind-*/arm/Bv9ARM.html
7 // Also see the BIND Configuration GUI : /usr/bin/system-confi g-bind and
8 // its manual.
9 //
10 options
11 {
12 // Those options should be used carefully because they disable port
13 // randomization
14 // query-source port 53;
15 // query-source-v6 port 53;
16
17 // Put files that named is allowed to write in the dat a/ directory:
18 directory "/var/named"; // the default
19 dump-file "data/cache_dump.db";
20 statistics-file "data/named_stats.txt";
21 memstatistics-file "data/named_mem_stats.txt";
22
23 };
24 logging
25 {
26 /* If you want to enable debugging, eg. using the 'rndc t race' command,
27 * named will try to write the 'named.run' file in the $d irectory (/var/named).
28 * By default, SELinux policy does not allow named to mod ify the /var/named directory,
29 * so put the default debug log file in data/ :
30 */
31 channel default_debug {
32 file "data/named.run";
33 severity dynamic;
34 };
35 };
36 //
37 // All BIND 9 zones are in a "view", which allow different zon es to be served
38 // to different types of client addresses, and for options to be set for groups
39 // of zones.
40 //
41 // By default, if named.conf contains no "view" clauses, all z ones are in the
42 // "default" view, which matches all clients.
43 //
44 // If named.conf contains any "view" clause, then all zones MU ST be in a view;
45 // so it is recommended to start off using views to avoid havi ng to restructure
46 // your configuration files in the future.
47 //
48 view "localhost_resolver"
49 {
50 /* This view sets up named to be a localhost resolver ( cachin g only nameserver ).
51 * If all you want is a caching-only nameserver, then you need only define this view:
52 */
53 match-clients { localhost; };
54 match-destinations { localhost; };
55 recursion yes;
56 # all views must contain the root hints zone:
57 include "/etc/named.root.hints";
58
59 /* these are zones that contain definitions for all th e localhost
60 * names and addresses, as recommended in RFC1912 - th ese names should
61 * ONLY be served to localhost clients:
62 */
63 include "/etc/named.rfc1912.zones";
64 };
65 view "internal"
66 {
67 /* This view will contain zones you want to serve only to "int ernal" clients
68 that connect via your directly attached LAN interfaces - "l ocalnets" .
69 */
70 match-clients { localnets; };
71 match-destinations { localnets; };
72 recursion yes;
73 // all views must contain the root hints zone:
74 include "/etc/named.root.hints";
75
76 // include "named.rfc1912.zones";
77 // you should not serve your rfc1912 names to non-loca lhost clients.
78
79 // These are your "authoritative" internal zones, and would probably
80 // also be included in the "localhost_resolver" view a bove :
81
82 zone "my.internal.zone" {
83 type master;
84 file "my.internal.zone.db";
85 };
86 zone "my.slave.internal.zone" {
87 type slave;
88 file "slaves/my.slave.internal.zone.db";
89 masters { /* put master nameserver IPs here */ 127.0.0.1; } ;
90 // put slave zones in the slaves/ directory so named can update them
91 };
92 zone "my.ddns.internal.zone" {
93 type master;
94 allow-update { key ddns_key; };
95 file "slaves/my.ddns.internal.zone.db";
96 // put dynamically updateable zones in the sla ves/ directory so named can update them
97 };
98 };
99 key ddns_key
100 {
101 algorithm hmac-md5;
102 secret "use /usr/sbin/dns-keygen to generate TSIG keys ";
103 };
104 view "external"
105 {
106 /* This view will contain zones you want to serve only to "ext ernal" clients
107 * that have addresses that are not on your directly attached LAN interface subnets:
108 */
109 match-clients { any; };
110 match-destinations { any; };
111
112 recursion no;
113 // you'd probably want to deny recursion to external c lients, so you don't
114 // end up providing free DNS service to all takers
115
116 allow-query-cache { none; };
117 // Disable lookups for any cached data and root hints
118
119 // all views must contain the root hints zone:
120 include "/etc/named.root.hints";
121
122 // These are your "authoritative" external zones, and would probably
123 // contain entries for just your web and mail servers:
124
125 zone "my.external.zone" {
126 type master;
127 file "my.external.zone.db";
128 };
129 };
----------------------------------
訂閱:
文章 (Atom)