茫茫網海中的冷日
         
茫茫網海中的冷日
發生過的事,不可能遺忘,只是想不起來而已!
 恭喜您是本站第 1670172 位訪客!  登入  | 註冊
主選單

Google 自訂搜尋

Goole 廣告

隨機相片
IMG_60D_00232.jpg

授權條款

使用者登入
使用者名稱:

密碼:


忘了密碼?

現在就註冊!

小企鵝開談 : [轉貼]如何避免DNS主機被當成攻擊跳板

發表者 討論內容
冷日
(冷日)
Webmaster
  • 註冊日: 2008/2/19
  • 來自:
  • 發表數: 15771
[轉貼]如何避免DNS主機被當成攻擊跳板

如何避免DNS主機被當成攻擊跳板

作者:郭幸香 / 臺灣大學計算機及資訊網路中心網路組研究助理

近期校園內出現大量對外的DNS response流量,經分析後發現為最近熱門的DDoS攻擊「DNS放大(反射)攻擊」。校園內的電腦或伺服器由於設定不良,導致被利用當成跳板來攻擊網際網路上的其它主機,本文將介紹如何檢測與設定DNS服務,以防止被利用來當成跳板來攻擊網際網路上的其它主機,提高資訊安全。

緣由
近期校園內出現大量對外的DNS response流量,經分析後發現為DDoS攻擊「DNS放大(反射)攻擊」。校園內的電腦或伺服器由於設定不良,導致被利用當成跳板來攻擊網際網路上的其它主機。

DNS放大(反射)攻擊簡介
攻擊者(Attacker or Zombie)將DNS查詢封包中的Source IP偽造成Victim IP,向設定不良之Open DNS server送出大量查詢封包(small packet size),DNS server則會將大量查詢結果(big packet size)傳到Victim IP,以DDoS的方式癱瘓受害者的網路資源與主機資源。2013年三月歐洲反垃圾郵件組織Spamhaus即是遭此DDoS攻擊,攻擊流量高達300Gbps,成為目前為止最嚴重的一次DDoS攻擊。


 

您管理的主機可能被利用當成跳板的原因
1. 您的主機安裝的某個套件軟體有開啟DNS服務。
2. 該主機為貴單位授權的DNS伺服器,但未設定良好的存取權限。
3. 您的主機可能已被入侵,並安裝惡意軟體與開啟DNS服務。

如何檢測您管理的主機是否有開啟DNS服務
1. 在待查主機的本機使用netstat指令檢測

I. 在Linux環境下

● 開啟Terminal
● 在游標處輸入netstat -an
● 觀察主機是否有開啟UDP 53 port(請參考圖1)

II. 在Windows環境下
● 滑鼠左鍵點選桌面左下角「開始」
● 滑鼠左鍵點選「所有程式」
● 滑鼠左鍵點選「附屬應用程式」
● 滑鼠左鍵點選「開啟命令提示字元」
● 在游標處輸入netstat –an
● 觀察主機是否有開啟UDP 53 port(請參考圖1)


圖1.Netstat查詢範例

2. 從其它主機使用nslookup指令對待查主機做查詢

I. 在Linux環境下
● 開啟Terminal
● 在游標處輸入nslookup
● 在游標處輸入server 待查主機IP,暫時將DNS查詢主機轉至待查主機
● 在游標處輸入欲查詢的網域,例如:www.google.com
● 察待查主機是否有回應該網域的資訊
  圖2.表示此IP未提供DNS查詢服務或有設定recursive query存取權限
  圖3.表示此IP有提供DNS查詢服務

II. 在Windows環境下
● 滑鼠左鍵點選桌面左下角「開始」
● 滑鼠左鍵點選「所有程式」
● 滑鼠左鍵點選「附屬應用程式」
● 滑鼠左鍵點選「開啟命令提示字元」
● 在游標處輸入nslookup
● 在游標處輸入server 待查主機IP,暫時將DNS查詢主機轉至待查主機

● 在游標處輸入欲查詢的網域,例如:www.google.com
● 觀察待查主機是否有回應該網域的資訊
  圖2.表示此IP未提供DNS查詢服務或有設定recursive query存取權限
  圖3.表示此IP有提供DNS查詢服務


圖2.此IP未提供DNS查詢服務或有設定recursive query存取權限


圖3. 此IP有提供DNS查詢服務

以BIND為例設定DNS存取權限
1. Berkeley Internet Name Domain (BIND),最初由加州大學柏克萊分校發展出的DNS伺服器軟體,由於它可提供穩定且強大的名稱服務,因此被廣泛使用,目前由ISC組織負責維護與發展。
2. 在BIND版本9.5之前,recursion的功能是預設開啟的,故管理者必須自行關閉此功能或設定適當的存取權限。
3. 以下為BIND的組態設定檔name.conf的建議設定

// 定義一個ACL,設定能存取DNS服務的IP範圍
// 此例為台大的網段140.112.0.0/16,可自行調整為貴單位的
// 網段
Acl "allowed-IP"{
140.112.0.0/16;
};

// 僅允許符合ACL設定的網段進行recursive query
Options {
……
Allow-recursion { allowed-IP; };
……
};


//提供貴單位管轄下的網域給其它DNS查詢
zone "貴單位網域.ntu.edu.tw" in {
……
allow-query { any; };
……
};


4. 更多詳細的設定步驟可參考 BIND 9.5 Administrator Reference Manual

結語
1. 建議各系所網管檢查並關閉不必要的DNS服務。
2. 建議各系所可將其DNS服務轉移至計中由專人管理,網管們可以在計中的DNS伺服器上管理各自的網域。
3. 如各系所的DNS服務仍需要獨立運作,請在貴單位DNS伺服器上設定 ACL,僅讓授權的網域能使用貴單位的 DNS recursive query 的服務。


