<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Bind &#8211; richliu&#039;s blog</title>
	<atom:link href="https://richliu.com/tag/bind/feed/" rel="self" type="application/rss+xml" />
	<link>https://richliu.com</link>
	<description>Linux, 工作, 生活, 家人</description>
	<lastBuildDate>Tue, 07 Jul 2020 16:53:11 +0000</lastBuildDate>
	<language>zh-TW</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
	<item>
		<title>自架 DNS 防成人內容</title>
		<link>https://richliu.com/2020/07/08/4291/%e8%87%aa%e6%9e%b6dns%e9%98%b2%e6%88%90%e4%ba%ba%e5%85%a7%e5%ae%b9/</link>
					<comments>https://richliu.com/2020/07/08/4291/%e8%87%aa%e6%9e%b6dns%e9%98%b2%e6%88%90%e4%ba%ba%e5%85%a7%e5%ae%b9/#respond</comments>
		
		<dc:creator><![CDATA[richliu]]></dc:creator>
		<pubDate>Tue, 07 Jul 2020 16:50:48 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Network]]></category>
		<category><![CDATA[audlt]]></category>
		<category><![CDATA[Bind]]></category>
		<category><![CDATA[dhcp]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[pron]]></category>
		<guid isPermaLink="false">https://richliu.com/?p=4291</guid>

					<description><![CDATA[<p>果然還是到了這一天，雖然總是有一天他們會看到，但是多多少少還是要設一道簡單的關卡最簡單的是在路由器上設定 DN [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://richliu.com/2020/07/08/4291/%e8%87%aa%e6%9e%b6dns%e9%98%b2%e6%88%90%e4%ba%ba%e5%85%a7%e5%ae%b9/">自架 DNS 防成人內容</a> appeared first on <a rel="nofollow" href="https://richliu.com">richliu&#039;s blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>果然還是到了這一天，雖然總是有一天他們會看到，但是多多少少還是要設一道簡單的關卡<br />最簡單的是在路由器上設定 DNS ，畢竟誰都不喜歡在自己的手機電腦裝軟體吧 </p>



<span id="more-4291"></span>



<p><a rel="noreferrer noopener" aria-label="8 Free DNS Services to Block Porn Sites without Installing Software (opens in a new tab)" href="https://www.raymond.cc/blog/how-to-block-pornographic-websites-without-spending-money-on-software/" target="_blank">8 Free DNS Services to Block Porn Sites without Installing Software</a><br />這一篇就有提一些免費的 DNS 可以防國外的成人內容，像是 OpenDNS  OpenDNS Family Shield <br />DNS 設為<br /> Preferred DNS Server: 208.67.222.123<br /> Alternate DNS Server: 208.67.220.123 <br /><br />不過呢，這樣爸爸也會被擋掉，實在不是一個好解決方案</p>



<p>不過如果你有自已架 Linux Server，這到也不是什麼難事對吧，首先我猜你應該有了 dhcp 和 bind (name server) ，好吧，我知道現在大家都沒有，所以我也是寫來自 high 用的，畢竟我不想寫怎麼架 Linux router <br /><br />但是其實步驟並不會太複雜的<br />1. 設定 bind dns 到 OpenDNS 去查資料<br />在 /etc/bind/named.conf 內的 options session 加上以下這個選項，這樣會讓 bind 強迫去用 OpenDNS 查詢網址</p>



<pre class="wp-block-code"><code>    forwarders {
        208.67.222.123;
        208.67.220.123;
    };</code></pre>



<p>2. 將 dhcp 給的 DNS Server 設到 OpenDNS 和自己架的 name server <br />修改 /etc/dhcp/dhcpd.conf，修改 DNS Server ，以下是範例</p>



<pre class="wp-block-code"><code>option domain-name-servers 192.168.0.254, 208.67.220.123;</code></pre>



<p>3. 在 dhcpd.conf 內的 subnet session ，讓老爸的電腦變固定 IP，並且 DNS 設定成正常的 DNS，以下是範例，記得填入老爸電腦的 Mac Address. </p>



<pre class="wp-block-code"><code>host father { hardware ethernet 00:11:22:33:44:55; fixed-address 192.168.0.10; option domain-name-servers 8.8.8.8,
1.1.1.1;}</code></pre>



<p>4. 重開 dhcp 和 name server ，大功告成<br />現在只有老爸能看 P**nHub 了!<br /><br /><s>這時候有沒有感覺自己架 Linux 真好呢</s></p>
<p>The post <a rel="nofollow" href="https://richliu.com/2020/07/08/4291/%e8%87%aa%e6%9e%b6dns%e9%98%b2%e6%88%90%e4%ba%ba%e5%85%a7%e5%ae%b9/">自架 DNS 防成人內容</a> appeared first on <a rel="nofollow" href="https://richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://richliu.com/2020/07/08/4291/%e8%87%aa%e6%9e%b6dns%e9%98%b2%e6%88%90%e4%ba%ba%e5%85%a7%e5%ae%b9/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>DNS Query But Get Reply Code : Format Error</title>
		<link>https://richliu.com/2018/02/24/2215/dns-query-but-get-reply-code-format-error/</link>
					<comments>https://richliu.com/2018/02/24/2215/dns-query-but-get-reply-code-format-error/#respond</comments>
		
		<dc:creator><![CDATA[richliu]]></dc:creator>
		<pubDate>Sat, 24 Feb 2018 01:33:41 +0000</pubDate>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Bind]]></category>
		<guid isPermaLink="false">https://richliu.com/?p=2215</guid>

					<description><![CDATA[<p>This is strange problem, when update BIND this time, su [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://richliu.com/2018/02/24/2215/dns-query-but-get-reply-code-format-error/">DNS Query But Get Reply Code : Format Error</a> appeared first on <a rel="nofollow" href="https://richliu.com">richliu&#039;s blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>This is strange problem, when update BIND this time, suddenly, DNS query failed. I cannot find reason, I thought that should be NAT problem originally, because it cannot all other domains but Intranet domain, So, after capture packet to observe it. found root cause eventually , the DNS server replay me <strong>Format Error</strong>. </p>
<p><span id="more-2215"></span></p>
<p><a href="https://richliu.com/wp-content/uploads/2018/02/DNS-COOKIE-0.png"><img fetchpriority="high" decoding="async" src="https://richliu.com/wp-content/uploads/2018/02/DNS-COOKIE-0.png" alt="" width="849" height="548" class="aligncenter size-full wp-image-2216" srcset="https://richliu.com/wp-content/uploads/2018/02/DNS-COOKIE-0.png 849w, https://richliu.com/wp-content/uploads/2018/02/DNS-COOKIE-0-300x194.png 300w, https://richliu.com/wp-content/uploads/2018/02/DNS-COOKIE-0-768x496.png 768w" sizes="(max-width: 849px) 100vw, 849px" /></a></p>
<p>The DNS server is intranet DNS server, and used BIND domain name forwarding function  to get domain name from intranet server. suppose that used a old DNS server, so, something happen. After analyze packet format between good and fail packets, it shows interesting result. fail packet has DNS Cookies . </p>
<p>Fail Query Packet<br />
<a href="https://richliu.com/wp-content/uploads/2018/02/DNS-COOKIE-1.png"><img decoding="async" src="https://richliu.com/wp-content/uploads/2018/02/DNS-COOKIE-1.png" alt="" width="997" height="409" class="aligncenter size-full wp-image-2217" srcset="https://richliu.com/wp-content/uploads/2018/02/DNS-COOKIE-1.png 997w, https://richliu.com/wp-content/uploads/2018/02/DNS-COOKIE-1-300x123.png 300w, https://richliu.com/wp-content/uploads/2018/02/DNS-COOKIE-1-768x315.png 768w" sizes="(max-width: 997px) 100vw, 997px" /></a></p>
<p>Good Query Packet<br />
<a href="https://richliu.com/wp-content/uploads/2018/02/DNS-COOKIE-2.png"><img decoding="async" src="https://richliu.com/wp-content/uploads/2018/02/DNS-COOKIE-2.png" alt="" width="995" height="354" class="aligncenter size-full wp-image-2218" srcset="https://richliu.com/wp-content/uploads/2018/02/DNS-COOKIE-2.png 995w, https://richliu.com/wp-content/uploads/2018/02/DNS-COOKIE-2-300x107.png 300w, https://richliu.com/wp-content/uploads/2018/02/DNS-COOKIE-2-768x273.png 768w" sizes="(max-width: 995px) 100vw, 995px" /></a></p>
<p>Root cause might be BIND default enable DNS Cookies on after 9.11.0 . But my previous bind version is 9.11.x. suppose already enable Cookie.</p>
<p>Solution is to disable cookie , modify bind configure file and add <strong>send-cookie no to</strong> option session. it works. </p>
<p>Ref.<br />
<a href="https://kb.isc.org/article/AA-01387/0/DNS-Cookies-in-BIND-9.10-and-9.11.html" rel="noopener" target="_blank">DNS Cookies in BIND 9.10 and 9.11</a></p>
<p>The post <a rel="nofollow" href="https://richliu.com/2018/02/24/2215/dns-query-but-get-reply-code-format-error/">DNS Query But Get Reply Code : Format Error</a> appeared first on <a rel="nofollow" href="https://richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://richliu.com/2018/02/24/2215/dns-query-but-get-reply-code-format-error/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Bind Zone Forward</title>
		<link>https://richliu.com/2017/10/30/2194/bind-zone-forward/</link>
					<comments>https://richliu.com/2017/10/30/2194/bind-zone-forward/#respond</comments>
		
		<dc:creator><![CDATA[richliu]]></dc:creator>
		<pubDate>Mon, 30 Oct 2017 04:45:31 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Network]]></category>
		<category><![CDATA[Bind]]></category>
		<category><![CDATA[forward]]></category>
		<category><![CDATA[named]]></category>
		<category><![CDATA[zone]]></category>
		<guid isPermaLink="false">https://richliu.com/?p=2194</guid>

					<description><![CDATA[<p>如果有特定的 domain 要指向特定的 Server 這時候就要用 Zone Forward 指令 例如:  [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://richliu.com/2017/10/30/2194/bind-zone-forward/">Bind Zone Forward</a> appeared first on <a rel="nofollow" href="https://richliu.com">richliu&#039;s blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>如果有特定的 domain 要指向特定的 Server</p>
<p>這時候就要用 Zone Forward 指令</p>
<p>例如:</p>
<pre lang="text">
zone "subzone.mydns.example.com" {
  type forward;
  forwarders { 192.168.0.4; };
};
</pre>
<p>這樣就可以了</p>
<p>ref<br />
<a href="https://serverfault.com/questions/409190/how-to-properly-configure-bind-forward-zone-for-an-internal-dns-server" rel="noopener" target="_blank">How to properly configure BIND forward zone for an internal DNS server?</a><br />
<a href="http://www.zytrax.com/books/dns/ch7/zone.html#type" rel="noopener" target="_blank">DNS BIND zone clause</a></p>
<p>The post <a rel="nofollow" href="https://richliu.com/2017/10/30/2194/bind-zone-forward/">Bind Zone Forward</a> appeared first on <a rel="nofollow" href="https://richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://richliu.com/2017/10/30/2194/bind-zone-forward/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>自幹 dyndns</title>
		<link>https://richliu.com/2014/10/09/1674/%e8%87%aa%e5%b9%b9-dyndns/</link>
					<comments>https://richliu.com/2014/10/09/1674/%e8%87%aa%e5%b9%b9-dyndns/#respond</comments>
		
		<dc:creator><![CDATA[richliu]]></dc:creator>
		<pubDate>Wed, 08 Oct 2014 17:01:20 +0000</pubDate>
				<category><![CDATA[Gentoo]]></category>
		<category><![CDATA[Network]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[UNIX]]></category>
		<category><![CDATA[Bind]]></category>
		<category><![CDATA[dyndns]]></category>
		<category><![CDATA[named]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[schtasks]]></category>
		<category><![CDATA[Update]]></category>
		<category><![CDATA[windows]]></category>
		<guid isPermaLink="false">https://richliu.com/?p=1674</guid>

					<description><![CDATA[<p>之前好像免費的 dyndns 都收的差不多了, 好像很久沒有人提了. 今天心情還不錯, 就來架設自己的 dyn [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://richliu.com/2014/10/09/1674/%e8%87%aa%e5%b9%b9-dyndns/">自幹 dyndns</a> appeared first on <a rel="nofollow" href="https://richliu.com">richliu&#039;s blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>之前好像免費的 dyndns 都收的差不多了, 好像很久沒有人提了.<br />
今天心情還不錯, 就來架設自己的 dyndns.<br />
主要可以參考這二篇</p>
<p><a href="http://phorum.study-area.org/index.php?topic=40717.0" target="_blank" rel="noopener">[分享] 用 BIND 架設 DDNS Server 提供 DDNS 服務 </a>及<br />
<a href="http://www.study-area.org/tips/ddns.htm" target="_blank" rel="noopener">動態 DNS 設定技巧</a><br />
<span id="more-1674"></span></p>
<p>上網看了一下, 大家寫的非常長, 不過如果架過 DNS, 其實也沒有這麼難, 實作上還算簡單的.<br />
至少比想像中簡單許多<br />
1. 在 /var/bind/pri/named.domain.com 中加入你想要做 dyndns 的 domain name</p>
<p style="padding-left: 30px;">ex:<br />
test A 0.0.0.0</p>
<p style="padding-left: 30px;">別忘了改 serial number</p>
<p>2. 到 /var/bind/dyn 下產生 key</p>
<p style="padding-left: 30px;"># dnssec-keygen -a HMAC-MD5 -b 512 -n USER test.domain.name.<br />
會產生二個檔案, 內容產不多</p>
<p>3. 將 key 內容 copy 到 bind 去</p>
<p style="padding-left: 30px;">將其中的 Ktest.domain.name.+123+45678.key 內的</p>
<p style="padding-left: 30px;">&#8220;test.domain.name. IN KEY 0 3 157 WH3pLphbwFlc/F8C1tbFcdzWRfcDdYWu00KBM5l2OE0rAVHzXFO+dahU SRrPKC0AMcbO6mwV4oVK94G9J5u9aw==<br />
放到 /etc/bind/named.conf 內,</p>
<p style="padding-left: 30px;">key test.domain.name. {<br />
algorithm HMAC-MD5;<br />
secret &#8220;WH3pLphbwFlc/F8C1tbFcdzWRfcDdYWu00KBM5l2OE0rAVHzXFO+dahU SRrPKC0AMcbO6mwV4oVK94G9J5u9aw==&#8221;;<br />
};</p>
<p>4. 修改 zone 的設定</p>
<p style="padding-left: 30px;">zone &#8220;domain.name&#8221; in {<br />
type master;<br />
file &#8220;pri/named.domain&#8221;;<br />
allow-query{ any; };</p>
<p style="padding-left: 30px;">update-policy {<br />
grant test.domain.name. name test.domain.name. A;<br />
};<br />
};</p>
<p>5. Restart bind</p>
<p style="padding-left: 30px;"># /etc/init.d/named restart</p>
<p>6. 測試 Update 是否成功<br />
使用 nsupdate 工具向 Primary DNS 做更新動作：</p>
<p>$ nsupdate -k Ktest.domain.name.+123+45678.key<br />
&gt; server ns.domain.name // 指定 Primary DNS<br />
&gt; update delete test.domain.name A // 先刪除舊資料<br />
&gt; update add test.domain.name 0 A 1.1.1.1 // 再新增資料<br />
&gt; send // 送出到 Primary DNS<br />
$ dig @ns.domain.name test.domain.name<br />
;; ANSWER SECTION:<br />
test.domain.name. 0 IN A 1.1.1.1</p>
<p>如果不成功, 可以看一下 /var/log , 然後看看是不是少了 /var/bind/pri/named.domain.com.jnl, 這個權限要加上去<br />
如果重啟之後, 出現 &#8220;response to SOA query was unsuccessful&#8221;, 那個 .jnl 的檔案砍了再重來就可以了, 好像是改了 SOA 就會錯亂.</p>
<p>這樣算完成一半, 上面第二個 Link 內有 Linux Update 的範例, 不過 Windows 怎麼辦呢? 像中華電信每幾天會換一次 IP, 所以自動更新的功能只好自己硬幹了. 而且 Windows PPPoE Disconnect/connected 時都不會有 event 可以呼叫 script 去執行, 所以就每一陣子執行一次 script 更新一下 DNS 資料, 不重要的 Service 這樣做還好, 重要的話可能就不行, 但是重要的也不會放 PPPoE 上吧 XD</p>
<p>自己硬幹有幾個選擇</p>
<p style="padding-left: 30px;">[X] DOS BASH : 這個很差, 可能抓不到 IP<br />
[X] Cygwin : 這個在我的 Windows XP 上根本跑不起來, 被防毒軟體擋到不能用 :&lt;<br />
[O] Python : 這個好, 什麼地方都可以用, 只要跑簡單的程式的話, 還是 python 安定.</p>
<p>所以就自己寫了一個小程式<br />
1. 程式碼放到 github , 存成 update.py<br />
https://github.com/richliu/dnsupdate</p>
<p>2. 產生 template file, script.txt 內容如下</p>
<p style="padding-left: 30px;">server ns.domain.name<br />
update delete test.domain.name A<br />
update add test.domain.name 0 A SERVER_NEW_IP<br />
send</p>
<p>3. 產生一個空的 ip.dat 檔案. (懶得檢查了, 所以就自己動手最快)</p>
<p>4. 寫一個 run.bat 內容是</p>
<p style="padding-left: 30px;">cd C:\TEST\<br />
C:\Python27\python.exe update.py</p>
<p>5. 下載 bind 執行檔 for windows 32bit</p>
<p><a href="http://www.isc.org/downloads/bind/" target="_blank" rel="noopener">  http://www.isc.org/downloads/bind/</a></p>
<p>解出所有的 .dll 檔, 和 dig 及 nsupdate 丟到同一個目錄, 如果是 windows 32 bit, 別忘了執行一下程式內的 vcredist_x86.exe, 這是 visual c++ 2005 dll .</p>
<p>6. 定時執行</p>
<p style="padding-left: 30px;">如果 IP 有變的話就會更新 dyndns, 因為用 windows, 所以採用的是 schtasks.<br />
相關的說明可以上 Microsoft <a href="http://technet.microsoft.com/en-us/library/cc725744.aspx" target="_blank" rel="noopener">Schtasks</a> 網站看<br />
用下面這個指令就可以讓 script 每 5 分鐘執行一次<br />
# schtasks /create /tn &#8220;Check IP&#8221; /tr c:\TEST\run.bat /sc minute /mo 5</p>
<p>大.功.告.成.</p>
<p>&nbsp;</p>
<p>The post <a rel="nofollow" href="https://richliu.com/2014/10/09/1674/%e8%87%aa%e5%b9%b9-dyndns/">自幹 dyndns</a> appeared first on <a rel="nofollow" href="https://richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://richliu.com/2014/10/09/1674/%e8%87%aa%e5%b9%b9-dyndns/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Bind 9 Performance Test, Gentoo 奪冠</title>
		<link>https://richliu.com/2008/02/19/556/bind-9-performance-test-gentoo-%e5%a5%aa%e5%86%a0/</link>
					<comments>https://richliu.com/2008/02/19/556/bind-9-performance-test-gentoo-%e5%a5%aa%e5%86%a0/#respond</comments>
		
		<dc:creator><![CDATA[richliu]]></dc:creator>
		<pubDate>Mon, 18 Feb 2008 17:02:48 +0000</pubDate>
				<category><![CDATA[Gentoo]]></category>
		<category><![CDATA[UNIX]]></category>
		<category><![CDATA[Bind]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Performance Test]]></category>
		<guid isPermaLink="false">https://richliu.com/2008/02/19/556/</guid>

					<description><![CDATA[<p>本期的 Gentoo Monthly Newsletter: 18 February 2008 ISC 針對  [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://richliu.com/2008/02/19/556/bind-9-performance-test-gentoo-%e5%a5%aa%e5%86%a0/">Bind 9 Performance Test, Gentoo 奪冠</a> appeared first on <a rel="nofollow" href="https://richliu.com">richliu&#039;s blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>本期的 <a href="http://www.gentoo.org/news/en/gmn/20080218-newsletter.xml" target="_blank" rel="noopener">Gentoo Monthly Newsletter: 18 February 2008</a><br />
ISC 針對 8 個平台(包含 Linux, FreeBSD, Solaris, Windows) 做的 <a href="http://new.isc.org/proj/dnsperf/OStest.html" target="_blank" rel="noopener">DNS Query Test.</a> </p>
<p>Gentoo 以 93,000/sec 次奪冠, 遠超過 Windows 平台 4 倍以上.<br />
不過&#8230;&#8230;<br />
一般不會有這麼大量的 DNS Query 吧, 除非是攻擊.</p>
<p>The post <a rel="nofollow" href="https://richliu.com/2008/02/19/556/bind-9-performance-test-gentoo-%e5%a5%aa%e5%86%a0/">Bind 9 Performance Test, Gentoo 奪冠</a> appeared first on <a rel="nofollow" href="https://richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://richliu.com/2008/02/19/556/bind-9-performance-test-gentoo-%e5%a5%aa%e5%86%a0/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