原文出處: 如何避免DNS主機被當成攻擊跳板
冷日
(冷日)
Webmaster
  • 註冊日: 2008/2/19
  • 來自:
  • 發表數: 15771
[轉貼]關於DNS的遞迴查詢攻擊與防護
最近有許多學校的DNS遭到了攻擊,全都是因為沒有限制遞迴查詢,導致外面的IP也可以使用學校的DNS進行遞迴查詢,產生大量的查詢封包,攻擊者只要利用沒有限制遞迴查詢的學校DNS,去查詢一個網域,就足以產生大量的名稱解析

這次受攻擊的SERVER為Centos與舊版B2D(jacana) ,全都是未加入限制查詢的設定

若你使用miniserver或OB2D,那麼預設是有加入的(使用 acl allow_clients { …. }; view “recursive” { …. };來限制),可以放心

Linux限制遞迴查詢:
若你的系統是Centos或舊版B2D:

B2D:請檢查你的/etc/bind/named.conf
CentOS:請檢查你的/var/named/chroot/etc/named.conf

於 options{ …. };中,加入
------------------------------------------------------------------------------
allow-recursion { 127.0.0.1/32; 120.116.126.0/24(學校網段); 2001:288:759d::/48; };
------------------------------------------------------------------------------

以上是範例,請勿照抄m(_ _)m,請將學校網段改成學校的IPv4與IPv6

清除查詢快取:
rndc flush


重新啟動dns
B2D:
service bind9 restart

CentOS:
service named restart


windows server:關閉遞迴查詢

注意:Windows的DNS服務並沒有辦法像Linux上Bind(DNS服務)做允許遞迴查詢來源限制,

此時勾選不允許遞迴查詢限制時,學校電腦的DNS解析伺服器若指定該Windows DNS伺服

器IP,會造無法連線google ,yahoo等網站問題,主要是此時的DNS伺服器只負責解析自己管理的網域,解決方式就是更改主機的DNS伺服器IP設定,可參考使用下列DNS伺服器IP:

中心DNS伺服器: 163.26.1.1 , 163.26.1.26 , 163.26.200.1 , 163.26.200.2

Hinet DNS伺服器:168.95.1.1, 168.95.192.1

處理後的狀況
案例:後壁國中(CentOS)與柳營國小(B2D)
後壁國中
9/1

9/4(關閉遞迴查詢後)dns查詢量雖減少,但查詢的殭屍電腦仍不斷查詢

9/10(以iptables drop ANY的查詢後)

柳營國小
9/1

9/4(關閉遞迴查詢後)

9/10(以iptables drop ANY的查詢後)

以下是我的處理流程
(攻擊查詢變成fkfkfkfz.guru)

雖於於9/2日,關閉遞迴查詢,dns查詢量已經大幅減少,後續觀察,這些『殭屍電腦』還是緊咬不放,而有大量的deny紀錄,讓log檔案快速增長
log有一大堆的莫名其妙的dns ANY query 被 denied

計算一下查詢的次數
(9/7)

9925540筆的deny查詢
(9/8)

10656799筆的deny查詢
(9/9)

6005641筆的deny查詢

雖然這些查詢被deny,但是持續不斷,真如殭屍一般,對系統造成不小的壓力,所以,根據之前log的特徵值,以iptables進行封檔

iptables -t raw -A PREROUTING -p udp --dport 53 -m string --algo bm --hex-string "|0000ff0001|" -j DROP

封擋掉吧,不然 messages的log會變很大

2.8G的檔案中,光從fkfkfkfz.guru的ANY查詢就達到2.6G

使用此iptables來deny ANY的查詢,可以立刻阻斷這些殭屍電腦的攻擊,並且也就不會紀錄相關log,可以讓你的系統負擔瞬間降低

測試:
ANY 查詢
dig @120.116.96.1 fkfkfkfz.guru ANY

-> 會被drop

一般查詢
dig @120.116.96.1 fkfkfkfz.guru

; <<>> DiG 9.9.5-3-Ubuntu <<>> @120.116.96.1 fkfkfkfz.guru
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: REFUSED, id: 17042
;; flags: qr rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1
;; WARNING: recursion requested but not available

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;fkfkfkfz.guru.            IN    A

;; Query time: 3 msec
;; SERVER: 120.116.96.1#53(120.116.96.1)
;; WHEN: Tue Sep 09 15:57:03 CST 2014
;; MSG SIZE  rcvd: 42

B2D的bind版本較舊,需使用iptables drop ANY的查詢

柳營國小dns攻擊紀錄:
Sep 09 11:25:15.234 queries: info: client 179.99.159.137#10559: query: fkfkfkfz.guru IN ANY
Sep 09 11:25:15.237 queries: info: client 179.99.159.137#49217: query: fkfkfkfz.guru IN ANY
Sep 09 11:25:15.244 queries: info: client 179.99.159.137#57063: query: fkfkfkfz.guru IN ANY
Sep 09 11:25:15.245 queries: info: client 189.79.40.16#1364: query: fkfkfkfz.guru IN ANY
Sep 09 11:25:15.245 queries: info: client 179.99.159.137#24150: query: fkfkfkfz.guru IN ANY
Sep 09 11:25:15.246 queries: info: client 179.99.159.137#4834: query: fkfkfkfz.guru IN ANY
Sep 09 11:25:15.257 queries: info: client 179.99.159.137#47927: query: fkfkfkfz.guru IN ANY
Sep 09 11:25:15.266 queries: info: client 179.99.159.137#23960: query: fkfkfkfz.guru IN ANY
Sep 09 11:25:15.274 queries: info: client 179.99.159.137#18024: query: fkfkfkfz.guru IN ANY
Sep 09 11:25:15.285 queries: info: client 189.79.40.16#63803: query: fkfkfkfz.guru IN ANY
Sep 09 11:25:15.285 queries: info: client 189.79.40.16#36168: query: fkfkfkfz.guru IN ANY
Sep 09 11:25:15.305 queries: info: client 189.79.40.16#47455: query: fkfkfkfz.guru IN ANY
Sep 09 11:25:15.306 queries: info: client 189.79.40.16#55162: query: fkfkfkfz.guru IN ANY
Sep 09 11:25:15.306 queries: info: client 189.79.40.16#36751: query: fkfkfkfz.guru IN ANY
Sep 09 11:25:15.321 queries: info: client 189.79.40.16#51238: query: fkfkfkfz.guru IN ANY
Sep 09 11:25:15.356 queries: info: client 179.99.159.137#42087: query: fkfkfkfz.guru IN ANY
Sep 09 11:25:15.356 queries: info: client 179.99.159.137#25743: query: fkfkfkfz.guru IN ANY

另外,作一個錯誤的zone
cd /etc/bind/
vi bad-domain
-------------------------------
$TTL 86400
@    IN    SOA    dns.lyes.tn.edu.tw.    admin.dns.lyes.tn.edu.tw. (
            2000082619     ; serial
            86400         ; refresh
            1800         ; retry
            1728000     ; expirei
            1200         ;native cache
            )
;      IN    NS    dns.lyes.tn.edu.tw.
;*    IN    A    127.0.0.1
------------------------------


vi auth_zones.conf
--------------------------------
zone "fkfkfkfz.guru" {
 type master;
 file "bad-domain";
 allow-update { none; };
};
--------------------------------

service bind9 restart

參考網站:
http://pank.org/blog/2012/08/block-dns-query-type-any.html
http://blogger.micloud.tw/2013/05/what-is-dns.html

原文出處:關於DNS的遞迴查詢攻擊與防護
冷日
(冷日)
Webmaster
  • 註冊日: 2008/2/19
  • 來自:
  • 發表數: 15771
[轉貼]DNS 服務,你對於 DNS 懂多少?

DNS 服務,你對於 DNS 懂多少?

DNS 安全性,開發者必知


DNS - Domain Name System,簡單的說,在網際網路上的各式主機不論IPv4或IPv6均以IP位置為識別,而DNS就是提供網際網路上IP與名稱對應的一套系統,提供大家可以透過好記的名稱來找得到服務提供主機的一個方式,後面將會從自己經驗分享 DNS 安全性問題,以及 DNS 的基本保護方式, 當然『安全』從你我開始


先了解...




了解DNS之前,有些專有名詞需要再重新了解一下...


  • IP位置 - 一個識別網際網路上唯一存在的ID,要提供服務的主機都需要有對應到網路上可存取的一個IP位置,相當於一個入口,讓我們可以訪問需要的服務。
  • 協定(Protocol) - 可以想像成馬路的分類,可以給機車走的、單車走的、汽車走的、大卡車走的都不一樣,同樣的,網際網路上有HTTP走的、HTTPS走的、FTP走的...都是一些溝通的協定,背後也有自己的一個溝通的定義。
  • 網域名稱(Domain Name) - 代表著一個或一組IP位置的名稱,使用網際網路的使用者可以透過這個名稱找到相對應的伺服器存取服務。

  • 網址(URI / URL) - 一般我們稱的網址 = 協定+網域名稱+資源位置,類似: http://www.google.com/drive就是個網址的實例,我們透過他來存取對應的資源。


簡述DNS的運作原理



一般使用者了解到IP的機制後,大致上想得到每次網址列打上網址(就是domain name),下面一個最簡單的實例,當使用者瀏覽器上打上某個網址時,電腦會解攜出欲訪問的網域名稱,並且透過DNS系統查詢該網域名稱真實的IP位置後,再結合網址的資源位置直接訪問實際資源所在的位置(此時已經定位出實際IP位置,並連線該IP查詢定義位置中的資源)...






圖一、訪問網路資源概念圖



而網際網路上不是只有一台DNS Server,一般私有網路大多自己架設內部的DNS Server,以提供內部查詢使用,作用上,一方面是方便將特定私有往段服務IP定義逾期上,以提供內部使用,另一方面則是透過DNS Cache機制,讓服務的存取可以更加快速。圖二是以內部網路為例,存取網路資源時候DNS查詢的流程,而一般設定DNS時候,都會設定轉查的路徑,例如我信任Google的DNS服務,那我就會設定我的上一層DNS為8.8.8.8或8.8.4.4(此兩個IP為Google的DNS位置),所有超過我這台DNS伺服器所能回答的問題,都將往上詢問上一層DNS Server,由他回答...


圖二、內部DNS服務



而DNS詢問網域名稱的實際過程卻又複雜過圖二所交代的,實際上打上一個網域名稱,則第一層DNS向上詢問不果的時候,DNS server會去詢問該domain的root dns server(一般root dns server會定義在DNS server上),然後由root dns回應該domain是隸屬於哪台DNS server管轄,之後該DNS server就會記住這個對應,日後有該domain的DNS問題就都會詢問這個網域管理的DNS server。而這奇妙的一切,都是設定在DNS server中... 不過這邊不講設定,了解一下概念,如圖三所示:


圖三、DNS的階層是查詢(1)

最後一種情況是當DNS Server有設定子網域的時候,查詢到該網域的所屬DNS server後,該DNS server會轉查子網域負責的DNS server,再將查詢結果IP往上回傳... 圖四是說明這樣狀況的詢問流程:




圖四、DNS的階層是查詢(2)


失守DNS Server的風險


談到這邊,大致上可以猜想得到如果不幸DNS Server掛點,無法提供回應的時候,網路上將會無法解析您服務的真正位置,也就是說服務將會中斷而無法使用... 此時就是考慮IT是否用新備份的時候了,回復一台完整可供查詢的DNS Server將是服務回復的關鍵因素!
而另一個風險... 想像如果DNS server上面的紀錄(一般稱DNS record)被串改,則用戶可能就此連到別的網站去,如果被有心人士利用,則可以作為詐騙的工具...試想如果有人做了一個跟PXHome一樣的交易網站,在交易時候透過偽裝的程式就可以輕易的盜取使用者的交易或個人資料,甚至是信用卡資料,只要偽裝的網站長得一樣,一般人很難察覺... 即使有SSL加密的網站,也很難防範DNS Server被攻陷造成的傷害...

圖五、失守DNS Server示意圖


保護 DNS Server的方式


敝人在下不是網路之才,所學不深,目前了解到防範DNS server被攻擊的幾種情境,主要以DDoS最為麻煩(DNS A buse Attack ),而這些攻擊不外乎是利用大量的查詢來癱瘓DNS Server,有的神級Hacker甚至可以透過攻擊尋得漏洞侵入DNS Server... 而保護DNS server應當要做到:

  • 落實iptables的管理,非服務Port不開放,且DNS Server不要裝其他服務
  • 落實網路節點上的防火牆管理,此點同上,僅是層次上不同
  • 如不需服務大眾,盡可能改為內部存取ONLY (一般設定上可以限制存取網段,可配合iptables做設定)
  • 如不需要,請關閉any查詢 (所耗資源較大)
  • 做好DNS Cluster Group的設定 (避免掛一台而無法提供服務)

而說到保護,在好的保護不如做好完整的備份與還原機制,X戰警的金剛狼就是最好的例子...快速恢復的能力就是王道!能快速復原被攻陷的DNS Server,讓服務快速恢復營運,勝過做100種防護,而此點在目前的Cloud環境上將是最好的演示∼透過類似映象檔備份或是Image的備份,再快速生成主機,恢復服務,就不用再擔心被Hacker攻破啦∼ (PS: 漏洞還是要修啦@@) 這邊提供一個備份的策略給大家參考:

  • 日備份,以git為版本儲存體
  • 每次備份檢核前一份備份(版本)資料,透過diff做差異report
  • 差異部分通知管理者、管理者主管(交叉檢核)
  • 準備好還原機的映象檔及備機

保護用戶端 DNS Server被串改的方式



最後談到,保護用戶端的部份,我想最快的方式就是使用OpenDNS所提供的DNSCrypt工具,讓Client端跟DNS Server端建立私密通道,可保證(盡可能保證啦)中間的資料不被串改,因此,只要您所使用的DNS Server有實作此協定,可以安裝DNSCrypt試試看!

後記
上回文章我們從 gov.ph 網站安全性談起,從網站開發者的角色,從腳本語言的基本漏洞開始談起。這回我們與大家來談 DNS ,從 DNS 基本概念,到如何執行,最後講身為開發者需要注意 DNS 的哪些部分。最終最終大部分的漏洞,幾乎都是開發者的疏忽,只要多做判斷、多做保護,網站的安全性問題可以被降低許多。
MiCloud 內部也有提供 DNS 服務,給予外部、內部使用,MiCloud DNS 可以單獨申請使用,使用受信任、外部的服務,也是方法之一。
希望各位在開發、架構都能夠謹慎考量,注意到每一個細節,了解其中實作理論,讓網站開發更為完整、更為安全,避免掉無謂的安全性問題再度發生。網路上沒有絕對的安全,但是基礎的防範,是身為開發者應有的責任。

參考資料



原文出處:MiCloud Blogger: DNS 服務,你對於 DNS 懂多少?
冷日
(冷日)
Webmaster
  • 註冊日: 2008/2/19
  • 來自:
  • 發表數: 15771
[轉貼]Block DNS query type ANY

Block DNS query type ANY

前一陣子發現的 DNS Abuse Attack 行為找到了原因,
追查之後, 發現是某些 CPE 裝置, 如分享器等存在 DNS forward 漏洞所引起,
正常來說, DNS forward 只能 forward 內部(Private IP)來的 query,
但是有問題的 CPE 會把外部 DNS query forward 給它取得的 DNS,
攻擊者可以利用這點, 就可以對這些終端進行大量 DNS query, 達到 DDoS 攻擊,
ISP 所看到的 query source IP 都是自家客戶的 IP, 所以沒辦法用擋 IP 的方式來處理.
大部份的 query type 都是 any 或 txt, 因為回應的封包量比較大, 量大就足以癱瘓 DNS Server.
例如:
host -t any .
host -t txt isc.org

知道攻擊行為後, 就可以研擬防範的方法
1. 在 DNS 或防火牆設 UDP Port 53 rate limit
2. 擋掉 To 客戶端的 UDP Port 53, 前題是客戶沒有人架 DNS
3. 在 DNS 擋掉 query type=any, 這雖然是正規的 query, 但軟體應該不會進行這樣的查詢,
若是 Linux 平台的 DNS, 可以用下面的 rule 擋掉
iptables -t raw -A PREROUTING -p udp --dport 53 -m string --algo bm --hex-string "|0000ff0001|" -j DROP

ref.
Bind ANY ANY Query Denial of Service


原文出處:Block DNS query type ANY - Pank's Blog
冷日
(冷日)
Webmaster
  • 註冊日: 2008/2/19
  • 來自:
  • 發表數: 15771
[轉貼]How to Disable External DNS recursion?
How to Disable External DNS recursion?

I know that to disable recursive queries in BIND, I need add the following lines to the options section of /etc/bind/named.conf.options
allow-transfer {"none";};
allow-recursion {"none";};
recursion no;

Will the above configuration disable all DNS recursive queries?

How can I disable DNS recursion only to external network queries and keep recursion only for Internal network?

If I disable the recursion, then what process will be performed by the BIND resolve the name request? Iterative or Inverse?



You can enable recursion for some clients and disable recursion for others using views, but it is not recommended because you will lose some of the advantages of turning off recursion in the first place. You should use different nameservers for recursive resolution and authoritative service. (The two servers could run on the same machine if necessary.) Still, here's how to do it:
// global options apply to external clients
options {
    recursion no;
    additional-from-auth no;
    additional-from-cache no;
};

view "local" in {
    // view options enable recursion only for local clients
    match-clients { 172.16.45.80/23; 192.168.12.0/24; 127.0.0.1/8; ::1; };
    recursion yes;
    additional-from-auth yes;
    additional-from-cache yes;

    zone "." in {
            type hint;
            file "/etc/bind/db.root";
    };

    // put definitions for zones like "localhost" and "127.in-addr.arpa" here
}

// put definitions for real authoritative zones here.

As for the question in your last sentence, "what process will be performed by the BIND resolve the name request? Iterative or Inverse?", I do not understand the question. A nameserver configured not to offer recursive service will simply refuse to answer recursive queries.

原文出處:bind - How to Disable External DNS recursion? - Ask Ubuntu
冷日
(冷日)
Webmaster
  • 註冊日: 2008/2/19
  • 來自:
  • 發表數: 15771
[轉貼]DNS BIND9 Query Statements

DNS BIND9 Query Statements

This chapter describes all the statements available in BIND 9.x relating to or controlling queries. Full list of named.conf statements.

additional-from-auth, additional-from-cache



additional-from-auth yes | no ;
additional-from-cache yes | no ;

additional-from-auth and additional-from-cache control the behaviour when zones have additional (out-of-zone) data or when following CNAME or DNAME records. These options are for used for configuring authoritative-only (non-caching) servers and are only effective if recursion no is specified in a global options clause or in a view clause. The default in both cases is yes. These statements may be used in a global options or in a view clause. The behaviour is defined by the table below:


authcacheBIND Behaviour
yesyesBIND will follow out of zone records e.g. it will follow the MX record specifying mail.example.net for zone example.com for which it is authoritative (master or slave). Default behaviour.
nonoCache disabled. BIND will NOT follow out-of-zone records even if it is in the cache e.g. it will NOT follow the MX record specifying mail.example.net for zone example.com for which it is authoritative (master or slave). It will return REFUSED for the out-of-zone record.
yesnoCache disabled. BIND will follow out-of-zone records but since this requires the cache (which is disabled) the net result is the same - BIND will return REFUSED for the out-of-zone record.
noyesBIND will NOT follow out-of-zone records but if it is the cache it will be returned. If not in the cache BIND will return REFUSED for the out-of-zone record.

Prior to BIND 9.5 auth-from-cache also controlled whether a recursive query (even when recursion no; was specified) would return a referral to the root servers (since these would, most likely, be available in the cache). Since BIND 9.5+ such queries are now failed with REFUSED status.

allow-query, allow-query-on



allow-query { address_match_list };
allow-query { address_match_list };
allow-query {10.0/16;};
allow-query-on {192.168.2.1;};

allow-query defines an match list of IP address(es) which are allowed to issue queries to the server. If not specified all hosts are allowed to make queries (defaults to allow-query {any;};).

allow-query-on defines the server interface(s) from which queries are accepted and can be useful where a server is multi-homed, perhaps in conjunction with a view clause. Defaults to allow-query-on {any;};) meaning that queries are accepted on any server interface.

These statements may be used in a zone, view or a global options clause.

allow-query-cache, allow-query-cache-on



allow-query-cache { address_match_list };
allow-query-cache-on { address_match_list };
allow-query-cache { 10/8; };
allow-query-cache-on { localhost; };

Since BIND 9.4 allow-query-cache (or its default) controls access to the cache and thus effectively determines recursive behavior. This was done to limit the number of, possibly inadvertant, OPEN DNS resolvers. allow-query-cache defines an address_match_list of IP address(es) which are allowed to issue queries that access the local cache - without access to the local cache recursive queries are effectively useless so, in effect, this statement (or its default) controls recursive behavior. Its default setting depends on:

  1. If recursion no; present, defaults to allow-query-cache {none;};. No local cache access permitted.

  2. If recursion yes; (default) then, if allow-recursion present, defaults to the value of allow-recursion. Local cache access permitted to the same
    address_match_list as allow-recursion.

  3. If recursion yes; (default) then, if allow-recursion is NOT present, defaults to allow-query-cache {localnets; localhost;};. Local cache access permitted to localnets and localhost only.

Both allow-query-cache and allow-recursion statements are allowed - this is a recipe for conflicts and a debuggers dream come true. Use either statement consistently - by preference allow-recursion.

allow-query-cache-on defines the server interface(s) from which queries that access the local cache are accepted and can be useful where a server is multi-homed, perhaps in conjunction with a
view clause. Defaults to allow-query-cache-on {any;};) meaning that queries that access the local cache are accepted on any server interface.

These statements may be used in a view or a global options clause.

allow-recursion, allow-recursion-on



allow-recursion { address_match_list };
allow-recursion-on { address_match_list };
allow-recursion { 10.0/16; };
allow-recursion-on { 192.168.2.3; };

Only relevant if recursion yes; is present or defaulted. allow-recursion defines a address_match_list of IP address(es) which are allowed to issue recursive queries to the server. When allow-recursion is present allow-query-cache defaults to the same values. If allow-recursion is NOT present the allow-query-cache default is assumed (localnets, localhost only). Meaning that only localhost (the server's host) and hosts connected to the local LAN (localnets) are permitted to issue recursive queries.

allow-recusion-on defines the server interface(s) from which recursive queries are accepted and can be useful where a server is multi-homed, perhaps in conjunction with a
view clause. Defaults to allow-recursion-on {any;};) meaning that recursive queries are accepted on any server interface.

These statements may be used in a view or a global options clause.

auth-nxdomain



[auth-nxdomain yes | no;]

If auth-nxdomain is 'yes' allows the server to answer authoritatively (the AA bit is set) when returning NXDOMAIN (domain does not exist) answers, if 'no' (the default) the server will not answer authoritatively. NOTE: This changes the previous BIND 8 default setting. This statement may be used in a view or a global options clause.

blackhole



blackhole { address_match_list };

blackhole defines a address_match_list of hosts that the server will NOT respond to, or answer queries for. The default is 'none' (all hosts are responded to). This statement may only be used in a global options clause.

delegation-only



delegation-only yes | no ;
delegation-only no;

delegation-only applies to hint and stub zones only and defines whether the zone will only respond with delegations (or referrals). See type for more information. The default is no. This statement may only be used in a zone clause.

deny-answer-addresses



deny-answer-addresses { address_match_list }
[ except-from { name_list } ];
deny-answer-addresses {192.168.2.0/24;}
except-from {"example.com";"example.net";};

Allows a receiving recursive name server (full function resolver) to discard a query response which contains any IP address (IPv4 or IPv6) defined in the address_match_list (while a key parameter is valid within an address_match_list it will be silently ignored in this context). The intent of the statement is to prevent DNS queries to external domains returning IP addresses that lie inside protected or private address space of the receiver (the so-called "re-binding attack").


The optional except-from ( name_list ) may contain one or more names (; separated and terminated) which will bypass the deny-answer-address processing if the query name is for a matching domain name or a subdomain of a domain name that appears in the name_list. In the above example if a query from any domain responds with any address in the network block 192.168.2.0 to 192.169.2.255 it will be discarded (and a SERVFAIL message returned to the client which issued the original query) unless it is returned from a query to the domain or any subdomain of either example.com or example.net (both are defined in the except-from parameter which bypasses the filtering check). Thus, if a query to the name servers of domain example.com is issued for www.example.com and it returns an A record of 192.168.2.45 it will be accepted (it was defined in the except-from name_list) whereas if a query was issued to, say, the name servers for the domain someexternaldomain.com and it returns an A record of 192.168.2.45 it will be discarded. The statement may appear in a global
options clause.

deny-answer-aliases



deny-answer-aliases { name_list }
[ except-from { name_list } ] ;
deny-answer-aliases {"example.com";"example.net";}
except-from {"example.com";"example.net";};

deny-answer-aliases is similar to deny-answer-addresses but operates on any CNAME (or DNAME) records returned. The except-from ( name_list ) parameter allows the user to optionally select names which can bypass the filter processing. In the above example if a query returns a CNAME pointing to the domain name (or any subdomain) of either example.com or example.net then the response will be discarded (and a SERVFAIL message returned to the client which issued the original query) unless it is returned from a query to the domain (or any subdomain) of either example.com or example.net (both are defined in the except-from parameter which bypasses the filtering check). Thus, if a query to the name servers of the domain example.com is issued for www.example.com and it returns a CNAME pointing to, say, fred.example.com it will be accepted (it was defined in the except-from name_list) whereas if a query was issued to, say, the name servers of the domain someexternaldomain.com and it returns a CNAME pointing to, say, fred.example.com it will be discarded. The statement may appear in a global
options clause.

disable-empty-zone



disable-empty-zone zone_name ;
disable-empty-zone "168.192.IN-ADDR.ARPA";

By default
empty-zones-enable is set to yes which means that reverse queries for IPv4 and IPv6 addresses covered by RFCs 1918, 4193, 5737 and 6598 (as well as IPv6 local address (locally assigned), IPv6 link local addresses, the IPv6 loopback address and the IPv6 unknown address) but which is not covered by a locally defined zone clause will automatically return an NXDOMAIN response from the local name server. This prevents reverse map queries to such addresses escaping to the DNS hierarchy where they are simply noise and increase the already high level of query pollution caused by mis-configuration. disable-empty-zone may be used to selectively turn off empty zone responses for any particular zone in which case the query will escape to the DNS hierarchy. To turn off more than one empty-zone, multiple disable-empty-zone statements must be defined. There is no need to turn off empty-zones for which the user has defined a local
zone clause since BIND automatically detects this, similarly if the name server forwards all queries, the empty-zone process is automatically inhibited. Other than name servers which delegate to the IN-ADDR.ARPA or IP6.ARPA domains, it is not clear who would want to use this statement. Perhaps more imaginative readers can see uses. The statement may appear in a global options clause or a view clause.

Note: An empty zone contains only an SOA and a single NS RR.

empty-contact



empty-contact name ;
empty-contact "hostmaster.example.com";

By default empty-zones-enable is set to yes which means that reverse queries for IPv4 and IPv6 addresses covered by RFCs 1918, 4193, 5737 and 6598 (as well as IPv6 local address (locally assigned), IPv6 link local addresses, the IPv6 loopback address and the IPv6 unknown address) but which is not covered by a locally defined zone clause will automatically return an NXDOMAIN response from the local name server. This prevents reverse map queries to such addresses escaping to the DNS hierarchy where they are simply noise and increase the already high level of query pollution caused by mis-configuration. The NXDOMAIN response provides the SOA RR in the Authority Section:. The
SOA RR contains a number of fields which are synthesized by the empty zone feature. One of the fields is the mail address of a zone contact (the RNAME field). By default this is set to the value "." (a null value). empty-contact may be used to define an alternative email address which will be used in the SOA RR for all empty-zone responses. The example above defines hostmaster@example.com as an email address to which questions regarding this zone may be sent. The statement may appear in a global options clause or a view clause.

Note: An empty zone contains only an SOA and a single NS RR.

empty-server



empty-server name ;
empty-server "ns1.example.com";

By default empty-zones-enable is set to yes which means that reverse queries for IPv4 and IPv6 addresses covered by RFCs 1918, 4193, 5737 and 6598 (as well as IPv6 local address (locally assigned), IPv6 link local addresses, the IPv6 loopback address and the IPv6 unknown address) but which is not not covered by a locally defined zone clause will automatically return an NXDOMAIN response from the local name server. This prevents reverse map queries to such addresses escaping to the DNS hierarchy where they are simply noise and increase the already high level of query pollution caused by mis-configuration. The NXDOMAIN response provides the SOA RR in the Authority Section:. The
SOA RR contains a number of fields which are synthesized by the empty zone feature. One of the fields is the name of one of the zones names servers (the MNAME field). By default this is set to the value of the synthesized domain name. empty-server may be used to define an alternative name which will be used for all empty-zone responses. The example above indicates that ns1.example.com will appear as the name server name (MNAME) is all SOA RRs for empty-zone responses. The statement may appear in a global options clause or a view clause.

Note: An empty zone contains only an SOA and a single NS RR.

empty-zones-enable



empty-zones-enable yes | no ;
empty-zones-enable no;

By default empty-zones-enable is set to yes which means that reverse queries for IPv4 and IPv6 addresses covered by RFCs 1918, 4193, 5737 and 6598 (as well as IPv6 local address (locally assigned), IPv6 link local addresses, the IPv6 loopback address and the IPv6 unknown address) but which is not not covered by a locally defined zone clause will automatically return an NXDOMAIN response from the local name server. This prevents reverse map queries to such addresses escaping to the DNS hierarchy where they are simply noise and increase the already high level of query pollution caused by mis-configuration. The empty-zone feature may be turned off entirely by specifying empty-zones-enable no; or selectively by using one or more disable-empty-zone statements. The statement may appear in a global options clause or a
view clause.

Note: An empty zone contains only an SOA and a single NS RR.

forward



forward ( only | first );

forward is only relevant in conjunction with a valid forwarders statement. If set to 'only' the server will only forward queries, if set to 'first' (default) it will send the queries to the forwarder and if not answered will attempt to answer the query. This statement may be used in a zone, view or a global options clause.

forwarders



forwarders { ip_addr [port ip_port] ; [ ip_addr [port ip_port] ; ... ] };
forwarders { 10.2.3.4; 192.168.2.5; };

forwarders defines a list of IP address(es) (and optional port numbers) to which queries will be forwarded. Only relevant when used with the related forward statement. This statement may be used in a zone, view or a global options clause.

minimal-responses



minimal-responses yes | no ;
minimal-responses yes ;

If yes the server will only add records to the authority and additional data sections when they are required by the protocol, for instance, delegations and negative responses. This may improve the performance of the server by reducing outgoing data volumes. The BIND default is no. This statement may be used in a view or a global options clause.

prefetch



prefetch expiry-ttl-seconds [threshold-ttl-secs];
prefetch 5 ;

Introduced with BIND 9.10. This statement applies to recursive servers (full service resolvers) and allows the user to control the time at which the cache may be refreshed. If the recursive server waits until the TTL of any cached record has reached zero then there will be a visible delay while the replacement record is being fetched from the authoritative server. In order to increase user visible performance BIND (since 9.10) by default now prefetches records if it accesses a cached record which has 2 seconds or less of TTL remaining. The prefetch statement allows the user to control this behaviour by defining the expiry-ttl-seconds which may lie in the range 0 to 10 seconds. The value 0 indicates that prefetch should be disabled (the cache will only be updated when the TTL reaches 0), values in the range 1 to 10 indicate that if a cached record is accessed and its remaining TTL is equal to or less than expiry-ttl-seconds the record will be prefetched to ensure consistent user performance (values greater than 10 will be silently reduced to 10).

The optional threshold-ttl-seconds defines the minimum number of seconds of the TTL on the original record to invoke prefetching. If not defined the default for this value is 9 seconds. Thus, if a record is read into the cache with an original TTL of 5 seconds then, assuming the default threshold-ttl-seconds, prefetching is inhibited for that record (it is less than the 9 second default value). The threshold-ttl-seconds must be at least 6 seconds greater that the expiry-ttl-seconds. If this is not the case BIND will silently increase threshold-ttl-seconds.


While on its face this looks as if records can never be discarded from the cache, this is not the case. The prefetch algorithm will in practise only be invoked for high activity cached records since these will, by their nature, be frequently accessed and thus will trigger prefetch behavior checks and action. Low activity records are, by their nature, accessed infrequently and therefore will most likely not invoke prefetch behavior checks and action - they will naturally reach zero and be discarded from the cache. This statement may be used in a global options clause.

query-source[-v6]



query-source [ address ( ip_addr | * ) ] [ port ( ip_port | * ) ];
query-source address 192.168.2.3 ;
query-source-v6 [ address ( ip_addr | * ) ] [ port ( ip_port | * ) ];
query-source-v6 address * port 1188;

Defines the IP address (IPv4 or IPv6) and optional port to be used as the source for outgoing queries from the server. The BIND default is any server interface IP address and a random unprivileged port (1024 to 65535). The optional port is only used to control UDP operations. avoid-v4-udp-ports and avoid-v6-udp-ports can be used to prevent selection of certain ports. This statement may be used in a view or a global options clause.

Health Warning: Use of this option to define a fixed port number is extremely dangerous and can quickly lead to cache poisoning when used with any caching DNS server definition. An attacker normally has to guess both the transaction ID and the port number (both 16 bit values). If the port is fixed the bad guys have only to guess the transaction ID. You just made their job a lot easier. Don't do it.

recursion



recursion yes | no;

If recursion is set to 'yes' (the default) the server will always provide recursive query behaviour if requested by the client (resolver). If set to 'no' the server will only provide iterative query behaviour - normally resulting in a referral. If the answer to the query already exists in the cache it will be returned irrespective of the value of this statement. This statement essentially controls caching behaviour in the server. The allow-recursion statement and the view clauses can provide fine-grained control. This statement may be used in a view or a global options clause.

recursive-clients



recursive-clients number;
recursive-clients 25;

Defines the number of simultaneous recursive lookups the server will perform on behalf of its clients. BIND 9 default is 1000, that is, it will support 1000 simultaneous recursive lookup requests - which should be enough! This statement may only be used in a global options clause.

resolver-query-timeout



resolver-query-timeout seconds;
resolver-query-timeout 5;

Applies only to recursive name servers (full service resolvers) and defines the maximum time in seconds a recursive name server will take to perform a recursive operation before returning an error to the requesting client. May take any value between 10 (the default) and 30, with the special value 0 interpreted as the default (10 seconds - go figure). This statement may only be used in a global options clause.

response-policy

The response-policy statements allows BIND to intercept all queries and, based on a number of triggers and actions, to modify the returned responses. The feature is complex and is described on a Response Policy Zone page. It can only appear once in a global options clause.

root-delegation-only



root-delegation-only [ exclude { "domain_name"; ... } ];
root-delegation-only exclude { "com"; "net" };

If present indicates that all responses will be referrals or delegations. The optional exclude list consist of one or more domain_name (a quoted string) parameters. This statement is intended to be used for root domains (the gTLDs and ccTLDs) but the delegation-only statement may be to create the same effect for specific zones. This statement may be used in a view or a global options clause.

rrset-order



rrset-order { order_spec ; [ order_spec ; ... ]

rrset-order defines the order in which multiple records of the same type are returned. This works for any record type in which the records are similar not just A or AAAA RRs and covers results in the ANSWER SECTION and the ADDITIONAL SECTION. The default is cyclic (round-robin).

The full specification of rrset-order is shown below. An 'order_spec' is defined as:



class class_name ][ type type_name ][ name "domain_name"] order ordering;

Where 'class_name' is the record class, for example, IN (default is 'any'), type is the Resource Record type (if none specified defaults to 'any'), domain_name limits the statement to a specific domain suffix and defaults to root (all domains), order is a key word and ordering may take one of the following values:

  • fixed - records are returned in the order they are defined in the zone file
  • random - records are returned in a random order
  • cyclic - records are returned in a round-robin fashion

Note: For reasons best known to the ISC (BIND's author) the fixed value is now (BIND 9.6+) only available if the configure option --with-fixed-rrset is used in the build. Neither BSD nor Debian standard packages use this option. This is likely to be true for Fedora and other RPMs but has not been verified (use named -V to check). For practical purposes only cyclic and random are the available choices.

Examples

Defines that all equal records for all domains will be returned in random order.



rrset-order {order random;};

Defines that all equal MX records for example.com will be returned in random order all others in cyclic order.



rrset-order {type MX name "example.com" order random; order cyclic};

This statement may be used in a view or a global options clause. (For more information on DNS based resilience and load balancing techniques see this article.)

sortlist



sortlist { address_match_list; ... };
sortlist { {10.2/16; };};

The sortlist statement is used to order RRsets (groups of equal RRs) for use by a resolver (a client). It is the client side of the rrset-order statement and can work against the rrset-order statement when being used as part of a load-balancing configuration in that rrset-order may carefully deliver equal RRs in its order of preference to a remote resolver that may then proceed to re-order them with a sortlist statement! The sortlist statement attempts to order returned records based on the IP address of the client that initiated the request. This statement may only be used in a global options or a view clause.

(For more information on DNS based resilience and load balancing techniques see this article.)


The address_match_list is used very differently from its use in all other statements and assumes that each element of the address_match_list is itself an address_match_list, it becomes a nested address_match_list and is enclosed in braces (curly brackets). Processing depends on whether there is one or more than one element in the nested address_match_list. In the simple case of one element as in the above example if the client's IP address matches 10.2/16 i.e. lies in range 10.2.0.0 to 10.2.255.255) and there are any IP addresses in the response in the same range they will be the first records supplied in the response. Any remaining records will be sorted according to the rrset-order (default is cyclic). If no match is found the records are returned in the order defined by the rrset-order or its default value (cyclic). If two elements are provided in the address match list then the second element is assumed to be an ordered list of preferences. This is best illustrated by an example. Assume the zone example.com has a zone file with multiple A RRs for lots.example.com:



// zone file example.com
$ORIGIN example.com.
lots IN A 192.168.3.6
IN A 192.168.4.5
IN A 192.168.5.5
IN A 10.2.4.5
IN A 172.17.4.5

The client side server has a sortlist statement as shown below:



options {
....
sortlist {
{// 1st preference block start
192.168.4/24; // 1st client IP selection matches any of these
{10.2/16; // return any of these response IPs as 1st preference
172.17.4/24; // 2nd preference
};
}; // end first block
{ // second preference block
192.168.5/24; // 2nd client IP selection matches any of these
{192.168.4/24; // return any of these response IPs as 1st preference
172.18.4/24; // 2nd preference
10.2/16; // 3rd preference
};
}; // end second block
}; // end sortlist
};

If the client, say a resolver, with an IP address of 192.168.5.33 issues an A query for lots.example.com then the RRs will be returned in the following order:



192.168.4.5
10.2.4.5
192.168.3.6
192.168.5.5
172.17.4.5

The results are computed as follows. The top level of the address_match_list is searched against the client IP (192.168.5.33) address and matches the line with a comment beginning "2nd client IP selection", the nested address_match_list is then treated as an ordered list for the A query result IPs (not the client IPs). The line with a comment terminating with "1st preference" matches so 192.168.4.5 becomes first in returned list, the line with the comment "2nd preference" does not match the returned IPs, the line with the comment "3rd preference" matches so 10.2.4.5 becomes second in the returned list and the remaining 3 RRs do not match any item in the address_match_list so are returned according to the rrset-order statement or its default (cyclic) if not defined.


原文出處:DNS BIND9 Query Statements
前一個主題 | 下一個主題 | 頁首 | | |



Powered by XOOPS 2.0 © 2001-2008 The XOOPS Project|