<?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:trackback="http://madskills.com/public/xml/rss/module/trackback/">
<channel>
	<title>flyinweb's blog - DNS技术</title>
	<link>http://www.517sou.net/Folder/dns/Index.aspx</link>
	<language>zh-CN</language>
	<webMaster>shanyiwan@msn.com(flyinweb)</webMaster>
	<pubDate>Mon, 15 Jun 2009 19:31:16 GMT</pubDate>
	<copyright>Copyright 2007-2009. All rights reserved.</copyright>
	<generator>Bitrac Free Version</generator>
	<description>桃李无言，下自成蹊</description>
	<image>
		<title>flyinweb&apos;s blog</title>
		<url>http://www.517sou.net/Client/Banner.gif</url>
		<link>http://www.517sou.net/</link>
		<description>桃李无言，下自成蹊</description>
	</image>
	<item>
		<link>http://www.517sou.net/Article/major-improvement-bind-9-startup-performance.aspx</link>
		<title>A Major Improvement in BIND 9 Startup Performance</title>
		<author>shanyiwan@live.com()</author>
		<category>DNS技术</category>
		<pubDate>Tue, 06 Sep 2011 01:03:52 GMT</pubDate>
		<description>&lt;p&gt;One of the common complaints we&apos;ve received over the years about BIND 9 is that large authoritative servers, particularly those with a very large number of small zones, are slow to launch. I&apos;ve met some DNS operators who expressed a powerful aversion to upgrading their systems, because a shutdown and restart can literally take all day.&lt;/p&gt;&lt;p&gt;If that describes you, I have some good news. There is a simple optimization for BIND 9 that can dramatically improve your startup performance. New versions of BIND are being released soon to take advantage of it.&lt;/p&gt;&lt;p&gt;I recently did some profiling experiments on a server with tens of thousands of small zones, and discovered that the delay was &lt;em&gt;not&lt;/em&gt;, as I had expected, primarily caused by loading the server configuration and the zone database. In fact, named was spending the vast majority of its time repeatedly walking very long linked-lists. Further examination to find the reason for this revealed a simple but significant tuning bug that&apos;s been overlooked for years: The zone tasks were massively overburdened.&lt;/p&gt;&lt;p&gt;In some ways, BIND 9 is almost like a miniature operating system. From the perspective of your real OS, named is just a single process. . . but within named, there are &lt;em&gt;more&lt;/em&gt; processes, all taking turns doing their jobs, then yielding control to the next miniature process. These internal mini-processes are called &amp;quot;tasks&amp;quot;, and they handle all the functions of the name server—sending queries, answering queries, cleaning the cache, and so on.&lt;/p&gt;&lt;p&gt;Each zone served by a BIND 9 server has a task associated with it, whose job is to do all the routine maintenance for an authoritative zone: sending SOA requests to masters, sending NOTIFY messages to slaves, dumping dynamic zone data to disk, regenerating expiring DNSSEC signatures, and so forth. Since these functions don&apos;t usually all happen at once, a single task can support many zones; but too many zones and the task can be overwhelmed.&lt;/p&gt;&lt;p&gt;It turned out that the pool from which the zone tasks were assigned was fixed in size, and much too small. And the damage this did to startup performance was immense: On a test server with 8 processors and 12G of memory, a server with a million zones took well over ten hours to begin serving queries. And no wonder, because those million zones were sharing the resources of only eight zone tasks.&lt;/p&gt;&lt;p&gt;When I tried increasing the size of the task pool, I expected to see a reduction in startup time. What I didn&apos;t expect was a near &lt;em&gt;elimination&lt;/em&gt; of startup time:&lt;/p&gt;&lt;div style=&quot;text-align: center&quot;&gt;&lt;img alt=&quot;&quot; src=&quot;http://www.517sou.net/Attach/month_1109/wn50m0_090651_1.png&quot; width=&quot;750&quot; height=&quot;562&quot; /&gt;&lt;/div&gt;&lt;p&gt;Named started up and began serving queries in a little over fifteen minutes, most of which was spent parsing the very large named.conf file. Loading the zones, a process that had taken over ten hours in the previous run, now took 2-3 minutes. (&lt;em&gt;Full details of the tests and results can be found &lt;/em&gt;&lt;a class=&quot;href-files-imce-startup-performance.pdf&quot; href=&quot;https://www.isc.org/files/imce/startup-performance.pdf&quot;&gt;&lt;em&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;here&lt;/font&gt;&lt;/u&gt;&lt;/em&gt;&lt;/a&gt;&amp;nbsp;or &lt;a href=&quot;http://www.517sou.net/Attach/month_1109/9cq7rp_startup-performance.pdf&quot;&gt;this site&lt;/a&gt;&lt;em&gt;.&lt;/em&gt;)&lt;/p&gt;&lt;p&gt;A larger task pool does take more memory, but it&apos;s negligible compared to the size of the zone data. If you serve hundreds of thousands or millions of zones, you can expect to see a factor-twenty improvement in startup time at the cost of about 2% more memory.&lt;/p&gt;&lt;p&gt;The single change to be made is in the file lib/dns/zone.c. When the function isc_taskpool_create() is called, the third argument—set to 8 in most versions of BIND—should be set to a number that&apos;s roughly one one-hundredth of the number of zones you expect to be serving. (There is also a slight theoretical benefit if the number happens to be prime, though in practice the difference is quite small.)&lt;/p&gt;&lt;p&gt;If you&apos;re running a million zones, you want about ten thousand zone tasks. 10007 happens to be prime. Changing the 8 to 10007 should dramatically improve your startup performance:&lt;/p&gt;&lt;p&gt;&lt;font face=&quot;monospace&quot;&gt;&lt;font color=&quot;#60ff60&quot;&gt;&lt;b&gt;--- zone.c.00 2011-07-12 08:56:34.000000000 -0700&lt;/b&gt;&lt;/font&gt;&lt;br /&gt;&lt;font color=&quot;#60ff60&quot;&gt;&lt;b&gt;+++ zone.c 2011-07-12 14:46:44.000000000 -0700&lt;/b&gt;&lt;/font&gt;&lt;br /&gt;&lt;font color=&quot;#60ff60&quot;&gt;&lt;b&gt;@@ -12455,8 +12455,7 @@&lt;/b&gt;&lt;/font&gt;&lt;br /&gt;zmgr-&amp;gt;transfersperns = 2;&lt;br /&gt;&lt;br /&gt;/* Create the zone task pool. */&lt;br /&gt;&lt;span style=&quot;background-color: rgb(68,136,136)&quot;&gt;&lt;font color=&quot;#ffff60&quot;&gt;- result = isc_taskpool_create(taskmgr, mctx,&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;background-color: rgb(68,136,136)&quot;&gt;&lt;font color=&quot;#ffff60&quot;&gt;- 8 /* XXX */, 2, &amp;amp;zmgr-&amp;gt;zonetasks);&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;background-color: rgb(170,102,102)&quot;&gt;&lt;font color=&quot;#40ffff&quot;&gt;+ result = isc_taskpool_create(taskmgr, mctx, 10007, 2, &amp;amp;zmgr-&amp;gt;zonetasks);&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;if (result != ISC_R_SUCCESS)&lt;br /&gt;goto free_rwlock;&lt;br /&gt;&lt;br /&gt;&lt;/font&gt;&lt;/p&gt;&lt;p&gt;Better yet, though, don&apos;t bother editing C files, and just install the newest releases of BIND 9. In the upcoming 9.8.1, which will have its third beta release this week, named counts the zones at startup time and automatically scales its zone task table accordingly.&lt;/p&gt;&lt;p&gt;The upcoming 9.6-ESV-R5 and 9.7.4 releases were already very close to final release when this trick was discovered. Since they&apos;ve already been through beta, we decided we&apos;d make a smaller, less invasive change in those. When the final releases come out in the next week or so, you&apos;ll be able to set an environment variable—&lt;font face=&quot;monospace&quot;&gt;BIND9_ZONE_TASKS_HINT&lt;/font&gt;—with your desired number of zone tasks.&lt;/p&gt;&lt;p&gt;In later releases of 9.6 and 9.7, we will backport the automatic scaling code, and the environment variable will no longer be necessary.&lt;/p&gt;&lt;p&gt;出处：&lt;a href=&quot;https://www.isc.org/community/blog/201107/major-improvement-bind-9-startup-performance&quot;&gt;https://www.isc.org/community/blog/201107/major-improvement-bind-9-startup-performance&lt;/a&gt;&lt;/p&gt;</description>
		<guid>http://www.517sou.net/Article/major-improvement-bind-9-startup-performance.aspx</guid>
		<trackback:ping>http://www.517sou.net/Article/671/Trackback.ashx</trackback:ping>
		<comments>http://www.517sou.net/Article/major-improvement-bind-9-startup-performance.aspx#CommentPostAnchor</comments>
		<wfw:commentRss>http://www.517sou.net/Article/671/Feeds.ashx</wfw:commentRss>
	</item>
	<item>
		<link>http://www.517sou.net/Article/bind9-chroot.aspx</link>
		<title>手动编译bind，并做chroot处理</title>
		<author>shanyiwan@live.com()</author>
		<category>DNS技术</category>
		<pubDate>Fri, 29 Jul 2011 01:38:12 GMT</pubDate>
		<description>&lt;div&gt;&lt;p&gt;&lt;span style=&quot;font-family: 宋体; background: yellow&quot;&gt;需要的文件&lt;/span&gt;&lt;span style=&quot;background: yellow&quot; lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;:&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;BIND&lt;/span&gt;&lt;span style=&quot;font-family: 宋体&quot;&gt;的源码&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;&lt;a href=&quot;http://ftp.isc.org/isc/bind9/9.6.1-P2/bind-9.6.1-P2.tar.gz&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;http://ftp.isc.org/isc/bind9/9.6.1-P2/bind-9.6.1-P2.tar.gz&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: 宋体; background: yellow&quot;&gt;目录列表&lt;/span&gt;&lt;span style=&quot;background: yellow&quot; lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;:&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;/opt/bind &lt;wbr /&gt;&lt;wbr /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: 宋体&quot;&gt;保存编译安装以后的&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;bind&lt;br /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;/opt/chroot bind&lt;/span&gt;&lt;span style=&quot;font-family: 宋体&quot;&gt;的&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;chroot&lt;/span&gt;&lt;span style=&quot;font-family: 宋体&quot;&gt;运行环境根目录&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: 宋体; background: yellow&quot;&gt;目录结构如下&lt;/span&gt;&lt;span style=&quot;background: yellow&quot; lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;:&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;bind&lt;br /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;|-- bin&lt;br /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;|-- etc&lt;br /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;|-- include&lt;br /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;| &lt;wbr /&gt;&lt;wbr /&gt;|-- bind9&lt;br /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;| &lt;wbr /&gt;&lt;wbr /&gt;|-- dns&lt;br /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;| &lt;wbr /&gt;&lt;wbr /&gt;|-- dst&lt;br /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;| &lt;wbr /&gt;&lt;wbr /&gt;|-- isc&lt;br /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;| &lt;wbr /&gt;&lt;wbr /&gt;|-- isccc&lt;br /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;| &lt;wbr /&gt;&lt;wbr /&gt;|-- isccfg&lt;br /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;| &lt;wbr /&gt;&lt;wbr /&gt;`-- lwres&lt;br /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;|-- lib&lt;br /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;|-- sbin&lt;br /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;|-- share&lt;br /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;| &lt;wbr /&gt;&lt;wbr /&gt;`-- man&lt;br /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;| &lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;|-- man1&lt;br /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;| &lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;|-- man3&lt;br /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;| &lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;|-- man5&lt;br /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;| &lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;`-- man8&lt;br /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;`-- var&lt;br /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;`-- run&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;chroot&lt;br /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;|-- dev&lt;br /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;|-- etc&lt;br /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;`-- var&lt;br /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;|-- log&lt;br /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;|-- named&lt;br /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;| &lt;wbr /&gt;&lt;wbr /&gt;|-- slaves&lt;br /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;| &lt;wbr /&gt;&lt;wbr /&gt;`-- zones&lt;br /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;`-- run&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: 宋体; background: yellow&quot;&gt;安装步骤：&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;1.&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: 宋体&quot;&gt;添加执行&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;bind&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: 宋体&quot;&gt;所用的用户&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;(&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: 宋体&quot;&gt;为了使用&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;chroot)&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;span lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;font-family: 宋体&quot;&gt;添加&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;named&lt;/span&gt;&lt;span style=&quot;font-family: 宋体&quot;&gt;组&lt;/span&gt;&lt;/p&gt;&lt;span lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;groupadd named &lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;/span&gt;&lt;p&gt;&lt;span lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;font-family: 宋体&quot;&gt;添加&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;named&lt;/span&gt;&lt;span style=&quot;font-family: 宋体&quot;&gt;用户，设定&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;home&lt;/span&gt;&lt;span style=&quot;font-family: 宋体&quot;&gt;目录为我们指定的&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;chroot&lt;/span&gt;&lt;span style=&quot;font-family: 宋体&quot;&gt;目录，&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;shell&lt;/span&gt;&lt;span style=&quot;font-family: 宋体&quot;&gt;设置成&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;nologin&lt;/span&gt;&lt;span style=&quot;font-family: 宋体&quot;&gt;，不允许从控制台登陆&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;useradd -g named -d /opt/chroot -s /sbin/nologin named &lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;font-family: 宋体&quot;&gt;锁定&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;named&lt;/span&gt;&lt;span style=&quot;font-family: 宋体&quot;&gt;帐户的密码&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;passwd -l named&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;2.&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: 宋体&quot;&gt;构建&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;chroot&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: 宋体&quot;&gt;环境&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;span lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;font-family: 宋体&quot;&gt;首先删掉&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;useradd&lt;/span&gt;&lt;span style=&quot;font-family: 宋体&quot;&gt;命令自己建立的&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;/opt/chroot&lt;/span&gt;&lt;span style=&quot;font-family: 宋体&quot;&gt;目录，然后再重建&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;/opt/chroot&lt;/span&gt;&lt;span style=&quot;font-family: 宋体&quot;&gt;目录，目的是清除&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;.bash_profile&lt;/span&gt;&lt;span style=&quot;font-family: 宋体&quot;&gt;这类文件，因为&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;named&lt;/span&gt;&lt;span style=&quot;font-family: 宋体&quot;&gt;不允许登陆，因此这些文件无用&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;rm -rf /opt/chroot&lt;br /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;mkdir /opt/chroot&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;font-family: 宋体&quot;&gt;建立&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;etc, dev, var&lt;/span&gt;&lt;span style=&quot;font-family: 宋体&quot;&gt;这三个必须的目录&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;&lt;wbr /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;mkdir -p /opt/chroot/{etc,dev,var/{run,named/{zones,slaves}}}&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;font-family: 宋体&quot;&gt;建立必要的设备文件&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;mknod /opt/chroot/dev/null c 1 3&lt;br /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;mknod /opt/chroot/dev/zero c 1 5&lt;br /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;mknod /opt/chroot/dev/random c 1 8&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;font-family: 宋体&quot;&gt;复制本机的&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;timezone&lt;/span&gt;&lt;span style=&quot;font-family: 宋体&quot;&gt;文件到&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;chroot&lt;/span&gt;&lt;span style=&quot;font-family: 宋体&quot;&gt;环境&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;cp /etc/localtime /opt/chroot/etc &lt;wbr /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;3.&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: 宋体&quot;&gt;解压缩&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;bind&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: 宋体&quot;&gt;源码&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;span lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;tar xvzf bind-9.6.1-P1.tar.gz&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;4.&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: 宋体&quot;&gt;进入源码目录进行编译&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;span lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;cd bind-9.6.1-P1&lt;br /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;./configure --prefix=/opt/bind --enable-threads &lt;wbr /&gt;--enable-largefile&lt;br /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;make&lt;br /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;make install&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: 宋体&quot;&gt;如果没有错误的话，已经编译好&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;bind&lt;/span&gt;&lt;span style=&quot;font-family: 宋体&quot;&gt;并安装到了&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;prefix&lt;/span&gt;&lt;span style=&quot;font-family: 宋体&quot;&gt;参数所指定位置&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font-family: 宋体&quot;&gt;默认情况下所有的文件都在该目录，除非手工指定其他目录&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;font-family: 宋体&quot;&gt;。&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;--enable-threads&lt;/span&gt;&lt;span style=&quot;font-family: 宋体&quot;&gt;指定了使用多线程&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;5.&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: 宋体&quot;&gt;建立&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;BIND&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: 宋体&quot;&gt;配置文件和&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;zone&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: 宋体&quot;&gt;文件&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;span lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;touch /opt/chroot/etc/named.conf&lt;br /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;touch /opt/chroot/etc/var/named/zones/test.com.zone&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;6.&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: 宋体&quot;&gt;削减，设置目录访问权限&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;span lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;chown root /chroot&lt;br /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;chmod 755 /chroot&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;chown named:named /chroot/var/named&lt;br /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;chmod 700 /chroot/var/named&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;chown -R named:named /chroot/named/var/named/slaves&lt;br /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;chown named:named /chroot/named/var/run&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;7.&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: 宋体&quot;&gt;启动&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;BIND&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;span lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;/opt/bind/sbin/named -t /opt/chroot -u named -c /etc/named.conf&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;8.&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: 宋体&quot;&gt;设置&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;rndc&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: 宋体&quot;&gt;编辑&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;/opt/bind/etc/rndc.conf &lt;wbr /&gt;(rndc.conf&lt;/span&gt;&lt;span style=&quot;font-family: 宋体&quot;&gt;文件需要在&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;rndc&lt;/span&gt;&lt;span style=&quot;font-family: 宋体&quot;&gt;所在目录的上层&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;etc&lt;/span&gt;&lt;span style=&quot;font-family: 宋体&quot;&gt;目录中，本例&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;rndc&lt;/span&gt;&lt;span style=&quot;font-family: 宋体&quot;&gt;的位置为&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;/opt/bind/sbin)&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;key &amp;quot;rndc-key&amp;quot; {&lt;br /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;algorithm hmac-md5;&lt;br /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;secret &amp;quot;O23s3DegwBjKrgXPfTB0g==&amp;quot;;&lt;br /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;};&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span lang=&quot;EN-US&quot; xml:lang=&quot;EN-US&quot;&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;options {&lt;br /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;default-key &amp;quot;rndc-key&amp;quot;;&lt;br /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;default-server 127.0.0.1;&lt;br /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;default-port 953;&lt;br /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;&lt;wbr /&gt;};&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;a href=&quot;http://www.faqs.org/docs/Linux-HOWTO/Chroot-BIND-HOWTO.html&quot; target=&quot;_blank&quot;&gt;Chroot-BIND HOWTO&lt;/a&gt;&lt;/p&gt;&lt;h1&gt;Chroot-BIND HOWTO&lt;/h1&gt;&lt;h2&gt;Scott Wunsch, &lt;code&gt;scott at wunsch.org&lt;/code&gt;&lt;/h2&gt;&lt;p&gt;v1.5, 1 December 2001&lt;/p&gt;&lt;hr /&gt;&lt;p&gt;&lt;em&gt;This document describes installing the BIND 9 nameserver to run in a chroot jail and as a non-root user, to provide added security and minimise the potential effects of a security compromise. Note that this document has been updated for BIND 9; if you still run BIND 8, you want the Chroot-BIND8 HOWTO instead.&lt;/em&gt;&lt;/p&gt;&lt;hr /&gt;&lt;h2&gt;&lt;a name=&quot;toc1&quot;&gt;&lt;font color=&quot;#000000&quot;&gt;1.&lt;/font&gt;&lt;/a&gt;&lt;a href=&quot;http://www.faqs.org/docs/Linux-HOWTO/Chroot-BIND-HOWTO.html#s1&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;Introduction&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;http://www.faqs.org/docs/Linux-HOWTO/Chroot-BIND-HOWTO.html#ss1.1&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;1.1 What?&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.faqs.org/docs/Linux-HOWTO/Chroot-BIND-HOWTO.html#ss1.2&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;1.2 Why?&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.faqs.org/docs/Linux-HOWTO/Chroot-BIND-HOWTO.html#ss1.3&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;1.3 Where?&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.faqs.org/docs/Linux-HOWTO/Chroot-BIND-HOWTO.html#ss1.4&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;1.4 How?&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.faqs.org/docs/Linux-HOWTO/Chroot-BIND-HOWTO.html#ss1.5&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;1.5 Disclaimer&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h2&gt;&lt;a name=&quot;toc2&quot;&gt;&lt;font color=&quot;#000000&quot;&gt;2.&lt;/font&gt;&lt;/a&gt;&lt;a href=&quot;http://www.faqs.org/docs/Linux-HOWTO/Chroot-BIND-HOWTO.html#s2&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;Preparing the Jail&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;http://www.faqs.org/docs/Linux-HOWTO/Chroot-BIND-HOWTO.html#ss2.1&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;2.1 Creating a User&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.faqs.org/docs/Linux-HOWTO/Chroot-BIND-HOWTO.html#ss2.2&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;2.2 Directory Structure&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.faqs.org/docs/Linux-HOWTO/Chroot-BIND-HOWTO.html#ss2.3&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;2.3 Placing the BIND Data&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.faqs.org/docs/Linux-HOWTO/Chroot-BIND-HOWTO.html#ss2.4&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;2.4 System Support Files&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.faqs.org/docs/Linux-HOWTO/Chroot-BIND-HOWTO.html#ss2.5&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;2.5 Logging&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.faqs.org/docs/Linux-HOWTO/Chroot-BIND-HOWTO.html#ss2.6&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;2.6 Tightening Permissions&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h2&gt;&lt;a name=&quot;toc3&quot;&gt;&lt;font color=&quot;#000000&quot;&gt;3.&lt;/font&gt;&lt;/a&gt;&lt;a href=&quot;http://www.faqs.org/docs/Linux-HOWTO/Chroot-BIND-HOWTO.html#s3&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;Compiling and Installing Your Shiny New BIND&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;http://www.faqs.org/docs/Linux-HOWTO/Chroot-BIND-HOWTO.html#ss3.1&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;3.1 Doing the Compile&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h2&gt;&lt;a name=&quot;toc4&quot;&gt;&lt;font color=&quot;#000000&quot;&gt;4.&lt;/font&gt;&lt;/a&gt;&lt;a href=&quot;http://www.faqs.org/docs/Linux-HOWTO/Chroot-BIND-HOWTO.html#s4&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;Installing Your Shiny New BIND&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;http://www.faqs.org/docs/Linux-HOWTO/Chroot-BIND-HOWTO.html#ss4.1&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;4.1 Installing the Binaries&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.faqs.org/docs/Linux-HOWTO/Chroot-BIND-HOWTO.html#ss4.2&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;4.2 Setting up the Init Script&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.faqs.org/docs/Linux-HOWTO/Chroot-BIND-HOWTO.html#ss4.3&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;4.3 Configuration Changes&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h2&gt;&lt;a name=&quot;toc5&quot;&gt;&lt;font color=&quot;#000000&quot;&gt;5.&lt;/font&gt;&lt;/a&gt;&lt;a href=&quot;http://www.faqs.org/docs/Linux-HOWTO/Chroot-BIND-HOWTO.html#s5&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;The End&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;http://www.faqs.org/docs/Linux-HOWTO/Chroot-BIND-HOWTO.html#ss5.1&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;5.1 Launching BIND&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.faqs.org/docs/Linux-HOWTO/Chroot-BIND-HOWTO.html#ss5.2&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;5.2 That&apos;s It!&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h2&gt;&lt;a name=&quot;toc6&quot;&gt;&lt;font color=&quot;#000000&quot;&gt;6.&lt;/font&gt;&lt;/a&gt;&lt;a href=&quot;http://www.faqs.org/docs/Linux-HOWTO/Chroot-BIND-HOWTO.html#s6&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;Appendix - Upgrading BIND Later&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;&lt;/h2&gt;&lt;h2&gt;&lt;a name=&quot;toc7&quot;&gt;&lt;font color=&quot;#000000&quot;&gt;7.&lt;/font&gt;&lt;/a&gt;&lt;a href=&quot;http://www.faqs.org/docs/Linux-HOWTO/Chroot-BIND-HOWTO.html#s7&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;Appendix - Thanks&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;&lt;/h2&gt;&lt;h2&gt;&lt;a name=&quot;toc8&quot;&gt;&lt;font color=&quot;#000000&quot;&gt;8.&lt;/font&gt;&lt;/a&gt;&lt;a href=&quot;http://www.faqs.org/docs/Linux-HOWTO/Chroot-BIND-HOWTO.html#s8&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;Appendix - Document Distribution Policy&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;&lt;hr /&gt;&lt;/font&gt;&lt;/u&gt;&lt;/p&gt;&lt;h2&gt;&lt;a name=&quot;s1&quot;&gt;&lt;font color=&quot;#000000&quot;&gt;1.&lt;/font&gt;&lt;/a&gt;&lt;a href=&quot;http://www.faqs.org/docs/Linux-HOWTO/Chroot-BIND-HOWTO.html#toc1&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;Introduction&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;This is the Chroot-BIND HOWTO; see &lt;a href=&quot;http://www.faqs.org/docs/Linux-HOWTO/Chroot-BIND-HOWTO.html#where&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;Where?&lt;/font&gt;&lt;/u&gt;&lt;/a&gt; for the master site, which contains the latest copy. It is assumed that you already know how to configure and use BIND (the Berkeley Internet Name Domain). If not, I would recommend that you read the DNS HOWTO first. It is also assumed that you have a basic familiarity with compiling and installing software on your UNIX-like system.&lt;/p&gt;&lt;h2&gt;&lt;a name=&quot;ss1.1&quot;&gt;&lt;font color=&quot;#000000&quot;&gt;1.1 What?&lt;/font&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;This document describes some extra security precautions that you can take when you install BIND. It explains how to configure BIND so that it resides in a ``chroot jail,&apos;&apos; meaning that it cannot see or access files outside its own little directory tree. We shall also configure it to run as a non-root user.&lt;/p&gt;&lt;p&gt;The idea behind chroot is fairly simple. When you run BIND (or any other process) in a chroot jail, the process is simply unable to see any part of the filesystem outside the jail. For example, in this document, we&apos;ll set BIND up to run chrooted to the directory &lt;code&gt;/chroot/named&lt;/code&gt;. Well, to BIND, the contents of this directory will appear to be &lt;code&gt;/&lt;/code&gt;, the root directory. Nothing outside this directory will be accessible to it. You&apos;ve probably encounted a chroot jail before, if you&apos;ve ever used &lt;code&gt;ftp&lt;/code&gt; to log into a public system.&lt;/p&gt;&lt;p&gt;Because the chroot process is much simpler with BIND 9, I have started to expand this document slightly, to include more general tips about securing a BIND installation. Nevertheless, this document is not (and is not intended to be) a complete reference for securing BIND. If you do only what is outlined in this document, you&apos;re not finished securing your nameserver!&lt;/p&gt;&lt;h2&gt;&lt;a name=&quot;ss1.2&quot;&gt;&lt;font color=&quot;#000000&quot;&gt;1.2 Why?&lt;/font&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;The idea behind running BIND in a chroot jail is to limit the amount of access any malicious individual could gain by exploiting vulnerabilities in BIND. It is for the same reason that we run BIND as a non-root user.&lt;/p&gt;&lt;p&gt;This should be considered as a supplement to the normal security precautions (running the latest version, using access control, etc.), certainly not as a replacement for them.&lt;/p&gt;&lt;p&gt;If you&apos;re interested in DNS security, you might also be interested in a few other products. Building BIND with &lt;a href=&quot;http://www.immunix.org/products.html#stackguard&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;StackGuard&lt;/font&gt;&lt;/u&gt;&lt;/a&gt; would probably be a good idea for even more protection. Using it is easy; it&apos;s just like using ordinary gcc. Also, &lt;a href=&quot;http://cr.yp.to/dnscache.html&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;DNScache&lt;/font&gt;&lt;/u&gt;&lt;/a&gt; is a secure replacement for BIND, written by Dan Bernstein. Dan is the author of qmail, and DNScache appears to follow a similar philosophy.&lt;/p&gt;&lt;h2&gt;&lt;a name=&quot;ss1.3&quot;&gt;&lt;font color=&quot;#000000&quot;&gt;1.3 Where?&lt;/font&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;The latest version of this document is always available from the web site of the Linux/Open Source Users of Regina, Sask., at &lt;a href=&quot;http://www.losurs.org/docs/howto/Chroot-BIND.html&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;http://www.losurs.org/docs/howto/Chroot-BIND.html&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;There is now a Japanese translation of this document, maintained by Nakano Takeo &lt;code&gt;nakano at apm.seikei.ac.jp&lt;/code&gt;. This is available at &lt;a href=&quot;http://www.linux.or.jp/JF/JFdocs/Chroot-BIND-HOWTO.html&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;http://www.linux.or.jp/JF/JFdocs/Chroot-BIND-HOWTO.html&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;BIND is available from &lt;a href=&quot;http://www.isc.org/&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;the Internet Software Consortium&lt;/font&gt;&lt;/u&gt;&lt;/a&gt; at &lt;a href=&quot;http://www.isc.org/bind.html&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;http://www.isc.org/bind.html&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;. As of this writing, the current version of BIND 9 is 9.2.0. BIND 9 has been out for some time now, and many people are using it in production. Nevertheless, some more conservative sorts still prefer to remain with BIND 8. If you are such a person, please see my Chroot-BIND8 HOWTO (available from the same location) for details on chrooting it, but be warned that BIND 8 is much messier to chroot.&lt;/p&gt;&lt;p&gt;Keep in mind that there are &lt;b&gt;known&lt;/b&gt; security holes in many earlier versions of BIND, so make very sure that you&apos;re running the latest version!&lt;/p&gt;&lt;h2&gt;&lt;a name=&quot;ss1.4&quot;&gt;&lt;font color=&quot;#000000&quot;&gt;1.4 How?&lt;/font&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;I wrote this document based on my experiences in setting BIND up in a chroot environment. In my case, I already had an existing BIND installation in the form of a package that came with my Linux distribution. I&apos;ll assume that most of you are probably in the same situation, and will simply be transferring over and modifying the configuration files from your existing BIND installation, and then removing the package before installing the new one. Don&apos;t remove the package yet, though; we may want some files from it first.&lt;/p&gt;&lt;p&gt;If this is not the case for you, you should still be able to follow this document. The only difference is that, where I refer to copying an existing file, you first have to create it yourself. The DNS HOWTO may be helpful for this.&lt;/p&gt;&lt;h2&gt;&lt;a name=&quot;ss1.5&quot;&gt;&lt;font color=&quot;#000000&quot;&gt;1.5 Disclaimer&lt;/font&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;These steps worked for me, on my system; your mileage may vary. This is but one way to approach this; there are other ways to set the same thing up (although the general approach will be the same). It just happens that this was the first way that I tried that worked, so I wrote it down.&lt;/p&gt;&lt;p&gt;My BIND experience to date has been installing on Linux servers. However, most of the instructions in this document should be easily applicable to other flavours of UNIX as well, and I shall try to point out differences of which I am aware. I&apos;ve also received suggestions from people using other distributions and other platforms, and I&apos;ve tried to incorporate their comments where possible.&lt;/p&gt;&lt;p&gt;If you run Linux, you need to make sure that you&apos;re running a 2.4 kernel before attempting this. The &lt;code&gt;-u&lt;/code&gt; switch (to run as a non-root user) requires this newer kernel.&lt;/p&gt;&lt;hr /&gt;&lt;h2&gt;&lt;a name=&quot;s2&quot;&gt;&lt;font color=&quot;#000000&quot;&gt;2.&lt;/font&gt;&lt;/a&gt;&lt;a href=&quot;http://www.faqs.org/docs/Linux-HOWTO/Chroot-BIND-HOWTO.html#toc2&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;Preparing the Jail&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;&lt;/h2&gt;&lt;h2&gt;&lt;a name=&quot;ss2.1&quot;&gt;&lt;font color=&quot;#000000&quot;&gt;2.1 Creating a User&lt;/font&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;As mentioned in the introduction, it&apos;s not a good idea to run BIND as root. So, before we begin, let&apos;s create a separate user for BIND. Note that you should never use an existing generic user like &lt;code&gt;nobody&lt;/code&gt; for this purpose. However, some distributions, such as SuSE and Linux Mandrake have started providing a specific user (generally called &lt;code&gt;named&lt;/code&gt;); you can simply adapt this user for our purposes, if you like.&lt;/p&gt;&lt;p&gt;This requires adding a line something like the following to &lt;code&gt;/etc/passwd&lt;/code&gt;:&lt;/p&gt;&lt;blockquote&gt;&lt;code&gt;&lt;pre&gt;
named:x:200:200:Nameserver:/chroot/named:/bin/false
&lt;/pre&gt;&lt;/code&gt;&lt;/blockquote&gt;&lt;p&gt;And one like this to &lt;code&gt;/etc/group&lt;/code&gt;:&lt;/p&gt;&lt;blockquote&gt;&lt;code&gt;&lt;pre&gt;
named:x:200:
&lt;/pre&gt;&lt;/code&gt;&lt;/blockquote&gt;&lt;p&gt;This creates a user and group called &lt;code&gt;named&lt;/code&gt; for BIND. Make sure that the UID and GID (both 200 in this example) are unique on your system. The shell is set to &lt;code&gt;/bin/false&lt;/code&gt; because this user will never need to log in.&lt;/p&gt;&lt;h2&gt;&lt;a name=&quot;ss2.2&quot;&gt;&lt;font color=&quot;#000000&quot;&gt;2.2 Directory Structure&lt;/font&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Now, we must set up the directory structure that we will use for the chroot jail in which BIND will live. This can be anywhere on your filesystem; the truly paranoid may even want to put it on a separate volume. I shall assume that you will use &lt;code&gt;/chroot/named&lt;/code&gt;. Let&apos;s start by creating the following directory structure:&lt;/p&gt;&lt;blockquote&gt;&lt;code&gt;&lt;pre&gt;
/chroot
  +-- named
       +-- dev
       +-- etc
       |    +-- namedb
       |         +-- slave
       +-- var
            +-- run
&lt;/pre&gt;&lt;/code&gt;&lt;/blockquote&gt;&lt;p&gt;If you use GNU &lt;code&gt;mkdir&lt;/code&gt; (such as on a Linux system), you can create this directory structure like this:&lt;/p&gt;&lt;blockquote&gt;&lt;code&gt;&lt;pre&gt;
# mkdir -p /chroot/named
# cd /chroot/named
# mkdir -p dev etc/namedb/slave var/run
&lt;/pre&gt;&lt;/code&gt;&lt;/blockquote&gt;&lt;h2&gt;&lt;a name=&quot;ss2.3&quot;&gt;&lt;font color=&quot;#000000&quot;&gt;2.3 Placing the BIND Data&lt;/font&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Assuming that you have already done a conventional installation of BIND and are using it, you will already have an existing &lt;code&gt;named.conf&lt;/code&gt; and zone files. These files must now be moved (or copied, to be safe) into the chroot jail, so that BIND can get at them. &lt;code&gt;named.conf&lt;/code&gt; goes in &lt;code&gt;/chroot/named/etc&lt;/code&gt;, and the zone files can go in &lt;code&gt;/chroot/named/etc/namedb&lt;/code&gt;. For example:&lt;/p&gt;&lt;blockquote&gt;&lt;code&gt;&lt;pre&gt;
# cp -p /etc/named.conf /chroot/named/etc/
# cp -a /var/named/* /chroot/named/etc/namedb/
&lt;/pre&gt;&lt;/code&gt;&lt;/blockquote&gt;&lt;p&gt;BIND would normally need to write to the &lt;code&gt;namedb&lt;/code&gt; directory, but in the interests of tightening security, we will not allow it to do this. If your nameserver serves as a slave for any zones, it will need to update these zone files, which means we&apos;ll have to store them in a separate directory, to which BIND does have write access.&lt;/p&gt;&lt;blockquote&gt;&lt;code&gt;&lt;pre&gt;
# chown -R named:named /chroot/named/etc/namedb/slave
&lt;/pre&gt;&lt;/code&gt;&lt;/blockquote&gt;&lt;p&gt;Keep in mind that&apos;ll you have to move any slave zones you have into this directory, and update your &lt;code&gt;named.conf&lt;/code&gt; accordingly.&lt;/p&gt;&lt;p&gt;BIND will also need to write to the &lt;code&gt;/var/run&lt;/code&gt; directory, to put its pidfile and statistical information there, so let&apos;s allow it to do so:&lt;/p&gt;&lt;blockquote&gt;&lt;code&gt;&lt;pre&gt;
# chown named:named /chroot/named/var/run
&lt;/pre&gt;&lt;/code&gt;&lt;/blockquote&gt;&lt;h2&gt;&lt;a name=&quot;ss2.4&quot;&gt;&lt;font color=&quot;#000000&quot;&gt;2.4 System Support Files&lt;/font&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Once BIND is running in the chroot jail, it will not be able to access files outside the jail &lt;b&gt;at all&lt;/b&gt;. However, it needs to access a few key files, although not nearly as many as BIND 8 did.&lt;/p&gt;&lt;p&gt;One file that BIND will need inside its jail is good ol&apos; &lt;code&gt;/dev/null&lt;/code&gt;. Note that the exact command necessary to create this device node may vary from system to system; check your &lt;code&gt;/dev/MAKEDEV&lt;/code&gt; script to be sure. Some systems may also require &lt;code&gt;/dev/zero&lt;/code&gt;, which can created similarly. It&apos;s reported that the BIND 9.2.0 release candidates now require &lt;code&gt;/dev/random&lt;/code&gt; as well. For most Linux systems, we can use the following commands:&lt;/p&gt;&lt;blockquote&gt;&lt;code&gt;&lt;pre&gt;
# mknod /chroot/named/dev/null c 1 3
# mknod /chroot/named/dev/random c 1 8
# chmod 666 /chroot/named/dev/{null,random}
&lt;/pre&gt;&lt;/code&gt;&lt;/blockquote&gt;&lt;p&gt;For FreeBSD 4.3, this is:&lt;/p&gt;&lt;blockquote&gt;&lt;code&gt;&lt;pre&gt;
# mknod /chroot/named/dev/null c 2 2
# mknod /chroot/named/dev/random c 2 3
# chmod 666 /chroot/named/dev/{null,random}
&lt;/pre&gt;&lt;/code&gt;&lt;/blockquote&gt;&lt;p&gt;You also need another file in the &lt;code&gt;/etc&lt;/code&gt; directory inside the jail. You must copy &lt;code&gt;/etc/localtime&lt;/code&gt; (this is sometimes known as &lt;code&gt;/usr/lib/zoneinfo/localtime&lt;/code&gt; on some systems) in there so that BIND logs things with the right time on them. The following command will take care of this:&lt;/p&gt;&lt;blockquote&gt;&lt;code&gt;&lt;pre&gt;
# cp /etc/localtime /chroot/named/etc/
&lt;/pre&gt;&lt;/code&gt;&lt;/blockquote&gt;&lt;h2&gt;&lt;a name=&quot;ss2.5&quot;&gt;&lt;font color=&quot;#000000&quot;&gt;2.5 Logging&lt;/font&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Unlike a conventional jailbird, BIND can&apos;t just scribble its log entries on the walls :-). Normally, BIND logs through &lt;code&gt;syslogd&lt;/code&gt;, the system logging daemon. However, this type of logging is performed by sending the log entries to the special socket &lt;code&gt;/dev/log&lt;/code&gt;. Since this is outside the jail, BIND can&apos;t use it any more. Fortuantely, there are a couple options to work around this.&lt;/p&gt;&lt;h3&gt;The Ideal Solution&lt;/h3&gt;&lt;p&gt;The ideal solution to this dilemma requires a reasonably recent version of &lt;code&gt;syslogd&lt;/code&gt; which supports the &lt;code&gt;-a&lt;/code&gt; switch introduced by OpenBSD. Check the manpage for your &lt;code&gt;syslogd(8)&lt;/code&gt; to see if you have such a version.&lt;/p&gt;&lt;p&gt;If you do, all you have to do is add the switch ``&lt;code&gt;-a /chroot/named/dev/log&lt;/code&gt;&apos;&apos; to the command line when you launch &lt;code&gt;syslogd&lt;/code&gt;. On systems which use a full SysV-init (which includes most Linux distributions), this is typically done in the file &lt;code&gt;/etc/rc.d/init.d/syslog&lt;/code&gt;. For example, on my Red Hat Linux system, I changed the line&lt;/p&gt;&lt;blockquote&gt;&lt;code&gt;&lt;pre&gt;
daemon syslogd -m 0
&lt;/pre&gt;&lt;/code&gt;&lt;/blockquote&gt;&lt;p&gt;to&lt;/p&gt;&lt;blockquote&gt;&lt;code&gt;&lt;pre&gt;
daemon syslogd -m 0 -a /chroot/named/dev/log
&lt;/pre&gt;&lt;/code&gt;&lt;/blockquote&gt;&lt;p&gt;Interestingly, as of Red Hat 7.2, Red Hat has apparently made this process even easier. There is now a file called &lt;code&gt;/etc/sysconfig/syslog&lt;/code&gt; in which extra parameters for syslogd can be defined.&lt;/p&gt;&lt;p&gt;On Caldera OpenLinux systems, they use a daemon launcher called &lt;code&gt;ssd&lt;/code&gt;, which reads configuration from &lt;code&gt;/etc/sysconfig/daemons/syslog&lt;/code&gt;. You simply need to modify the options line to look like this:&lt;/p&gt;&lt;blockquote&gt;&lt;code&gt;&lt;pre&gt;
OPTIONS_SYSLOGD=&amp;quot;-m 0 -a /chroot/named/dev/log&amp;quot;
&lt;/pre&gt;&lt;/code&gt;&lt;/blockquote&gt;&lt;p&gt;Similarly, on SuSE systems, I&apos;m told that the best place to add this switch is in the &lt;code&gt;/etc/rc.config&lt;/code&gt; file. Changing the line&lt;/p&gt;&lt;blockquote&gt;&lt;code&gt;&lt;pre&gt;
SYSLOGD_PARAMS=&amp;quot;&amp;quot;
&lt;/pre&gt;&lt;/code&gt;&lt;/blockquote&gt;&lt;p&gt;to read&lt;/p&gt;&lt;blockquote&gt;&lt;code&gt;&lt;pre&gt;
SYSLOGD_PARAMS=&amp;quot;-a /chroot/named/dev/log&amp;quot;
&lt;/pre&gt;&lt;/code&gt;&lt;/blockquote&gt;&lt;p&gt;should do the trick.&lt;/p&gt;&lt;p&gt;And, last but not least, for FreeBSD 4.3 you can apparently just edit the &lt;code&gt;rc.conf&lt;/code&gt; file and put in the following:&lt;/p&gt;&lt;blockquote&gt;&lt;code&gt;&lt;pre&gt;
syslogd_flags=&amp;quot;-s -l /chroot/named/dev/log&amp;quot;
&lt;/pre&gt;&lt;/code&gt;&lt;/blockquote&gt;&lt;p&gt;The &lt;code&gt;-s&lt;/code&gt; is for security reasons, and is part of the default settings. The &lt;code&gt;-l&lt;/code&gt; is a local path on which to put another logging node.&lt;/p&gt;&lt;p&gt;Once you&apos;ve figured out how to make this change for your system, simply restart &lt;code&gt;syslogd&lt;/code&gt;, either by killing it and launching it again (with the extra parameters), or by using the SysV-init script to do it for you:&lt;/p&gt;&lt;blockquote&gt;&lt;code&gt;&lt;pre&gt;
# /etc/rc.d/init.d/syslog stop
# /etc/rc.d/init.d/syslog start
&lt;/pre&gt;&lt;/code&gt;&lt;/blockquote&gt;&lt;p&gt;Once it&apos;s been restarted, you should see a ``file&apos;&apos; in &lt;code&gt;/chroot/named/dev&lt;/code&gt; called &lt;code&gt;log&lt;/code&gt;, that looks something like this:&lt;/p&gt;&lt;pre&gt;
srw-rw-rw-   1 root     root            0 Mar 13 20:58 log
&lt;/pre&gt;&lt;h3&gt;The Other Solutions&lt;/h3&gt;&lt;p&gt;If you have an older &lt;code&gt;syslogd&lt;/code&gt;, then you&apos;ll have to find another way to do your logging. There are a couple programs out there, such as &lt;code&gt;holelogd&lt;/code&gt;, which are designed to help by acting as a ``proxy&apos;&apos; and accepting log entries from the chrooted BIND and passing them out to the regular &lt;code&gt;/dev/log&lt;/code&gt; socket.&lt;/p&gt;&lt;p&gt;Alteratively, you can simply configure BIND to log to files instead of going through syslog. See the BIND documentation for more details if you choose to go this route.&lt;/p&gt;&lt;h2&gt;&lt;a name=&quot;ss2.6&quot;&gt;&lt;font color=&quot;#000000&quot;&gt;2.6 Tightening Permissions&lt;/font&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;First of all, feel free to restrict access to the whole &lt;code&gt;/chroot&lt;/code&gt; directory to the &lt;code&gt;root&lt;/code&gt; user. Of course, not everybody may want to do this, especially if you have other software installed in that tree that doesn&apos;t appreciate it.&lt;/p&gt;&lt;blockquote&gt;&lt;code&gt;&lt;pre&gt;
# chown root /chroot
# chmod 700 /chroot
&lt;/pre&gt;&lt;/code&gt;&lt;/blockquote&gt;&lt;p&gt;You can also safely restrict access to &lt;code&gt;/chroot/named&lt;/code&gt; to the &lt;code&gt;named&lt;/code&gt; user.&lt;/p&gt;&lt;blockquote&gt;&lt;code&gt;&lt;pre&gt;
# chown named:named /chroot/named
# chmod 700 /chroot/named
&lt;/pre&gt;&lt;/code&gt;&lt;/blockquote&gt;&lt;p&gt;For even more tightening, on Linux systems we can make a few of the files and directories immutable, using the &lt;code&gt;chattr&lt;/code&gt; tool on ext2 filesystems.&lt;/p&gt;&lt;blockquote&gt;&lt;code&gt;&lt;pre&gt;
# cd /chroot/named
# chattr +i etc etc/localtime var
&lt;/pre&gt;&lt;/code&gt;&lt;/blockquote&gt;&lt;p&gt;Equivalently, on FreeBSD 4.3, you want to look into &lt;code&gt;chflags&lt;/code&gt; if you wish to make things immutable. As an example, the following should change everything in the &lt;code&gt;/chroot/named/etc&lt;/code&gt; directory to immutable:&lt;/p&gt;&lt;blockquote&gt;&lt;code&gt;&lt;pre&gt;
# chflags schg /chroot/named/etc/*(*).
&lt;/pre&gt;&lt;/code&gt;&lt;/blockquote&gt;&lt;p&gt;It would be nice to do this for the &lt;code&gt;dev&lt;/code&gt; directory too, but unfortunately that would prevent &lt;code&gt;syslogd&lt;/code&gt; from creating its &lt;code&gt;dev/log&lt;/code&gt; socket. You may also choose to set the immutable bit on other files in the jail as well, such as your primary zone files, if they aren&apos;t expected to change.&lt;/p&gt;&lt;hr /&gt;&lt;h2&gt;&lt;a name=&quot;s3&quot;&gt;&lt;font color=&quot;#000000&quot;&gt;3.&lt;/font&gt;&lt;/a&gt;&lt;a href=&quot;http://www.faqs.org/docs/Linux-HOWTO/Chroot-BIND-HOWTO.html#toc3&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;Compiling and Installing Your Shiny New BIND&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;&lt;/h2&gt;&lt;h2&gt;&lt;a name=&quot;ss3.1&quot;&gt;&lt;font color=&quot;#000000&quot;&gt;3.1 Doing the Compile&lt;/font&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Compiling BIND 9 for use in a chroot jail should be a much more pleasant experience than BIND 8 was. In fact, you don&apos;t have to do anything special; the standard &lt;code&gt;./configure &amp;amp;&amp;amp; make&lt;/code&gt; should suffice.&lt;/p&gt;&lt;p&gt;Keep in mind that if you want to enable IPv6 support in BIND (&lt;code&gt;--enable-ipv6&lt;/code&gt;) on Linux systems, you need matching versions of kernel and glibc. If you have kernel 2.2, you need glibc 2.1, and if you have kernel 2.4, you need glibc 2.2. BIND is quite picky about this.&lt;/p&gt;&lt;hr /&gt;&lt;h2&gt;&lt;a name=&quot;s4&quot;&gt;&lt;font color=&quot;#000000&quot;&gt;4.&lt;/font&gt;&lt;/a&gt;&lt;a href=&quot;http://www.faqs.org/docs/Linux-HOWTO/Chroot-BIND-HOWTO.html#toc4&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;Installing Your Shiny New BIND&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;I should mention that if you have an existing installation of BIND, such as from an RPM, you should probably remove it before installing the new one. On Red Hat systems, this probably means removing the packages &lt;code&gt;bind&lt;/code&gt; and &lt;code&gt;bind-utils&lt;/code&gt;, and possibly &lt;code&gt;bind-devel&lt;/code&gt; and &lt;code&gt;caching-nameserver&lt;/code&gt;, if you have them.&lt;/p&gt;&lt;p&gt;You may want to save a copy of the init script (e.g., &lt;code&gt;/etc/rc.d/init.d/named&lt;/code&gt;), if any, before doing so; it&apos;ll be useful later on.&lt;/p&gt;&lt;p&gt;If you are upgrading from an older version of BIND, such as BIND 8, you will want to read the migration documentation in the file &lt;code&gt;doc/misc/migration&lt;/code&gt; in the BIND source package. I don&apos;t deal with any migration issues in this document; I simply assume that you are replacing an existing, working installation of BIND 9.&lt;/p&gt;&lt;h2&gt;&lt;a name=&quot;ss4.1&quot;&gt;&lt;font color=&quot;#000000&quot;&gt;4.1 Installing the Binaries&lt;/font&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;This is the easy part :-). Just run &lt;code&gt;make install&lt;/code&gt; and let it take care of it for you. Really, that&apos;s it!&lt;/p&gt;&lt;h2&gt;&lt;a name=&quot;ss4.2&quot;&gt;&lt;font color=&quot;#000000&quot;&gt;4.2 Setting up the Init Script&lt;/font&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;If you have an existing init script from your distribution, it would probably be best simply to modify it to run the new binary, with the appropriate switches. The switches are... &lt;i&gt;(drumroll please...)&lt;/i&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;code&gt;-u named&lt;/code&gt;, which tells BIND to run as the user &lt;code&gt;named&lt;/code&gt;, rather than &lt;code&gt;root&lt;/code&gt;.&lt;/li&gt;&lt;li&gt;&lt;code&gt;-t /chroot/named&lt;/code&gt;, which tells BIND to chroot itself to the jail that we&apos;ve set up.&lt;/li&gt;&lt;li&gt;&lt;code&gt;-c /etc/named.conf&lt;/code&gt;, which tells BIND where to find its configuration file within the jail.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;The following is the init script I use with my Red Hat 6.0 system. As you can see, it is almost exactly the same as the way it shipped from Red Hat. I haven&apos;t tried the &lt;code&gt;rndc&lt;/code&gt; commands yet, but I can&apos;t see any reason why they shouldn&apos;t work.&lt;/p&gt;&lt;blockquote&gt;&lt;code&gt;&lt;hr /&gt;&lt;pre&gt;
#!/bin/sh
#
# named           This shell script takes care of starting and stopping
#                 named (BIND DNS server).
#
# chkconfig: 345 55 45
# description: named (BIND) is a Domain Name Server (DNS) \
# that is used to resolve host names to IP addresses.
# probe: true
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ ${NETWORKING} = &amp;quot;no&amp;quot; ] &amp;amp;&amp;amp; exit 0
[ -f /usr/local/sbin/named ] || exit 0
[ -f /chroot/named/etc/named.conf ] || exit 0
# See how we were called.
case &amp;quot;$1&amp;quot; in
  start)
        # Start daemons.
        echo -n &amp;quot;Starting named: &amp;quot;
        daemon /usr/local/sbin/named -u named -t /chroot/named -c /etc/named.conf
        echo
        touch /var/lock/subsys/named
        ;;
  stop)
        # Stop daemons.
        echo -n &amp;quot;Shutting down named: &amp;quot;
        killproc named
        rm -f /var/lock/subsys/named
        echo
        ;;
  status)
        status named
        exit $?
        ;;
  restart)
        $0 stop
        $0 start
        exit $?
        ;;
  reload)
        /usr/local/sbin/rndc reload
        exit $?
        ;; 
  probe)
        # named knows how to reload intelligently; we don&apos;t want linuxconf
        # to offer to restart every time
        /usr/local/sbin/rndc reload &amp;gt;/dev/null 2&amp;gt;&amp;amp;1 || echo start
        exit 0
        ;;
  
  *)
        echo &amp;quot;Usage: named {start|stop|status|restart|reload}&amp;quot;
        exit 1
esac
exit 0
&lt;/pre&gt;&lt;hr /&gt;&lt;/code&gt;&lt;/blockquote&gt;&lt;p&gt;As with syslogd, as of Red Hat 7.2 this process is now even easier. There is a file called &lt;code&gt;/etc/sysconfig/named&lt;/code&gt; in which extra parameters for syslogd can be defined. The default &lt;code&gt;/etc/rc.d/init.d/named&lt;/code&gt; on Red Hat 7.2, however, will check for the existance of &lt;code&gt;/etc/named.conf&lt;/code&gt; before starting. You will need to correct this path.&lt;/p&gt;&lt;p&gt;On Caldera OpenLinux systems, you simply need to modify the variables defined at the top, and it will apparently take care of the rest for you:&lt;/p&gt;&lt;blockquote&gt;&lt;code&gt;&lt;pre&gt;
NAME=named
DAEMON=/usr/local/sbin/$NAME
OPTIONS=&amp;quot;-t /chroot/named -u named -c /etc/named.conf&amp;quot;
&lt;/pre&gt;&lt;/code&gt;&lt;/blockquote&gt;&lt;p&gt;And for FreeBSD 4.3, you can edit the &lt;code&gt;rc.conf&lt;/code&gt; file and put in the following:&lt;/p&gt;&lt;blockquote&gt;&lt;code&gt;&lt;pre&gt;
named_enable=&amp;quot;YES&amp;quot;
named_program=&amp;quot;chroot/named/bin/named&amp;quot;
named_flags=&amp;quot;-u named -t /chroot/named -c /etc/namedb/named.conf&amp;quot;
&lt;/pre&gt;&lt;/code&gt;&lt;/blockquote&gt;&lt;h2&gt;&lt;a name=&quot;ss4.3&quot;&gt;&lt;font color=&quot;#000000&quot;&gt;4.3 Configuration Changes&lt;/font&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;You will also have to add or change a few options in your &lt;code&gt;named.conf&lt;/code&gt; to keep the various directories straight. In particular, you should add (or change, if you already have them) the following directives in the &lt;code&gt;options&lt;/code&gt; section:&lt;/p&gt;&lt;blockquote&gt;&lt;code&gt;&lt;pre&gt;
directory &amp;quot;/etc/namedb&amp;quot;;
pid-file &amp;quot;/var/run/named.pid&amp;quot;;
statistics-file &amp;quot;/var/run/named.stats&amp;quot;;
&lt;/pre&gt;&lt;/code&gt;&lt;/blockquote&gt;&lt;p&gt;Since this file is being read by the &lt;code&gt;named&lt;/code&gt; daemon, all the paths are of course relative to the chroot jail. As of this writing, BIND 9 does not support many of the statistics and dump files that previous versions did. Presumably later versions will; if you are running such a version, you may have to add additional entries to cause BIND to write them to the &lt;code&gt;/var/run&lt;/code&gt; directory as well.&lt;/p&gt;&lt;hr /&gt;&lt;h2&gt;&lt;a name=&quot;s5&quot;&gt;&lt;font color=&quot;#000000&quot;&gt;5.&lt;/font&gt;&lt;/a&gt;&lt;a href=&quot;http://www.faqs.org/docs/Linux-HOWTO/Chroot-BIND-HOWTO.html#toc5&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;The End&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;&lt;/h2&gt;&lt;h2&gt;&lt;a name=&quot;ss5.1&quot;&gt;&lt;font color=&quot;#000000&quot;&gt;5.1 Launching BIND&lt;/font&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Everything should be set up, and you should be ready to put your new, more secure BIND into action. Assuming you set up a SysV-style init script, you can simply launch it as:&lt;/p&gt;&lt;blockquote&gt;&lt;code&gt;&lt;pre&gt;
# /etc/rc.d/init.d/named start
&lt;/pre&gt;&lt;/code&gt;&lt;/blockquote&gt;&lt;p&gt;Make sure you kill any old versions of BIND still running before doing this.&lt;/p&gt;&lt;h2&gt;&lt;a name=&quot;ss5.2&quot;&gt;&lt;font color=&quot;#000000&quot;&gt;5.2 That&apos;s It!&lt;/font&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;You can go take a nap now ;-).&lt;/p&gt;&lt;hr /&gt;&lt;h2&gt;&lt;a name=&quot;s6&quot;&gt;&lt;font color=&quot;#000000&quot;&gt;6.&lt;/font&gt;&lt;/a&gt;&lt;a href=&quot;http://www.faqs.org/docs/Linux-HOWTO/Chroot-BIND-HOWTO.html#toc6&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;Appendix - Upgrading BIND Later&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;So, you had BIND 9.1.2 all nicely chrooted and tweaked to your taste... and then you hear this nasty rumour that BIND 9.1.3 is finally out, and you just have to give it a try right away. Do you have to go through this whole long process to install this new version?&lt;/p&gt;&lt;p&gt;Nope. In fact, you really just need to compile the new BIND and install it over top of the old one. Just don&apos;t forget to kill the old version and restart BIND, or it&apos;ll still be the old version running!&lt;/p&gt;&lt;hr /&gt;&lt;h2&gt;&lt;a name=&quot;s7&quot;&gt;&lt;font color=&quot;#000000&quot;&gt;7.&lt;/font&gt;&lt;/a&gt;&lt;a href=&quot;http://www.faqs.org/docs/Linux-HOWTO/Chroot-BIND-HOWTO.html#toc7&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;Appendix - Thanks&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;I&apos;d like to thank the following people for their assistance in the creation of this HOWTO:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Lonny Selinger &lt;code&gt;&amp;lt;lonny at abyss.za.org&amp;gt;&lt;/code&gt; for &amp;quot;testing&amp;quot; the first version of this HOWTO and making sure that I didn&apos;t miss any steps.&lt;/li&gt;&lt;li&gt;Chirik &lt;code&gt;&amp;lt;chirik at CastleFur.COM&amp;gt;&lt;/code&gt;, Dwayne Litzenberger &lt;code&gt;&amp;lt;dlitz at dlitz.net&amp;gt;&lt;/code&gt;, Phil Bambridge &lt;code&gt;&amp;lt;phil.b at cableinet.co.uk&amp;gt;&lt;/code&gt;, Robert Cole &lt;code&gt;&amp;lt;rcole at metrum-datatape.com&amp;gt;&lt;/code&gt;, Colin MacDonald &lt;code&gt;&amp;lt;colinm at telus.net&amp;gt;&lt;/code&gt;, and others for pointing out errors, omissions, and providing other useful advice to make this HOWTO even better.&lt;/li&gt;&lt;li&gt;Erik Wallin &lt;code&gt;&amp;lt;erikw at sec.se&amp;gt;&lt;/code&gt; and Brian Cervenka &lt;code&gt;&amp;lt;brian at zerobelow.org&amp;gt;&lt;/code&gt; for providing good suggestions for further tightening the jail.&lt;/li&gt;&lt;li&gt;Robert Dalton &lt;code&gt;&amp;lt;support at accesswest.com&amp;gt;&lt;/code&gt; for suggesting a couple more example commands, and pointing out BIND 9.2.0&apos;s need of &lt;code&gt;/dev/random&lt;/code&gt;.&lt;/li&gt;&lt;li&gt;Eric McCormick &lt;code&gt;&amp;lt;hostmaster at cybertime.net&amp;gt;&lt;/code&gt; for the FreeBSD 4.3 information.&lt;/li&gt;&lt;li&gt;Tan Zheng Da &lt;code&gt;&amp;lt;tzd at pobox.com&amp;gt;&lt;/code&gt; for the details about the changes in Red Hat 7.2 that make this a little easier.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;And last but certainly not least, I&apos;d like to thank Nakano Takeo &lt;code&gt;&amp;lt;nakano at apm.seikei.ac.jp&amp;gt;&lt;/code&gt; for translating the Chroot-BIND HOWTO into Japanese. You can find his translation at &lt;a href=&quot;http://www.linux.or.jp/JF/JFdocs/Chroot-BIND-HOWTO.html&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;http://www.linux.or.jp/JF/JFdocs/Chroot-BIND-HOWTO.html&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;.&lt;/p&gt;&lt;hr /&gt;&lt;h2&gt;&lt;a name=&quot;s8&quot;&gt;&lt;font color=&quot;#000000&quot;&gt;8.&lt;/font&gt;&lt;/a&gt;&lt;a href=&quot;http://www.faqs.org/docs/Linux-HOWTO/Chroot-BIND-HOWTO.html#toc8&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;Appendix - Document Distribution Policy&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Copyright © Scott Wunsch, 2000-2001. This document may be distributed only subject to the terms set forth in the LDP licence at &lt;a href=&quot;http://metalab.unc.edu/LDP/COPYRIGHT.html&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;http://metalab.unc.edu/LDP/COPYRIGHT.html&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;This HOWTO is free documentation; you can redistribute it and/or modify it under the terms of the LDP licence. It is distributed in the hope that it will be useful, but &lt;b&gt;without any warranty&lt;/b&gt;; without even the impled warranty of merchantability or fitness for a particular purpose. See the LDP licence for more details.&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;http://www.unixwiz.net/techtips/bind9-chroot.html&quot; target=&quot;_blank&quot;&gt;Building and configuring BIND 9 in a chroot jail&lt;/a&gt;&lt;/p&gt;&lt;p&gt;This has turned out to be a very hard document to write: we work on it bits and pieces at a time. Sorry if it&apos;s incomplete. All of our main work has been done on various flavors of Red Hat, Debian, and Fedora Core, but we&apos;ve included notes on porting to other systems as well.&lt;/p&gt;&lt;div id=&quot;toc&quot;&gt;&lt;center&gt;Table of Contents &lt;/center&gt;&lt;ol&gt;&lt;li&gt;&lt;a href=&quot;http://www.unixwiz.net/techtips/bind9-chroot.html#intro&quot; target=&quot;_blank&quot;&gt;&lt;font color=&quot;#0066cc&quot;&gt;&lt;u&gt;Introduction &lt;/u&gt;&lt;/font&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.unixwiz.net/techtips/bind9-chroot.html#jail&quot; target=&quot;_blank&quot;&gt;&lt;font color=&quot;#0066cc&quot;&gt;&lt;u&gt;What&apos;s a &amp;quot;Jail&amp;quot;? &lt;/u&gt;&lt;/font&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.unixwiz.net/techtips/bind9-chroot.html#source&quot; target=&quot;_blank&quot;&gt;&lt;font color=&quot;#0066cc&quot;&gt;&lt;u&gt;Pick up &amp;amp; unpack the source &lt;/u&gt;&lt;/font&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.unixwiz.net/techtips/bind9-chroot.html#build&quot; target=&quot;_blank&quot;&gt;&lt;font color=&quot;#0066cc&quot;&gt;&lt;u&gt;Configure and build &lt;/u&gt;&lt;/font&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.unixwiz.net/techtips/bind9-chroot.html#mkjail&quot; target=&quot;_blank&quot;&gt;&lt;font color=&quot;#0066cc&quot;&gt;&lt;u&gt;Create the jail &lt;/u&gt;&lt;/font&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.unixwiz.net/techtips/bind9-chroot.html#conf&quot; target=&quot;_blank&quot;&gt;&lt;font color=&quot;#0066cc&quot;&gt;&lt;u&gt;Create the configuration files &lt;/u&gt;&lt;/font&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.unixwiz.net/techtips/bind9-chroot.html#perms&quot; target=&quot;_blank&quot;&gt;&lt;font color=&quot;#0066cc&quot;&gt;&lt;u&gt;Verifying permissions &lt;/u&gt;&lt;/font&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.unixwiz.net/techtips/bind9-chroot.html#starting&quot; target=&quot;_blank&quot;&gt;&lt;font color=&quot;#0066cc&quot;&gt;&lt;u&gt;Starting the nameserver &lt;/u&gt;&lt;/font&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.unixwiz.net/techtips/bind9-chroot.html#rndc&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;Daemon control with &lt;b&gt;rndc&lt;/b&gt;&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.unixwiz.net/techtips/bind9-chroot.html#boot&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;Starting named at boot time &lt;/font&gt;&lt;/u&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.unixwiz.net/techtips/bind9-chroot.html#masters&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;Adding local slave zones &lt;/font&gt;&lt;/u&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.unixwiz.net/techtips/bind9-chroot.html#slaves&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;Adding local master zones &lt;/font&gt;&lt;/u&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.unixwiz.net/techtips/bind9-chroot.html#rrndc&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;Remote RNDC &lt;/font&gt;&lt;/u&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.unixwiz.net/techtips/bind9-chroot.html#views&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;Views / Split DNS &lt;/font&gt;&lt;/u&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.unixwiz.net/techtips/bind9-chroot.html#files&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;Files created by &amp;quot;make install&amp;quot; &lt;/font&gt;&lt;/u&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.unixwiz.net/techtips/bind9-chroot.html#port&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;Porting issues &lt;/font&gt;&lt;/u&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.unixwiz.net/techtips/bind9-chroot.html#resources&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;Other resources &lt;/font&gt;&lt;/u&gt;&lt;/a&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;p&gt;We&apos;re particularly fond of the outstanding O&apos;Reilly DNS and BIND book.&lt;/p&gt;&lt;p&gt;But our goal is to make this a one-stop place to figure how to do do this, and we&apos;d be &lt;b&gt;really grateful&lt;/b&gt; if those that were stuck could send us suggestions to clarify. Kindly forward them to&lt;img alt=&quot;[Email address]&quot; align=&quot;middle&quot; src=&quot;http://www.unixwiz.net/images/steve-email.gif&quot; width=&quot;156&quot; height=&quot;16&quot; /&gt;.&lt;/p&gt;&lt;p&gt;&lt;br clear=&quot;all&quot; /&gt;&lt;/p&gt;&lt;h1 id=&quot;intro&quot;&gt;Introduction&lt;/h1&gt;&lt;p&gt;There are plenty of people who&apos;ve written about how to run BIND in a chroot jail, and we&apos;ll add our own experiences. We have done this on a handful of machines and have the routine down pretty well, and anybody else with the same problem set might find this helpful.&lt;/p&gt;&lt;p&gt;We&apos;ve previously run BIND 8 in a jail, and it has always been a horrid nightmare to build and configure because the install paths had to be hacked up on a custom basis, and every operating system put files in different places. BIND 9 has changed this and decide that it all goes into &lt;tt&gt;/usr/local&lt;/tt&gt;. This has made an enormous difference to consultants with widely varied customer bases. Thank you, ISC.&lt;/p&gt;&lt;p&gt;Most of our direct experience is with various flavors of Red Hat Linux, but we&apos;ve set this up on Debian&apos;s &amp;quot;woody&amp;quot; release as well. These instructions are current as of BIND 9.2.2rc1.&lt;/p&gt;&lt;h1 id=&quot;jail&quot;&gt;What&apos;s a &amp;quot;Jail&amp;quot;?&lt;/h1&gt;&lt;p&gt;Though the utility of a nameserver is probably clear to most people reading this tech tip, the concept of &amp;quot;jail&amp;quot; may not be: we&apos;ve been asked to elaborate.&lt;/p&gt;&lt;p&gt;A &amp;quot;jail&amp;quot; is a software mechanism for limiting the ability of a process to access resources outside a very limited area, and it&apos;s done with security in mind. A nameserver often talks to the outside world, and time has shown that &amp;quot;the public internet&amp;quot; is a very hostile environment. Should a flaw in BIND be discovered, it could be exploited by one located anywhere on the planet: by isolating the process inside a jail, this restricts the harm that can be done to a compromised system.&lt;/p&gt;&lt;p&gt;A jail is created using the &lt;tt&gt;chroot()&lt;/tt&gt; system call (named for &amp;quot;change root&amp;quot;), and it&apos;s given a directory name as a parameter. Once this call is made, the root - the top of the directory tree - for this process is changed from &lt;b&gt;/&lt;/b&gt; to the directory given, and there is no way for the process to get outside this area. We typically use &lt;b&gt;/chroot/named&lt;/b&gt; to jail our nameservers, but we&apos;ll note that the &amp;quot;chroot&amp;quot; in the directory name is just a convention: this is not required (e.g., &amp;quot;/usr/local/named&amp;quot; would make a fine jail location too).&lt;/p&gt;&lt;p&gt;By itself, this won&apos;t prevent some flaw in BIND from being exploited, but the worst that happens is that the nameserver is compromised: it can&apos;t be leveraged to taking over the whole system. In this way it&apos;s more of a general safety precaution providing defense in depth.&lt;/p&gt;&lt;p&gt;Much more information on chroot jails can be found in our&lt;a href=&quot;http://www.linux-mag.com/&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;Linux Magazine&lt;/font&gt;&lt;/u&gt;&lt;/a&gt; article:&lt;a href=&quot;http://www.linux-mag.com/2002-12/chroot_01.html&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;Go Directly to Jail - Secure Untrusted Applications with Chroot&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;&lt;/p&gt;&lt;h1 id=&quot;source&quot;&gt;Pick up the source&lt;/h1&gt;&lt;p&gt;Get the source at the Internet Software Consortium, and the home page for BIND is &lt;a href=&quot;http://www.isc.org/products/BIND/&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;http://www.isc.org/products/BIND/&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;. These instructions were written for 9.1.2 on a Red Hat Linux 6.2 system, and we&apos;ll try to keep them updated as we upgrade our and customer systems. We generally try to keep running the latest stable versions - we&apos;re not generally too adventurous with beta.&lt;/p&gt;&lt;p&gt;Our practice is to keep our own build stuff under a &lt;tt&gt;/source&lt;/tt&gt; tree, and to unpack individual sources under it.&lt;/p&gt;&lt;pre class=&quot;codeblock&quot;&gt;
# &lt;b&gt;cd /source&lt;/b&gt;
# &lt;b&gt;gtar -xzvf bind-9.1.2.tar.gz&lt;/b&gt;&lt;/pre&gt;&lt;p&gt;This unbundles everything into a subdirectory with the full name of the package, and the next step is to to configure and build it.&lt;/p&gt;&lt;h1 id=&quot;build&quot;&gt;Configure and build&lt;/h1&gt;&lt;p&gt;The BIND instructions say to simply run &lt;tt&gt;./configure&lt;/tt&gt;, but under Linux a couple of additions are required.&lt;/p&gt;&lt;p&gt;For many years, we have recommended disabling thread support, because in 2.2 kernels, chroot jailing did not work properly. We have never been brave enough to attempt it with more recent kernels, but we&apos;ve been getting reports that threading works fine in 2.6.&lt;/p&gt;&lt;p&gt;In addition, BIND can support IPv6, the next generation IP addresses (current version is IPv4). BIND typically probes for IPv6 support at runtime, but since we are quite sure that we really don&apos;t need this on our networks, we disable it entirely as a safety measure.&lt;/p&gt;&lt;p&gt;NOTE: we prefer to remove any existing nameserver installations (especially those provided by the operating system) before installing the new one. This avoids problems with older versions of key binaries lying around and &lt;i&gt;sometimes&lt;/i&gt; being at the wrong point in the command-search&lt;b&gt;&lt;tt&gt;$PATH&lt;/tt&gt;&lt;/b&gt;.&lt;/p&gt;&lt;p&gt;Under Red Hat Linux (for instance), this means removing three packages before doing installations.&lt;/p&gt;&lt;pre class=&quot;codeblock&quot;&gt;
# &lt;b&gt;rpm -e bind bind-utils caching-nameserver&lt;/b&gt;&lt;/pre&gt;&lt;p&gt;Finally, we want everything installed into the &lt;tt&gt;/usr/local&lt;/tt&gt;hierarchy, so we provide the installation prefix. This said, configuration and installation is quite simple:&lt;/p&gt;&lt;pre class=&quot;codeblock&quot;&gt;
# &lt;b&gt;cd /source/bind-9.1.2&lt;/b&gt;
# &lt;b&gt;./configure --prefix=/usr/local --disable-ipv6&lt;/b&gt;
# &lt;b&gt;make&lt;/b&gt;
# &lt;b&gt;make install&lt;/b&gt;&lt;/pre&gt;&lt;p&gt;This takes about 15 minutes on a dual-CPU 200 MHz Pentium Pro machine and about three minutes on a 1 GHz Pentium III, and it installs around 200 files under &lt;b&gt;&lt;tt&gt;/usr/local&lt;/tt&gt;&lt;/b&gt;. Most of them are &lt;tt&gt;#include&lt;/tt&gt;files for C language programming, and only about a dozen are really needed for a BIND installation. See the complete file list at the end of this document.&lt;/p&gt;&lt;h1 id=&quot;mkjail&quot;&gt;Build and configure the jail&lt;/h1&gt;&lt;p&gt;Creating the actual jail itself is much easier than for BIND 8 because so much trash is &lt;i&gt;not&lt;/i&gt; required - it&apos;s just tremendous. In particular, none of the shared libraries or &lt;tt&gt;named&lt;/tt&gt; binary files are required to live in the jail, and this makes it easier and more secure for us. For more details on our thoughts on chroot operations, see our more detailed tech tip&lt;a href=&quot;http://www.unixwiz.net/techtips/chroot-practices.html&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;Best Practices for UNIX &lt;tt&gt;chroot()&lt;/tt&gt; Operations&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;The initial steps to configure the jail are:&lt;/p&gt;&lt;pre class=&quot;codeblock&quot;&gt;&lt;i&gt;create initial &lt;tt&gt;&lt;b&gt;named&lt;/b&gt;&lt;/tt&gt; user and group&lt;/i&gt;
# &lt;b&gt;groupadd named&lt;/b&gt;
# &lt;b&gt;useradd -g named -d /chroot/named -s /bin/true named&lt;/b&gt;
# &lt;b&gt;passwd -l named&lt;/b&gt;&lt;i&gt;&amp;quot;lock&amp;quot; the account&lt;/i&gt;&lt;i&gt;Remove all the login-related trash under the newly-created home directory&lt;/i&gt;
# &lt;b&gt;rm -rf /chroot/named&lt;/b&gt;&lt;i&gt;Re-create the top level jail directory&lt;/i&gt;
# &lt;b&gt;mkdir -p /chroot/named&lt;/b&gt;
# &lt;b&gt;cd /chroot/named&lt;/b&gt;&lt;i&gt;create the hierarchy&lt;/i&gt;
# &lt;b&gt;mkdir dev&lt;/b&gt;
# &lt;b&gt;mkdir etc&lt;/b&gt;
# &lt;b&gt;mkdir logs&lt;/b&gt;
# &lt;b&gt;mkdir -p var/run&lt;/b&gt;
# &lt;b&gt;mkdir -p conf/secondaries&lt;/b&gt;&lt;i&gt;create the devices, but confirm the major/minor device&lt;/i&gt;&lt;br /&gt;&lt;i&gt;numbers with&lt;/i&gt;   &amp;quot;&lt;tt&gt;ls -lL /dev/zero /dev/null /dev/random&lt;/tt&gt;&amp;quot;
# &lt;b&gt;mknod dev/null c 1 3&lt;/b&gt;
# &lt;b&gt;mknod dev/zero c 1 5&lt;/b&gt;
# &lt;b&gt;mknod dev/random c 1 8&lt;/b&gt;&lt;i&gt;copy the timezone file&lt;/i&gt;
# &lt;b&gt;cp /etc/localtime etc&lt;/b&gt;&lt;/pre&gt;&lt;p&gt;Noticeably absent are any ownership/permissions issues: this is deliberate. We&apos;ll get to it shortly. Note that the &lt;tt&gt;ls&lt;/tt&gt; command used to verify the major/minor device numbers includes the &lt;b&gt;&lt;tt&gt;-L&lt;/tt&gt;&lt;/b&gt; parameter - this follows symbolic links and is required on some platforms such as Solaris.&lt;/p&gt;&lt;h1 id=&quot;conf&quot;&gt;Construct the configuration files&lt;/h1&gt;&lt;p&gt;The &lt;b&gt;&lt;tt&gt;named.conf&lt;/tt&gt;&lt;/b&gt; configuration is central to &lt;tt&gt;named&lt;/tt&gt; operation, and we&apos;ll go through creating it step by step. Though these files can get very complex, our first efforts will be for a minimal caching-only nameserver just to get the whole end-to-end process working correctly. Then we&apos;ll retrofit to add in needed features such as local domains and access controls.&lt;/p&gt;&lt;p&gt;The &lt;b&gt;&lt;tt&gt;named.conf&lt;/tt&gt;&lt;/b&gt; file lives in the jail&apos;s &lt;b&gt;&lt;tt&gt;etc&lt;/tt&gt;&lt;/b&gt; directory, which makes the full path &lt;b&gt;&lt;tt&gt;/chroot/named/etc/named.conf&lt;/tt&gt;&lt;/b&gt;. We usually create a symbolic link to make this visible to the rest of the system at &lt;b&gt;&lt;tt&gt;/etc/named.conf&lt;/tt&gt;&lt;/b&gt;.&lt;/p&gt;&lt;pre class=&quot;codeblock&quot;&gt;
# &lt;b&gt;ln -s /chroot/named/etc/named.conf /etc/named.conf&lt;/b&gt;&lt;/pre&gt;&lt;p&gt;&lt;b&gt;Note&lt;/b&gt; - we&apos;re creating a symbolic link to a file that&lt;i&gt;does not yet exist&lt;/i&gt; - this is confusing. But when we edit the file (the next step), it is created properly.&lt;/p&gt;&lt;p&gt;Now, using your favorite editor, create the first version of the&lt;tt&gt;etc/named.conf&lt;/tt&gt; file. We suspect that some of these parameters are not strictly necessary, as the defaults will do, but we feel that being explicit will make the daemon easier to debug for the new administrator (less searching for key files).&lt;/p&gt;&lt;pre class=&quot;codeblock&quot;&gt;
options {
	directory       &amp;quot;/conf&amp;quot;;
	pid-file        &amp;quot;/var/run/named.pid&amp;quot;;
	statistics-file &amp;quot;/var/run/named.stats&amp;quot;;
	dump-file       &amp;quot;/var/run/named.db&amp;quot;;
	&lt;i&gt;# hide our &amp;quot;real&amp;quot; version number&lt;/i&gt;
	version         &amp;quot;[secured]&amp;quot;;
};
&lt;i&gt;# The root nameservers&lt;/i&gt;
zone &amp;quot;.&amp;quot; {
	type   hint;
	file   &amp;quot;db.rootcache&amp;quot;;
};
&lt;i&gt;# localhost - forward zone&lt;/i&gt;
zone	&amp;quot;localhost&amp;quot; {
	type    master;
	file   &amp;quot;db.localhost&amp;quot;;
	notify  no;
};
&lt;i&gt;# localhost - inverse zone&lt;/i&gt;
zone    &amp;quot;0.0.127.in-addr.arpa&amp;quot; {
	type   master;
	file   &amp;quot;db.127.0.0&amp;quot;;
	notify no;
};
&lt;/pre&gt;&lt;p&gt;Notice that the &lt;b&gt;&lt;tt&gt;directory&lt;/tt&gt;&lt;/b&gt; keyword says &lt;b&gt;&lt;tt&gt;/conf&lt;/tt&gt;&lt;/b&gt;, not&lt;b&gt;&lt;tt&gt;/chroot/named/conf&lt;/tt&gt;&lt;/b&gt; - this is intended. When running the nameserver inside the chroot jail, all the paths are&lt;i&gt;relative to the top of the jail&lt;/i&gt; at &lt;b&gt;&lt;tt&gt;/chroot/named&lt;/tt&gt;&lt;/b&gt;.&lt;/p&gt;&lt;p&gt;This configuration refers to three additional files -- &lt;b&gt;&lt;tt&gt;db.rootcache&lt;/tt&gt;&lt;/b&gt;,&lt;b&gt;&lt;tt&gt;db.localhost&lt;/tt&gt;&lt;/b&gt; and &lt;b&gt;&lt;tt&gt;db.127.0.0&lt;/tt&gt;&lt;/b&gt; -- and they are all created in the&lt;b&gt;&lt;tt&gt;/chroot/named/conf&lt;/tt&gt;&lt;/b&gt; directory.&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;tt&gt;db.rootcache&lt;/tt&gt;&lt;/b&gt; is a list of the roughly dozen &amp;quot;root servers&amp;quot; which are the starting points for virtually every name query done throughout the internet, and the latter describes the &amp;quot;localhost&amp;quot; address. Creating &lt;b&gt;&lt;tt&gt;conf/db.rootcache&lt;/tt&gt;&lt;/b&gt; file can usually be done automatically by querying the root nameservers directly.&lt;/p&gt;&lt;p&gt;If the current machine has working nameservers (say, via your ISP), you can just run the command:&lt;/p&gt;&lt;pre class=&quot;codeblock&quot;&gt;
# &lt;b&gt;dig +tcp @a.root-servers.net . ns &amp;gt; /chroot/named/conf/db.rootcache&lt;/b&gt;&lt;/pre&gt;&lt;p&gt;The &lt;b&gt;+tcp&lt;/b&gt; option is require to get the full reply, not the truncated version due to UDP packet limits. In the absense of any working nameservice, a recent version of the file can be found &lt;a href=&quot;http://www.unixwiz.net/techtips/db.rootcache&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;here&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;The two other required files serve to administrate the &amp;quot;localhost&amp;quot; address, and the files are static and need not really be understood:&lt;/p&gt;&lt;div class=&quot;blocklabel&quot;&gt;db.localhost&lt;/div&gt;&lt;pre class=&quot;codeblock&quot;&gt;
;
; db.localhost
;
$TTL    86400
@       IN SOA   @ root (
                        42              ; serial (d. adams)
                        3H              ; refresh
                        15M             ; retry
                        1W              ; expiry
                        1D )            ; minimum
        IN NS        @
        IN A         127.0.0.1
&lt;/pre&gt;&lt;div class=&quot;blocklabel&quot;&gt;db.127.0.0&lt;/div&gt;&lt;pre class=&quot;codeblock&quot;&gt;
;
; db.127.0.0
;
$TTL    86400
@       IN      SOA     localhost. root.localhost.  (
                            1 ; Serial
                            28800      ; Refresh
                            14400      ; Retry
                            3600000    ; Expire
                            86400 )    ; Minimum
        IN      NS      localhost.
1       IN      PTR     localhost.
&lt;/pre&gt;&lt;p&gt;They should be created one time, and thereafter won&apos;t ever be administered again.&lt;/p&gt;&lt;h1 id=&quot;perms&quot;&gt;Verifying permissions&lt;/h1&gt;&lt;p&gt;Now we&apos;ve created the files required inside the jail, but the matter of setting the permissions and ownership remains. It&apos;s possible to do this by hand, but unreliable: it&apos;s very hard to &amp;quot;keep up&amp;quot; with making sure that everything is set correctly on an ongoing basis. So we typically create a small shell script that will run through the entire jail and affirmatively set everything.&lt;/p&gt;&lt;p&gt;We typically put this in &lt;b&gt;&lt;tt&gt;/chroot/named.perms&lt;/tt&gt;&lt;/b&gt; - it lives &lt;i&gt;outside&lt;/i&gt;the jail itself - and we&apos;ve found that the same file has been usable without change on all of our installations.&lt;/p&gt;&lt;pre class=&quot;codeblock&quot;&gt;&lt;i&gt;#
# named.perms
#
#   Set the ownership and permissions on the named directory
#&lt;/i&gt;&lt;b&gt;cd /chroot/named&lt;/b&gt;&lt;i&gt;
# By default, root owns &lt;b&gt;everything&lt;/b&gt; and only root can write, but dirs
# have to be executable too. Note that some platforms use a dot
# instead of a colon between user/group in the &lt;tt&gt;chown&lt;/tt&gt; parameters}&lt;/i&gt;&lt;b&gt;chown -R root:named .&lt;/b&gt;&lt;b&gt;find . -type f -print | xargs chmod u=rw,og=r&lt;/b&gt;&lt;i&gt;# regular files&lt;/i&gt;&lt;b&gt;find . -type d -print | xargs chmod u=rwx,og=rx&lt;/b&gt;&lt;i&gt;# directories&lt;/i&gt;&lt;i&gt;# the named.conf and rndc.conf must protect their keys&lt;/i&gt;&lt;b&gt;chmod o= etc/*.conf&lt;/b&gt;&lt;i&gt;# the &amp;quot;secondaries&amp;quot; directory is where we park files from
# master nameservers, and named needs to be able to update
# these files and create new ones.&lt;/i&gt;&lt;b&gt;touch conf/secondaries/.empty&lt;/b&gt;&lt;i&gt;# placeholder&lt;/i&gt;&lt;b&gt;find conf/secondaries/ -type f -print | xargs chown named:named&lt;/b&gt;&lt;b&gt;find conf/secondaries/ -type f -print | xargs chmod ug=r,o=&lt;/b&gt;&lt;b&gt;chown root:named conf/secondaries/&lt;/b&gt;&lt;b&gt;chmod ug=rwx,o=  conf/secondaries/&lt;/b&gt;&lt;i&gt;# the var/run business is for the PID file&lt;/i&gt;&lt;b&gt;chown root:root  var/&lt;/b&gt;&lt;b&gt;chmod u=rwx,og=x var/&lt;/b&gt;&lt;b&gt;chown root:named  var/run/&lt;/b&gt;&lt;b&gt;chmod ug=rwx,o=rx var/run/&lt;/b&gt;&lt;i&gt;# named has to be able to create logfiles&lt;/i&gt;&lt;b&gt;chown root:named  logs/&lt;/b&gt;&lt;b&gt;chmod ug=rwx,o=rx logs/&lt;/b&gt;&lt;/pre&gt;&lt;p&gt;The &amp;quot;placeholder&amp;quot; file simply insures that the &lt;tt&gt;secondaries&lt;/tt&gt; directory is not empty, and it prevents the script from generating (harmless) error messages.&lt;/p&gt;&lt;p&gt;It&apos;s &lt;i&gt;absolutely&lt;/i&gt; necessary to run this at least once after setting things up, and periodically whenever changes are made. The command to run this is &lt;b&gt;&lt;tt&gt;sh /chroot/named.perms&lt;/tt&gt;&lt;/b&gt;, but the &lt;b&gt;&lt;tt&gt;-x&lt;/tt&gt;&lt;/b&gt; option can be added if you want to watch it run:&lt;/p&gt;&lt;pre class=&quot;codeblock&quot;&gt;
# &lt;b&gt;sh -x /chroot/named.perms&lt;/b&gt;
+ cd /chroot/named
+ chown -R root:named .
+ find . -type f -print
+ xargs chmod u=rw,og=r
+ find . -type d -print
+ xargs chmod u=rwx,og=rx
+ chmod o= etc/named.conf etc/rndc.conf
+ touch conf/secondaries/.empty
+ find conf/secondaries/ -type f -print
+ xargs chown named:named
+ find conf/secondaries/ -type f -print
+ xargs chmod ug=r,o=
+ chown root:named conf/secondaries/
+ chmod ug=rwx,o= conf/secondaries/
+ chown root:root var/
+ chmod u=rwx,og=x var/
+ chown root:named var/run/
+ chmod ug=rwx,o=rx var/run/
&lt;/pre&gt;&lt;p&gt;A few notes on the files in the jail:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;It&apos;s not clear that splitting up the &lt;b&gt;&lt;tt&gt;etc/&lt;/tt&gt;&lt;/b&gt; and &lt;b&gt;&lt;tt&gt;conf/&lt;/tt&gt;&lt;/b&gt; directories is necessary, but we&apos;ve done it this way for a long time and it seems to be a habit. We could probably put everything in &lt;b&gt;&lt;tt&gt;conf/&lt;/tt&gt;&lt;/b&gt; (or &lt;b&gt;&lt;tt&gt;etc/&lt;/tt&gt;&lt;/b&gt;) with no impact on safety.&lt;/li&gt;&lt;li&gt;&lt;p&gt;The &lt;b&gt;&lt;tt&gt;conf/secondaries/&lt;/tt&gt;&lt;/b&gt; directory holds the transferred zone files received from the master nameservers, and they are in a separate place for two reasons. One, it helps separate files that you&apos;re allowed to modify (the master files) from those that you&apos;re not (the secondary).&lt;/p&gt;&lt;p&gt;But more importantly, even the nameserver user itself should not modify your master files, which could be possible if a vulnerability allowed a remote bad guy to run arbitrary code. If the &lt;b&gt;&lt;tt&gt;db.master.com&lt;/tt&gt;&lt;/b&gt; files&lt;i&gt;or its directory&lt;/i&gt; is writable, the bad guy could hijack a domain this way (with substantial effort). By putting the secondaries in a writable area, it limits the damage that can occur this way and helps keep things organized well.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;&lt;tt&gt;named&lt;/tt&gt;&lt;/b&gt; needs to puts its process ID somewhere, and this is usually in some variant of &lt;b&gt;&lt;tt&gt;/var/run/named.pid&lt;/tt&gt;&lt;/b&gt;. This name is mentioned in the &lt;b&gt;&lt;tt&gt;named.conf&lt;/tt&gt;&lt;/b&gt; file, recalling that it&apos;s relative to the jail&apos;s top directory:&lt;pre class=&quot;codeblock&quot;&gt;
options {
	pid-file	&amp;quot;&lt;b&gt;/var/run/named.pid&lt;/b&gt;&amp;quot;;
	...
};
&lt;/pre&gt;&lt;/li&gt;&lt;li&gt;The &lt;b&gt;&lt;tt&gt;etc/named.conf&lt;/tt&gt;&lt;/b&gt; and &lt;b&gt;&lt;tt&gt;etc/rndc.conf&lt;/tt&gt;&lt;/b&gt; files will soon both contain the secret key used to manage the nameserver, and this key must be protected from disclosure by making both files unreadable by anybody other than root or the named group. This is important.&lt;/li&gt;&lt;/ul&gt;&lt;h1 id=&quot;starting&quot;&gt;Starting the nameserver&lt;/h1&gt;&lt;p&gt;We&apos;re just about ready to try starting the nameserver, but since the daemon requires several key parameters - that we &lt;i&gt;cannot&lt;/i&gt; omit - we prefer to put the full command in a script file. This small script is placed in &lt;b&gt;&lt;tt&gt;/chroot/named.start&lt;/tt&gt;&lt;/b&gt;:&lt;/p&gt;&lt;pre class=&quot;codeblock&quot;&gt;&lt;i&gt;#
# named.start
#
#       Note: the path given to the &amp;quot;-c&amp;quot; parameter is relative
#       to the jail&apos;s root, not the system root.
#
#       Add &amp;quot;-n2&amp;quot; if you have multiple CPUs
#
# usage: named [-c conffile] [-d debuglevel] [-f|-g] [-n number_of_cpus]
#              [-p port] [-s] [-t chrootdir] [-u username]&lt;/i&gt;&lt;b&gt;cd /chroot/named&lt;/b&gt;&lt;i&gt;# make sure the debugging-output file is writable by named&lt;/i&gt;&lt;b&gt;touch named.run
chown named:named named.run
chmod ug=rw,o=r   named.run
PATH=/usr/local/sbin:$PATH named  \
        -t /chroot/named \
        -u named \
        -c /etc/named.conf&lt;/b&gt;&lt;/pre&gt;&lt;p&gt;and made executable with &lt;b&gt;&lt;tt&gt;chmod a+x /chroot/named.start&lt;/tt&gt;&lt;/b&gt;. We will&lt;i&gt;never&lt;/i&gt; start the nameserver with just a &amp;quot;&lt;b&gt;&lt;tt&gt;named&lt;/tt&gt;&lt;/b&gt;&amp;quot; command - we must use the script. So let&apos;s do so:&lt;/p&gt;&lt;pre class=&quot;codeblock&quot;&gt;
# &lt;b&gt;&lt;tt&gt;sh /chroot/named.start&lt;/tt&gt;&lt;/b&gt;&lt;/pre&gt;&lt;p&gt;If all is well, the nameserver will start running quietly, and the &lt;b&gt;&lt;tt&gt;ps -fCnamed&lt;/tt&gt;&lt;/b&gt;command may show it running in the background. It should now be ready to accept nameserver requests, and we can test it with the &lt;b&gt;&lt;tt&gt;dig&lt;/tt&gt;&lt;/b&gt; command. Though we&apos;ll need to modify the file &lt;b&gt;&lt;tt&gt;/etc/resolv.conf&lt;/tt&gt;&lt;/b&gt; to contain the local machine&apos;s address.&lt;/p&gt;&lt;h1 id=&quot;rndc&quot;&gt;Daemon control with rndc&lt;/h1&gt;&lt;p&gt;Very old BIND nameservers relied on UNIX signals to control their behavior, and this has always been a lousy mechanism. BIND 8 introduced a &lt;b&gt;&lt;tt&gt;ndc&lt;/tt&gt;&lt;/b&gt; command that communicated over a control channel (a UNIX domain socket), but BIND 9 is now doing this via a TCP socket. This allows for &lt;i&gt;remote&lt;/i&gt; operation (say, reloading it) of the nameserver. The old &lt;b&gt;&lt;tt&gt;ndc&lt;/tt&gt;&lt;/b&gt; command is gone, replaced with &lt;b&gt;&lt;tt&gt;rndc&lt;/tt&gt;&lt;/b&gt;, though not all of the commands are implmented yet.&lt;/p&gt;&lt;p&gt;Configuring &lt;tt&gt;rndc&lt;/tt&gt; is a little tricky: BIND supports substantial functionality that involves the use of keys, and &lt;b&gt;&lt;tt&gt;rndc&lt;/tt&gt;&lt;/b&gt; uses just a small part of it. This is aggravated by the fact that getting even a little bit of this wrong will cause the mechanism to fail without meaningful diagnostics. It&apos;s been very frustrating.&lt;/p&gt;&lt;p&gt;The &lt;b&gt;&lt;tt&gt;rndc&lt;/tt&gt;&lt;/b&gt; command reads the file &lt;b&gt;&lt;tt&gt;/usr/local/etc/rndc.conf&lt;/tt&gt;&lt;/b&gt; for its configuration data, but we prefer to locate this file under our chroot area to keep an eye on the permissions and ownership. We&apos;ll create a link between the two shortly, but we prefer to build the file first.&lt;/p&gt;&lt;pre class=&quot;codeblock&quot;&gt;
#
# /chroot/named/etc/rndc.conf
#
options {
        default-server  127.0.0.1;
        default-key     &amp;quot;rndckey&amp;quot;;
};
server 127.0.0.1 {
        key     &amp;quot;rndckey&amp;quot;;
};
key &amp;quot;rndckey&amp;quot; {
        algorithm       &amp;quot;hmac-md5&amp;quot;;
        secret          &amp;quot;&lt;i&gt;secret key here&lt;/i&gt;&amp;quot;;
};
&lt;/pre&gt;&lt;p&gt;As with &lt;b&gt;&lt;tt&gt;named.conf&lt;/tt&gt;&lt;/b&gt;, the format is very peculiar and requires that all the semicolons go in the right places. In this file, the token &lt;b&gt;&lt;tt&gt;&amp;quot;rndckey&amp;quot;&lt;/tt&gt;&lt;/b&gt; is just the name of this key (as opposed to those keys required for other purposes), and any word could be used as long as they all agree in this file.&lt;/p&gt;&lt;p&gt;The variable part is the &amp;quot;secret&amp;quot;, which is a long string of base-64-encoded data, and the BIND distribution provides a mechanism for creating one of these keys. The &lt;b&gt;&lt;tt&gt;dnssec-keygen&lt;/tt&gt;&lt;/b&gt; is used for generating multiple kinds of keys, and in our case we just care about generating one of them. We&apos;ll create the key into a file, then copy that key to our config file:&lt;/p&gt;&lt;pre class=&quot;codeblock&quot;&gt;
# &lt;b&gt;&lt;tt&gt;cd /chroot/named/etc&lt;/tt&gt;&lt;/b&gt;
# &lt;b&gt;&lt;tt&gt;/usr/local/sbin/dnssec-keygen -a HMAC-MD5 -b 256 -n HOST rndc&lt;/tt&gt;&lt;/b&gt;
Krndc.+157+13856
# &lt;b&gt;&lt;tt&gt;cat Krndc.+157+13856.private&lt;/tt&gt;&lt;/b&gt;
Private-key-format: v1.2
Algorithm: 157 (HMAC_MD5)
Key: hU9utBAdP6/dVKKfxOlv0bPOTnAd4A1qosMbs/dwVJI=
...
# &lt;b&gt;&lt;tt&gt;rm Krndc.+157+13856.*&lt;/tt&gt;&lt;/b&gt;&lt;i&gt;after key has been saved&lt;/i&gt;&lt;/pre&gt;&lt;blockquote&gt;&lt;b&gt;Odd note&lt;/b&gt;: we&apos;ve seen the &lt;b&gt;&lt;tt&gt;dnssec-keygen&lt;/tt&gt;&lt;/b&gt; program simply hang for long periods of time even on very fast machines, and upon investigation found that there was no available random numbers from the &lt;b&gt;&lt;tt&gt;/dev/random&lt;/tt&gt;&lt;/b&gt; device (!). The system collects entropy (aka &amp;quot;randomness&amp;quot;) into a pool, and when it&apos;s depleted for whatever reason, it waits for more to show up. To get around this, add the &lt;nobr&gt;@BTT{-r /dev/urandom}&lt;/nobr&gt; option to the command line just before the &lt;b&gt;&lt;tt&gt;-a&lt;/tt&gt;&lt;/b&gt;option: this pulls from a different device that won&apos;t block on depleted entropy.&lt;/blockquote&gt;&lt;p&gt;The &lt;b&gt;&lt;tt&gt;Krndc.+157+13856&lt;/tt&gt;&lt;/b&gt; is the name of the key, and we don&apos;t believe that any part of this name is interesting to us. The key itself is created into output filenames based on the key name: &lt;tt&gt;&lt;i&gt;kname&lt;/i&gt;&lt;b&gt;.key&lt;/b&gt;&lt;/tt&gt;and &lt;tt&gt;&lt;i&gt;kname&lt;/i&gt;&lt;b&gt;.private&lt;/b&gt;&lt;/tt&gt;. We see above the contents of the private key file, and the key itself is&lt;b&gt;&lt;tt&gt;hU9utBAdP6/dVKKfxOlv0bPOTnAd4A1qosMbs/dwVJI=&lt;/tt&gt;&lt;/b&gt;. This data must be inserted into the &lt;b&gt;&lt;tt&gt;rndc.conf&lt;/tt&gt;&lt;/b&gt; file:&lt;/p&gt;&lt;pre class=&quot;codeblock&quot;&gt;
...
key &amp;quot;rndckey&amp;quot; {
        algorithm       &amp;quot;hmac-md5&amp;quot;;
        secret          &amp;quot;&lt;b&gt;hU9utBAdP6/dVKKfxOlv0bPOTnAd4A1qosMbs/dwVJI=&lt;/b&gt;&amp;quot;;
};
&lt;/pre&gt;&lt;p&gt;Now the &lt;b&gt;&lt;tt&gt;rndc.conf&lt;/tt&gt;&lt;/b&gt; file is created, the &amp;quot;key&amp;quot; files created by&lt;nobr&gt;&lt;b&gt;&lt;tt&gt;dnssec-keygen&lt;/tt&gt;&lt;/b&gt;&lt;/nobr&gt; can be deleted. We also wish to make this config file visible to the &lt;b&gt;&lt;tt&gt;rndc&lt;/tt&gt;&lt;/b&gt; program directly: it&apos;s looking in &lt;b&gt;&lt;tt&gt;/usr/local/etc/rndc.conf&lt;/tt&gt;&lt;/b&gt; for its configuration information. To do this, we perform a symbolic link:&lt;/p&gt;&lt;pre class=&quot;codeblock&quot;&gt;
# &lt;b&gt;ln -s /chroot/named/etc/rndc.conf /usr/local/etc/rndc.conf&lt;/b&gt;
# &lt;b&gt;ln -s /chroot/named/etc/rndc.conf /etc/rndc.conf&lt;/b&gt;&lt;/pre&gt;&lt;p&gt;Note that we also have &lt;b&gt;&lt;tt&gt;/etc/rndc.conf&lt;/tt&gt;&lt;/b&gt; point to the real file: this is simply as a convenience for the administrator who has to edit this file often - it&apos;s easier to type.&lt;/p&gt;&lt;p&gt;Now, the nameserver itself must be configured to listen on a control channel and use this particular key. In the same &lt;b&gt;&lt;tt&gt;/chroot/named/etc&lt;/tt&gt;&lt;/b&gt;directory, we reconsider the &lt;b&gt;&lt;tt&gt;named.conf&lt;/tt&gt;&lt;/b&gt; file: We must add two sections &lt;i&gt;to the beginning of this file&lt;/i&gt;. We add a &lt;b&gt;&lt;tt&gt;controls&lt;/tt&gt;&lt;/b&gt;section that describes the network addresses that &lt;b&gt;&lt;tt&gt;named&lt;/tt&gt;&lt;/b&gt; will listen on, and a &lt;b&gt;&lt;tt&gt;key&lt;/tt&gt;&lt;/b&gt; section describes the key it will use. Copy the secret key from above into the file in the obvious place:&lt;/p&gt;&lt;pre class=&quot;codeblock&quot;&gt;
controls {
        inet 127.0.0.1 allow { 127.0.0.1; } keys { rndckey; };
};
key &amp;quot;rndckey&amp;quot; {
        algorithm       &amp;quot;hmac-md5&amp;quot;;
        secret          &amp;quot;hU9utBAdP6/dVKKfxOlv0bPOTnAd4A1qosMbs/dwVJI=&amp;quot;;
};
...
&lt;/pre&gt;&lt;p&gt;&lt;b&gt;Note&lt;/b&gt; - previous versions of this document have suggested that the actual key name doesn&apos;t matter, but this has proven to be false. Once a key has a name, everybody has to agree on what that name is or things will fail outright.&lt;/p&gt;&lt;p&gt;The &lt;b&gt;&lt;tt&gt;controls&lt;/tt&gt;&lt;/b&gt;and &lt;b&gt;&lt;tt&gt;key&lt;/tt&gt;&lt;/b&gt; sections must be &lt;i&gt;first&lt;/i&gt; in the file: we&apos;re not sure&lt;i&gt;why&lt;/i&gt; it&apos;s a rule, but we&apos;re sure it &lt;i&gt;is&lt;/i&gt; a rule.&lt;/p&gt;&lt;p&gt;This configuration tells &lt;b&gt;&lt;tt&gt;named&lt;/tt&gt;&lt;/b&gt; to listen &lt;i&gt;only&lt;/i&gt; on the localhost interface, and as such won&apos;t accept any connections from the rest of the network. This is a useful security precaution, though it&apos;s possible to &amp;quot;open&amp;quot; the nameserver to accept connections from trusted others. Both of these config files contain these important private keys, so they must not be readable to nonprivileged users.&lt;/p&gt;&lt;p&gt;Now that the keys and controls have been set up properly, it&apos;s necessary to kick the nameserver to force it to reread the file. Simply send a SIGHUP (a &lt;b&gt;&lt;tt&gt;-1&lt;/tt&gt;&lt;/b&gt;) to the nameserver&lt;/p&gt;&lt;pre class=&quot;codeblock&quot;&gt;
# &lt;b&gt;&lt;tt&gt;ps -fCnamed&lt;/tt&gt;&lt;/b&gt;
UID        PID  PPID  C STIME TTY          TIME CMD
named    &lt;b&gt;12527&lt;/b&gt;     1  0 12:42 ?        00:00:00 named -t /chroot/named {...}
# &lt;b&gt;&lt;tt&gt;kill -1 12527&lt;/tt&gt;&lt;/b&gt;&lt;i&gt;12527 is process ID&lt;/i&gt;&lt;/pre&gt;&lt;p&gt;Now the nameserver should have reread the configuration files and started listening on the control interface. Now let&apos;s try &lt;b&gt;&lt;tt&gt;rndc&lt;/tt&gt;&lt;/b&gt;:&lt;/p&gt;&lt;pre class=&quot;codeblock&quot;&gt;
# &lt;b&gt;&lt;tt&gt;/usr/local/sbin/rndc status&lt;/tt&gt;&lt;/b&gt;
number of zones: 2
debug level: 0
xfers running: 0
xfers deferred: 0
soa queries in progress: 0
query logging is OFF
server is up and running
&lt;/pre&gt;&lt;p&gt;This indicates that all is well: the keys are correct. But a common error seen from a bad configuration is:&lt;/p&gt;&lt;pre class=&quot;codeblock&quot;&gt;
rndc: send remote authenticator: permission denied
&lt;/pre&gt;&lt;p&gt;This is often the only diagnostics seen, and it means you have to doublecheck your configuration files. We&apos;re sorry that we can&apos;t offer much more useful guidance on this front. We&apos;ll add notes as we find them.&lt;/p&gt;&lt;h1 id=&quot;boot&quot;&gt;Starting named at boot time&lt;/h1&gt;&lt;p&gt;Now that named is running correctly after being started &amp;quot;by hand&amp;quot;, we usually wish for it to start automatically at boot time. The mechanism for this depends somewhat on the particular operating system, but we can give some overall guidelines. Automatic starting at boot time requires a base &amp;quot;init&amp;quot; file plus a couple of symbolic links.&lt;/p&gt;&lt;p&gt;The &amp;quot;base&amp;quot; startup file a small shell script that can start or stop the nameserver, and our version looks like:&lt;/p&gt;&lt;pre class=&quot;codeblock&quot;&gt;&lt;i&gt;#!/bin/sh&lt;/i&gt;&lt;i&gt;#&lt;/i&gt;&lt;i&gt;# named&lt;/i&gt;&lt;i&gt;#&lt;/i&gt;
export PATH=/usr/local/sbin:$PATH       &lt;i&gt;# needed for rndc&lt;/i&gt;
case &amp;quot;$1&amp;quot; in
  start)
        &lt;i&gt;# Start daemons.&lt;/i&gt;
        echo -n &amp;quot;Starting named: &amp;quot;
        sh /chroot/named.start
        echo
        ;;
  stop)
        &lt;i&gt;# Stop daemons.&lt;/i&gt;
        echo -n &amp;quot;Shutting down named: &amp;quot;
        rndc stop
        echo &amp;quot;done&amp;quot;
        ;;
esac
exit 0
&lt;/pre&gt;&lt;p&gt;We only support &lt;b&gt;&lt;tt&gt;start&lt;/tt&gt;&lt;/b&gt; and &lt;b&gt;&lt;tt&gt;stop&lt;/tt&gt;&lt;/b&gt; commands, and this has been more than good enough for us: those wanting a more &amp;quot;full featured&amp;quot; control file are welcome to be adventurous. Be sure to make the file executable: &lt;nobr&gt;&lt;b&gt;&lt;tt&gt;chmod a+x named&lt;/tt&gt;&lt;/b&gt;&lt;/nobr&gt;.&lt;/p&gt;&lt;p&gt;Once the startup script is in place, we have to make some symbolic links to make it start in the appropriate runlevels. The filenames are modified from the &amp;quot;base&amp;quot; name to account for the order in which things are started: we want the nameserver to start just after the IP subsystem has started because so many of the other daemons depend on nameservice.&lt;/p&gt;&lt;p&gt;Locating this init file depends on the operating system, and we&apos;ll make notes in this table as we learn about them.&lt;/p&gt;&lt;p&gt;&lt;table class=&quot;standard&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;th&gt;Operating System&lt;/th&gt;&lt;th&gt;startup script&lt;/th&gt;&lt;th&gt;runlevel 2 file&lt;/th&gt;&lt;th&gt;runlevel 3 file&lt;/th&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Red Hat Linux 6.X / 7.X&lt;/td&gt;&lt;td&gt;&lt;b&gt;&lt;tt&gt;/etc/rc.d/init.d/named&lt;/tt&gt;&lt;/b&gt;&lt;/td&gt;&lt;td&gt;&lt;b&gt;&lt;tt&gt;/etc/rc.d/rc2.d/S11named&lt;/tt&gt;&lt;/b&gt;&lt;/td&gt;&lt;td&gt;&lt;b&gt;&lt;tt&gt;/etc/rc.d/rc3.d/S11named&lt;/tt&gt;&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Debian &amp;quot;Woody&amp;quot;&lt;/td&gt;&lt;td&gt;&lt;b&gt;&lt;tt&gt;/etc/init.d/named&lt;/tt&gt;&lt;/b&gt;&lt;/td&gt;&lt;td&gt;&lt;b&gt;&lt;tt&gt;/etc/rc2.d/S18named&lt;/tt&gt;&lt;/b&gt;&lt;/td&gt;&lt;td&gt;&lt;b&gt;&lt;tt&gt;/etc/rc3.d/S18named&lt;/tt&gt;&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/p&gt;&lt;p&gt;To create the &amp;quot;rc&amp;quot; files, we use symbolic links. This sample is for the Red Hat Linux organization, and it can be altered for your operating system. We also believe that other runlevels are used for things like X11 windowing, but we don&apos;t ever use them. Your mileage may vary.&lt;/p&gt;&lt;pre class=&quot;codeblock&quot;&gt;
# &lt;b&gt;cd /etc/rc.d&lt;/b&gt;
# &lt;b&gt;ln -s ../init.d/named rc2.d/S11named&lt;/b&gt;
# &lt;b&gt;ln -s ../init.d/named rc3.d/S11named&lt;/b&gt;&lt;/pre&gt;&lt;p&gt;We recommend rebooting the system once to be sure that the nameserver starts properly on an automatic basis: it&apos;s very frustrating to have a power outage (say) three months from now and find out that DNS is not available: better to test this while your mind is thinking about nameservice.&lt;/p&gt;&lt;h1 id=&quot;slaves&quot;&gt;Adding local slave zones&lt;/h1&gt;&lt;p&gt;(to be determined)&lt;/p&gt;&lt;h1 id=&quot;masters&quot;&gt;Adding local master zones&lt;/h1&gt;&lt;p&gt;(to be determined)&lt;/p&gt;&lt;h1 id=&quot;rrndc&quot;&gt;Remote RNDC&lt;/h1&gt;&lt;p&gt;The nameserver as installed only accepts &lt;b&gt;&lt;tt&gt;rndc&lt;/tt&gt;&lt;/b&gt; requests from the local system, but it&apos;s possible to do so over the network with a few changes in the config file.&lt;/p&gt;&lt;p&gt;The change is made in the &lt;b&gt;&lt;tt&gt;named.conf&lt;/tt&gt;&lt;/b&gt; file, and we add an entry to the &lt;b&gt;&lt;tt&gt;controls&lt;/tt&gt;&lt;/b&gt; section. The addition is made here in bold:&lt;/p&gt;&lt;pre class=&quot;codeblock&quot;&gt;
`
controls {
        inet 127.0.0.1    allow { 127.0.0.1; } keys { rndckey; };
&lt;b&gt;
        inet 192.168.1.31 allow { 127.0.0.1;         # localhost
                                  192.168.1.0/24;    # local Ethernet
                                  10.1.2.0/24;       # network at home
                                  172.27.217.6;      # our consultant
                          } keys { rndckey; };&lt;/b&gt;
};
...
&lt;/pre&gt;&lt;p&gt;The first &lt;b&gt;&lt;tt&gt;inet&lt;/tt&gt;&lt;/b&gt; line requests that &lt;b&gt;&lt;tt&gt;named&lt;/tt&gt;&lt;/b&gt; listed on the localhost interface only, but the second requests that it listen on the computer&apos;s public Ethernet address (here, &lt;b&gt;192.168.1.31&lt;/b&gt;). The access control lines limit the connections to addresses in the given list, and we can include as many as desired in either single IP address notation or &lt;b&gt;&lt;tt&gt;/nbits&lt;/tt&gt;&lt;/b&gt; netbits notation. Be careful to put semicolons in all places that matter - it&apos;s easy to get wrong.&lt;/p&gt;&lt;p&gt;Now the config files must be reread: but if we&apos;re &lt;i&gt;adding&lt;/i&gt; a new interface to listen on, we have to &lt;i&gt;fully stop and restart&lt;/i&gt; the daemon. Since we&apos;ve configured it to run as a non-root user, it&apos;s simply not able to bind to the privileged port (953/tcp) on the additional interface. So we must stop and restart.&lt;/p&gt;&lt;p&gt;Now to the remote machine.&lt;/p&gt;&lt;p&gt;On some other machine that&apos;s in the access list of the nameserver to be controlled, we must modify &lt;b&gt;&lt;tt&gt;rndc.conf&lt;/tt&gt;&lt;/b&gt; to add the keys. We presume here that the &lt;b&gt;&lt;tt&gt;rndc.conf&lt;/tt&gt;&lt;/b&gt; file will be controlling the local machine as well as the remote ones, so we&apos;ll be adding to the file, not modifying it.&lt;/p&gt;&lt;pre class=&quot;codeblock&quot;&gt;
#
# /chroot/named/etc/rndc.conf
#
options {
        default-server  127.0.0.1;
        default-key     &amp;quot;rndckey&amp;quot;;
};
server 127.0.0.1 {
        key     &amp;quot;rndckey&amp;quot;;
};
key &amp;quot;rndckey&amp;quot; {
        algorithm       &amp;quot;hmac-md5&amp;quot;;
        secret          &amp;quot;hU9utBAdP6/dVKKfxOlv0bPOTnAd4A1qosMbs/dwVJI=&amp;quot;;
};
&lt;b&gt;
server remote.example.com {
	key		&amp;quot;remotekey&amp;quot;;
};
key &amp;quot;remotekey&amp;quot; {
        algorithm       &amp;quot;hmac-md5&amp;quot;;
        secret          &amp;quot;4TT2RNenA3JyHJAVHvWQTzgOo8GzqHowHUdB2i95peM=&amp;quot;;
};&lt;/b&gt;&lt;/pre&gt;&lt;p&gt;&lt;b&gt;NOTE&lt;/b&gt;: we use &lt;b&gt;&lt;tt&gt;127.0.0.1&lt;/tt&gt;&lt;/b&gt; instead of &lt;b&gt;&lt;tt&gt;localhost&lt;/tt&gt;&lt;/b&gt; above because the latter requires name resolution and the former doesn&apos;t. We&apos;ve seen cases where we messed up the &amp;quot;localhost&amp;quot; resource record and caused&lt;b&gt;&lt;tt&gt;rndc&lt;/tt&gt;&lt;/b&gt; to stop working. This obviates that problem.&lt;/p&gt;&lt;p&gt;Here, the entry for the remote computer includes a definition of the key used by that remote, and it&apos;s clearly different than the key used for the local one.&lt;/p&gt;&lt;p&gt;To control the remote nameserver, we use &lt;b&gt;&lt;tt&gt;rndc&lt;/tt&gt;&lt;/b&gt; with the&lt;nobr&gt;&lt;b&gt;&lt;tt&gt;-s servername&lt;/tt&gt;&lt;/b&gt;&lt;/nobr&gt;parameter:&lt;/p&gt;&lt;pre class=&quot;codeblock&quot;&gt;
# &lt;b&gt;rndc -s remote.example.com status&lt;/b&gt;
number of zones: 13
debug level: 0
xfers running: 0
xfers deferred: 0
soa queries in progress: 0
query logging is OFF
server is up and running
&lt;/pre&gt;&lt;p&gt;We&apos;re able to stop and reload the remote server, but there is &lt;b&gt;no way&lt;/b&gt;to restart it via this mechanism. Be careful that you don&apos;t get surprised.&lt;/p&gt;&lt;h1 id=&quot;views&quot;&gt;Views / Split DNS&lt;/h1&gt;&lt;p&gt;It&apos;s possible to run BIND 9 in a &amp;quot;split DNS&amp;quot; configuration, where the nameserver will give different answers to the same question depending on who&apos;s doing the asking. This is mainly useful for sites that run private networks inside with a limited public footprint on the outside.&lt;/p&gt;&lt;p&gt;We&apos;ve only barely touched the whole &amp;quot;view&amp;quot; thing and can&apos;t offer any real advice in configuration, but we did run into one maddening problem regarding &lt;b&gt;&lt;tt&gt;rndc&lt;/tt&gt;&lt;/b&gt; that we&apos;ll touch on here.&lt;/p&gt;&lt;p&gt;When configuration changes have been made to the zone or config files, one normally can do &lt;nobr&gt;&lt;b&gt;&lt;tt&gt;rndc reload&lt;/tt&gt;&lt;/b&gt;&lt;/nobr&gt; to load them all, but it&apos;s also possible to reload just one zone: this can be useful for very busy systems.&lt;/p&gt;&lt;p&gt;But when views are used, it fails in a very unhelpful way:&lt;/p&gt;&lt;pre class=&quot;codeblock&quot;&gt;
# &lt;b&gt;rndc reload unixwiz.net&lt;/b&gt;
rndc: &apos;reload&apos; failed: not found
&lt;/pre&gt;&lt;p&gt;After fooling around with it for a while we realized that the command requires additional parameters: the class and view names. So we figured out that it&apos;s done this way:&lt;/p&gt;&lt;pre class=&quot;codeblock&quot;&gt;
# &lt;b&gt;rndc reload unixwiz.net IN external&lt;/b&gt;&lt;/pre&gt;&lt;p&gt;This requests the &amp;quot;internet&amp;quot; ( &lt;b&gt;&lt;tt&gt;IN&lt;/tt&gt;&lt;/b&gt; ) class and the &lt;b&gt;&lt;tt&gt;external&lt;/tt&gt;&lt;/b&gt; view: apparently these are not the defaults. We suspect that there are ways around this (say, by naming the view something else), but we very much think that the message from &lt;tt&gt;rndc&lt;/tt&gt; was &lt;i&gt;not&lt;/i&gt; very helpful. We might look into some patches to the 9.2.0 source to expand on this to provide a bit more feedback. It was very frustrating.&lt;/p&gt;&lt;h1 id=&quot;files&quot;&gt;Files created by &amp;quot;make install&amp;quot;&lt;/h1&gt;&lt;p&gt;One of the really ugly problems with previous versions of BIND is that the various important files got scattered all over the filesystem, and the locations varied by platform as determined by the operating system vendor. It was just a nightmare to configure a chroot nameserver for a new platform.&lt;/p&gt;&lt;p&gt;BIND 9 makes this dramatically easier because they have decided to put everything under one place (usually &lt;tt&gt;/usr/local/&lt;/tt&gt;), but there are enough files installed that it can be a bit overwhelming to know just what you need.&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;http://www.unixwiz.net/techtips/bind9-chroot-files.html&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;This&lt;/font&gt;&lt;/u&gt;&lt;/a&gt; is a list of files that were installed by our own configuration of BIND 9, and it might help you decide what you need to take for a binary-only distribution. Note that this was as of an early BIND 9 installation: we&apos;ve not updated this since we have upgraded our own installation.&lt;/p&gt;&lt;h1 id=&quot;port&quot;&gt;Porting Issues&lt;/h1&gt;&lt;dl class=&quot;defnlist&quot;&gt;&lt;dt&gt;SCO UNIX 3.2v5.0.5 (OpenServer 5)&lt;/dt&gt;&lt;dd&gt;&lt;p&gt;We&apos;ve had all kinds of trouble building BIND 9.2.1 on SCO Open Server wtih gcc 2.7.2.2, though we think we&apos;ve gotten around it. We have had &lt;i&gt;zero&lt;/i&gt; luck with the stock C compiler (no &amp;quot;long long&amp;quot; support). Note for this platform can be found &lt;a href=&quot;http://www.unixwiz.net/techtips/bind9-chroot-sco.html&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;here&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;.&lt;/p&gt;&lt;/dd&gt;&lt;dt&gt;Solaris &lt;/dt&gt;&lt;dd&gt;So that file-based logfiles have the correct time zone (as opposed to GMT), insure that the jail contains copies of the time-zone definition files found in &lt;b&gt;&lt;tt&gt;/usr/share/lib/zoneinfo/US/*&lt;/tt&gt;&lt;/b&gt;. They probably should be owned by root and be unwritable by all.&lt;p&gt;Solaris and *BSD use a colon instead of a dot between the user name and the group name in the &lt;tt&gt;chown&lt;/tt&gt; command. *BSD uses &lt;tt&gt;wheel&lt;/tt&gt; as the main root group, and Solaris uses &lt;tt&gt;other&lt;/tt&gt;.&lt;/p&gt;&lt;/dd&gt;&lt;dt&gt;BSD &lt;/dt&gt;&lt;dd&gt;To get BIND to start automatically at boot time, add this bit to the startup file (often &lt;b&gt;/etc/rc.conf&lt;/b&gt;, perhaps &lt;b&gt;rc.conf.local&lt;/b&gt;):&lt;div class=&quot;blocklabel&quot;&gt;/etc/rc.conf&lt;/div&gt;&lt;pre class=&quot;codeblock&quot;&gt;
...
named_enable=&amp;quot;YES&amp;quot;
named_program=&amp;quot;/usr/local/sbin/named&amp;quot;
named_flags=&amp;quot;-t /chroot/named -u named -c /etc/named.conf&amp;quot;
...
&lt;/pre&gt;&lt;/dd&gt;&lt;/dl&gt;&lt;h1 id=&quot;resources&quot;&gt;Other Resources&lt;/h1&gt;&lt;p&gt;Rob Thomas has a great&lt;a href=&quot;http://www.cymru.com/Documents/secure-bind-template.html&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;Secure BIND Template&lt;/font&gt;&lt;/u&gt;&lt;/a&gt; document, with more coverage of the &lt;tt&gt;named.conf&lt;/tt&gt; file than I provide.&lt;/p&gt;&lt;p&gt;Andrew St. Jean has a good document on setting up DNS and DHCP&lt;a href=&quot;http://www.arda.homeunix.net/dnssetup.shtml&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;here&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;.&lt;/p&gt;</description>
		<guid>http://www.517sou.net/Article/bind9-chroot.aspx</guid>
		<trackback:ping>http://www.517sou.net/Article/641/Trackback.ashx</trackback:ping>
		<comments>http://www.517sou.net/Article/bind9-chroot.aspx#CommentPostAnchor</comments>
		<wfw:commentRss>http://www.517sou.net/Article/641/Feeds.ashx</wfw:commentRss>
	</item>
	<item>
		<link>http://www.517sou.net/Article/mysql-driver-could-not-create-database-instance-object.aspx</link>
		<title>mysql driver could not create database instance object(bind dlz)</title>
		<author>shanyiwan@live.com()</author>
		<category>DNS技术</category>
		<pubDate>Wed, 24 Nov 2010 02:50:03 GMT</pubDate>
		<description>&lt;p&gt;&amp;nbsp;bind dlz(mysql)运行过程时出现如下错误：&lt;/p&gt;&lt;div&gt;Nov 24 10:35:01 lbbackup named[4155]: starting BIND 9.7.1-P2 -u named -c /usr/local/bind/etc/named.conf.mysql&lt;/div&gt;&lt;div&gt;Nov 24 10:35:01 lbbackup named[4155]: built with &apos;--prefix=/usr/local/bind&apos; &apos;--with-dlz-mysql=/usr/local/mysql&apos; &apos;--enable-threads=no&lt;/div&gt;&lt;div&gt;&apos; &apos;--enable-largefile&apos;&lt;/div&gt;&lt;div&gt;Nov 24 10:35:01 lbbackup named[4155]: using up to 4096 sockets&lt;/div&gt;&lt;div&gt;Nov 24 10:35:01 lbbackup named[4155]: loading configuration from &apos;/usr/local/bind/etc/named.conf.mysql&apos;&lt;/div&gt;&lt;div&gt;Nov 24 10:35:01 lbbackup named[4155]: reading built-in trusted keys from file &apos;/usr/local/bind/etc/bind.keys&apos;&lt;/div&gt;&lt;div&gt;Nov 24 10:35:01 lbbackup named[4155]: using default UDP/IPv4 port range: [1024, 65535]&lt;/div&gt;&lt;div&gt;Nov 24 10:35:01 lbbackup named[4155]: using default UDP/IPv6 port range: [1024, 65535]&lt;/div&gt;&lt;div&gt;Nov 24 10:35:01 lbbackup named[4155]: listening on IPv4 interface lo, 127.0.0.1#53&lt;/div&gt;&lt;div&gt;Nov 24 10:35:01 lbbackup named[4155]: listening on IPv4 interface eth0, 192.168.146.155#53&lt;/div&gt;&lt;div&gt;Nov 24 10:35:01 lbbackup named[4155]: listening on IPv4 interface eth1, 10.0.0.155#53&lt;/div&gt;&lt;div&gt;Nov 24 10:35:01 lbbackup named[4155]: Required root permissions to open &apos;/usr/local/bind/var/run/named.pid&apos;.&lt;/div&gt;&lt;div&gt;Nov 24 10:35:01 lbbackup named[4155]: Please check file and directory permissions or reconfigure the filename.&lt;/div&gt;&lt;div&gt;Nov 24 10:35:01 lbbackup named[4155]: generating session key for dynamic DNS&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(255, 0, 0); &quot;&gt;Nov 24 10:35:01 lbbackup named[4155]: Loading &apos;Mysql zone&apos; using driver mysql&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(255, 0, 0); &quot;&gt;Nov 24 10:35:01 lbbackup named[4155]: Required token $zone$ not found.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(255, 0, 0); &quot;&gt;Nov 24 10:35:01 lbbackup named[4155]: Could not build all nodes query list&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(255, 0, 0); &quot;&gt;Nov 24 10:35:01 lbbackup named[4155]: mysql driver could not create database instance&lt;/span&gt;&lt;span style=&quot;color: rgb(255, 0, 0); &quot;&gt;object.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(255, 0, 0); &quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: palatino, georgia, verdana, arial, sans-serif; line-height: 18px; font-size: small; &quot;&gt;段错误 (core dumped) #加-g -d 1时出现&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;配置文件如下：&lt;br /&gt;&lt;code&gt;&lt;div&gt;dlz &amp;quot;Mysql zone&amp;quot; {&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; database &amp;quot;mysql&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; {host=localhost dbname=mydns_data ssl=false port=3306 user=root pass=sok12345}&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; {select zone from dns_records where zone = &apos;%zone%&apos;}&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; {select ttl, type, mx_priority, case when lower(type)=&apos;txt&apos; then concat(&apos;\&amp;quot;&apos;, data, &apos;\&amp;quot;&apos;)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;else data end from dns_records where zone = &apos;%zone%&apos; and host = &apos;%record%&apos;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;and not (type = &apos;SOA&apos; or type = &apos;NS&apos;)}&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; {select ttl, type, mx_priority, data, resp_person, serial, refresh, retry, expire, minimum&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;from dns_records where zone = &apos;%zone%&apos; and (type = &apos;SOA&apos; or type=&apos;NS&apos;)}&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; {select ttl, type, host, mx_priority, data, resp_person, serial, refresh, retry, expire,&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;minimum from dns_records where zone = &apos;%zone%&apos; and not (type = &apos;SOA&apos; or type = &apos;NS&apos;)}&amp;quot;;&lt;/div&gt;&lt;div&gt;# &amp;nbsp; {select zone from xfr_table where zone = &apos;%zone%&apos; and client = &apos;%client%&apos;}&lt;/div&gt;&lt;div&gt;# &amp;nbsp; {update data_count set count = count + 1 where zone =&apos;%zone%&apos;}&amp;quot;;&lt;/div&gt;&lt;div&gt;};&lt;/div&gt;&lt;/code&gt;&lt;/div&gt;&lt;div&gt;解决办法：&lt;/div&gt;&lt;p&gt;将配置节&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace; &quot;&gt;dlz &amp;quot;Mysql zone&amp;quot;中的%号更改为$符号即可。&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace; &quot;&gt;“&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(34, 34, 34); font-family: palatino, georgia, verdana, arial, sans-serif; line-height: 18px; font-size: small; &quot;&gt;Some versions of DLZ used &apos;%&apos; to demarcate tokens, but they can cause problems for the LDAP driver.&amp;nbsp; Subsequent patches have changed the token demarcation to &apos;$&apos;.&amp;nbsp; It looks like your updated version (that&apos;s failing) is using the &apos;$&apos; symbols.&amp;nbsp; If your config file is a few years old and still using the &apos;%&apos;, it will suddenly fail at startup.&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(34, 34, 34); font-family: palatino, georgia, verdana, arial, sans-serif; line-height: 18px; font-size: small; &quot;&gt;&lt;br /&gt;Simple solution is to check what your file is using around the tokens, and if it&apos;s &apos;%&apos;, change them to &apos;$&apos; after the upgrade.”&lt;/span&gt;&lt;/p&gt;</description>
		<guid>http://www.517sou.net/Article/mysql-driver-could-not-create-database-instance-object.aspx</guid>
		<trackback:ping>http://www.517sou.net/Article/544/Trackback.ashx</trackback:ping>
		<comments>http://www.517sou.net/Article/mysql-driver-could-not-create-database-instance-object.aspx#CommentPostAnchor</comments>
		<wfw:commentRss>http://www.517sou.net/Article/544/Feeds.ashx</wfw:commentRss>
	</item>
	<item>
		<link>http://www.517sou.net/Article/BIND-and-Berkeley-DB-realization-of-DNS-dynamic-update.aspx</link>
		<title>Bind+Berkeley DB实现DNS动态更新</title>
		<author>shanyiwan@live.com()</author>
		<category>DNS技术</category>
		<pubDate>Tue, 28 Sep 2010 00:29:23 GMT</pubDate>
		<description>&lt;p&gt;简介：&lt;/p&gt;&lt;p&gt;本文介绍使用Bind+Berkerley DB驱动（&lt;a href=&quot;http://bind-dlz.sourceforge.net/bdbhpt_driver.html&quot; target=&quot;_blank&quot;&gt;BDBHPT&lt;/a&gt;）实现DNS的动态更新。&lt;/p&gt;&lt;p&gt;&lt;b&gt;&amp;nbsp;一、Bind配置&lt;/b&gt;&lt;/p&gt;&lt;p&gt;1．&amp;nbsp;  在named.conf下的基本配置&lt;/p&gt;&lt;div style=&quot;border:1pt solid blue; padding:4pt; BACKGROUND: #ffff66; &quot;&gt;dlz &amp;quot;bdbhpt zone&amp;quot; {&amp;nbsp;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;database &amp;quot;bdbhpt T(or C or P) /dns-root dnsdata.db&amp;quot;;&lt;br /&gt;};&lt;/div&gt;&lt;p&gt;2．&amp;nbsp;  三种方式&lt;/p&gt;&lt;p&gt;Transactional mode.：&amp;nbsp; Highest safety - lowest speed. support commit  or rollback operations&lt;/p&gt;&lt;p&gt;Concurrent  mode：&amp;nbsp; &amp;nbsp;&amp;nbsp;Lower safety (no rollback) - higher  speed.&lt;/p&gt;&lt;p style=&quot;TEXT-INDENT: -92.45pt; margin-left:92.45pt; margin-right:0cm; margin-top:0cm; margin-bottom:0pt&quot; class=&quot;MsoNormal&quot;&gt;Private mode：&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Verdana; color: black; font-size: 9pt&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;No inter-process  communication &amp;amp; no locking. Lowest saftey - highest  speed.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;二、Berkerley DB&lt;/b&gt;&lt;/p&gt;&lt;p&gt;1．DB 综述&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp; DB最初开发的目的是以新的HASH访问算法来代替旧的hsearch函数和大量的dbm实现（如AT&amp;amp;T的dbm，Berkeley的ndbm，GNU项目的gdbm）,DB的第一个发行版在1991年出现，当时还包含了B+树数据访问算法。在1992年，BSD UNIX第4.4发行版中包含了DB1.85版。基本上认为这是DB的第一个正式版。在1996年中期，&lt;u&gt;Sleepcat&lt;/u&gt;软件公司成立，提供对DB的商业支持，后来被Oracle收购,全世界拥有达2亿多用户。在这以后，DB得到了广泛的应用，当前最新版本是&lt;st1:chsdate w:st=&quot;on&quot; isrocdate=&quot;False&quot; islunardate=&quot;False&quot; day=&quot;30&quot; month=&quot;12&quot; year=&quot;1899&quot;&gt;4.6.19&lt;/st1:chsdate&gt;。&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp; DB支持几乎所有的现代操作系统，如LINUX、UNIX、WINDOWS等，也提供了丰富的应用程序接口，支持C、C++、JAVA、PERL、TCL、PYTHON、PHP等,新版提供的只有C、C++、JAVA详细的文档API,对java有je-&lt;st1:chsdate w:st=&quot;on&quot; isrocdate=&quot;False&quot; islunardate=&quot;False&quot; day=&quot;30&quot; month=&quot;12&quot; year=&quot;1899&quot;&gt;3.2.23&lt;/st1:chsdate&gt;工具包。&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  值得注意的是DB是嵌入式数据库系统，而不是常见的关系/对象型数据库，对SQL语言不支持，也不提供数据库常见的高级功能，如存储过程，触发器等。&lt;/p&gt;&lt;p&gt;2. DB的设计思想&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DB的设计思想是简单、小巧、可靠、高性能。如果说一些主流数据库系统是大而全的话，那么DB就可称为小而精。DB提供了一系列应用程序接口（API），调用本身很简单，应用程序和DB所提供的库在一起编译成为可执行程序。这种方式从两方面极大提高了DB的效率。第一：DB库和应用程序运行在同一个地址空间，没有客户端程序和数据库服务器之间昂贵的网络通讯开销，也没有本地主机进程之间的通讯；第二：不需要对SQL代码解码，对数据的访问直截了当。&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DB对需要管理的数据看法很简单，DB数据库包含若干条记录，每一个记录由关键字和数据（KEY/VALUE）构成。数据可以是简单的数据类型，也可以是复杂的数据类型，例如C语言中结构。DB对数据类型不做任何解释,  完全由程序员自行处理，典型的C语言指针的&amp;quot;自由&amp;quot;风格。如果把记录看成一个有n个字段的表，那么第1个字段为表的主键，第2--n个字段对应了其它数据。DB应用程序通常使用多个DB数据库，从某种意义上看，也就是关系数据库中的多个表。DB库非常紧凑，不超过500K，但可以管理大至256T的数据量。&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DB的设计充分体现了UNIX的基于工具的哲学，即若干简单工具的组合可以实现强大的功能。DB的每一个基础功能模块都被设计为独立的,也即意味着其使用领域并不局限于DB本身。例如加锁子系统可以用于非DB应用程序的通用操作，内存共享缓冲池子系统可以用于在内存中基于页面的文件缓冲。&lt;/p&gt;&lt;p&gt;3.&lt;font class=&quot;Apple-style-span&quot; color=&quot;#15647B&quot;&gt;&amp;nbsp;DB&lt;/font&gt;核心数据结构&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  数据库句柄结构DB：包含了若干描述数据库属性的参数，如数据库访问方法类型、逻辑页面大小、数据库名称等；同时，DB结构中包含了大量的数据库处理函数指针，大多数形式为（*dosomething）(DB *,  arg1, arg2, …)。其中最重要的有open,close,put,get等函数。&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  数据库记录结构DBT：DB中的记录由关键字和数据构成，关键字和数据都用结构DBT表示。实际上完全可以把关键字看成特殊的数据。结构中最重要的两个字段是 void *  data和u_int32_t  size，分别对应数据本身和数据的长度。&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  数据库游标结构DBC：游标（cursor）是数据库应用中常见概念，其本质上就是一个关于特定记录的遍历器。注意到DB支持多重记录（duplicate records），即多条记录有相同关键字，在对多重记录的处理中，使用游标是最容易的方式。&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  数据库环境句柄结构DB_ENV：环境在DB中属于高级特性，本质上看，环境是多个数据库的包装器。当一个或多个数据库在环境中打开后，环境可以为这些数据库提供多种子系统服务，例如多线/进程处理支持、事务处理支持、高性能支持、日志恢复支持等。&lt;/p&gt;&lt;p&gt;4. DB数据访问算法&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  在数据库领域中,数据访问算法对应了数据在硬盘上的存储格式和操作方法。在编写应用程序时，选择合适的算法可能会在运算速度上提高1个甚至多个数量级。大多数数据库都选用B+树算法，DB也不例外，同时还支持HASH算法、Recno算法和Queue算法。&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; B+树算法：B+树是一个平衡树，关键字有序存储，并且其结构能随数据的插入和删除进行动态调整。为了代码的简单，DB没有实现对关键字的前缀码压缩。B+树支持对数据查询、插入、删除的常数级速度。关键字可以为任意的数据结构。&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; HASH算法：DB中实际使用的是扩展线性HASH算法（extended  linear hashing），可以根据HASH表的增长进行适当的调整。关键字可以为任意的数据结构。&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Recno算法：要求每一个记录都有一个逻辑纪录号，逻辑纪录号由算法本身生成。实际上，这和关系型数据库中逻辑主键通常定义为int AUTO型是同一个概念。Recho建立在B+树算法之上，提供了一个存储有序数据的接口。记录的长度可以为定长或不定长。&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Queue算法：和Recno方式接近,   只不过记录的长度为定长。数据以定长记录方式存储在队列中，插入操作把记录插入到队列的尾部，相比之下插入速度是最快的。&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  对算法的选择首先要看关键字的类型，如果为复杂类型，则只能选择B+树或HASH算法，如果关键字为逻辑记录号，则应该选择Recno或Queue算法。当工作集关键字有序时，B+树算法比较合适；如果工作集比较大且基本上关键字为随机分布时，选择HASH算法。Queue算法只能存储定长的记录，在高的并发处理情况下，Queue算法效率较高；如果是其它情况，则选择Recno算法，Recno算法把数据存储为平面文件格式。&lt;/p&gt;&lt;p&gt;&lt;b&gt;注：bind+bdbhpt中我们使用了hash+btree,以下介绍都是以此为基。&lt;/b&gt;&lt;/p&gt;&lt;p&gt;5．Berkeley  Db的详细API，方法见Berkerley的文档&lt;/p&gt;&lt;div&gt;&lt;p&gt;&lt;b&gt;三、Dns数据在Berkeley中的关系以及存储方式&lt;/b&gt;&lt;/p&gt;&lt;p&gt;1．数据结构&lt;/p&gt;&lt;p&gt;定义：&lt;/p&gt;&lt;pre&gt;&lt;ol class=&quot;dp-cpp&quot;&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&lt;span class=&quot;keyword&quot;&gt;typedef&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;keyword&quot;&gt;struct&lt;/span&gt;&lt;span&gt;&amp;nbsp;bdb_instance&amp;nbsp;{&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;DB_ENV&amp;nbsp;&amp;nbsp;*dbenv;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;DB&amp;nbsp;&amp;nbsp;&amp;nbsp;*data;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;DBC&amp;nbsp;*cursor;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;DBC&amp;nbsp;*cursor2;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;DBC&amp;nbsp;*cursor3;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;DBC&amp;nbsp;*cursor4;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;DB&amp;nbsp;&amp;nbsp;&amp;nbsp;*zone;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;DB&amp;nbsp;&amp;nbsp;&amp;nbsp;*xfr;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;DB&amp;nbsp;&amp;nbsp;&amp;nbsp;*client;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;}&amp;nbsp;bdbhpt_instance_t;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;font class=&quot;Apple-style-span&quot; face=&quot;Verdana&quot;&gt;&lt;span&gt;&lt;span class=&quot;keyword&quot;&gt;&lt;p&gt;2．&amp;nbsp; 表及算法&lt;br /&gt; 	包括：&lt;br /&gt; 	dns_data&lt;br /&gt; 	dns_zone&lt;br /&gt; 	dns_host&lt;br /&gt; 	dns_client&lt;/p&gt;&lt;font size=&quot;3&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: 宋体&quot;&gt;&lt;font face=&quot;Times New Roman&quot; size=&quot;3&quot;&gt;&lt;p&gt;&lt;table class=&quot;MsoNormalTable&quot; border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; style=&quot;border-collapse:collapse;&quot;&gt;&lt;tbody&gt;&lt;tr style=&quot;height:16.15pt&quot;&gt;&lt;td rowspan=&quot;2&quot; style=&quot;border:solid windowtext 1.0pt;padding:0cm 5.4pt 0cm 5.4pt;
  height:16.15pt&quot;&gt;&lt;p class=&quot;MsoNormal&quot; align=&quot;center&quot; style=&quot;text-align:center;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size:9.0pt;font-family:&amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;;
  color:black;&quot;&gt;Dns_data&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td rowspan=&quot;2&quot; style=&quot;border-right:1.0pt solid windowtext; border-top:1.0pt solid windowtext; border-bottom:1.0pt solid windowtext; border-left:medium none; height:16.15pt; padding-left:5.4pt; padding-right:5.4pt; padding-top:0cm; padding-bottom:0cm&quot;&gt;&lt;p class=&quot;MsoNormal&quot; align=&quot;center&quot; style=&quot;text-align:center;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size:9.0pt;font-family:&amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;;
  color:black;&quot;&gt;Hash&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td width=&quot;47&quot; style=&quot;border-right:1.0pt solid windowtext; border-top:1.0pt solid windowtext; border-bottom:1.0pt solid windowtext; width:35.1pt;border-left:
  medium none;height:16.15pt; padding-left:5.4pt; padding-right:5.4pt; padding-top:0cm; padding-bottom:0cm&quot;&gt;&lt;p class=&quot;MsoNormal&quot; align=&quot;center&quot; style=&quot;text-align:center;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size:9.0pt;font-family:&amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;;
  color:black;&quot;&gt;key&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td width=&quot;140&quot; valign=&quot;top&quot; style=&quot;border-right:1.0pt solid windowtext; border-top:1.0pt solid windowtext; border-bottom:1.0pt solid windowtext; width:105.2pt;border-left:medium none;height:16.15pt; padding-left:5.4pt; padding-right:5.4pt; padding-top:0cm; padding-bottom:0cm&quot;&gt;&lt;p class=&quot;MsoNormal&quot; align=&quot;left&quot; style=&quot;text-align:left;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size:9.0pt;font-family:&amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;;
  color:black;&quot;&gt;Zone+a space+host&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;height:16.15pt&quot;&gt;&lt;td width=&quot;43&quot; style=&quot;width:32.0pt;border-top:medium none;border-left:medium none;border-bottom:
  1.0pt solid windowtext;border-right:1.0pt solid windowtext;height:16.15pt; padding-left:5.4pt; padding-right:5.4pt; padding-top:0cm; padding-bottom:0cm&quot;&gt;&lt;p class=&quot;MsoNormal&quot; align=&quot;center&quot; style=&quot;text-align:center;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size:9.0pt;
  font-family:&amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;;color:black;&quot;&gt;value&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td width=&quot;140&quot; valign=&quot;top&quot; style=&quot;width:105.2pt;border-top:medium none;border-left:
  medium none;border-bottom:1.0pt solid windowtext;border-right:1.0pt solid windowtext;
  height:16.15pt; padding-left:5.4pt; padding-right:5.4pt; padding-top:0cm; padding-bottom:0cm&quot;&gt;&lt;p class=&quot;MsoNormal&quot; align=&quot;left&quot; style=&quot;text-align:left;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size:9.0pt;
  font-family:&amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;;color:black;&quot;&gt;Dns data&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;height:16.15pt&quot;&gt;&lt;td rowspan=&quot;2&quot; style=&quot;border-left:1.0pt solid windowtext; border-right:1.0pt solid windowtext; border-bottom:1.0pt solid windowtext; border-top:medium none; height:16.15pt; padding-left:5.4pt; padding-right:5.4pt; padding-top:0cm; padding-bottom:0cm&quot;&gt;&lt;p class=&quot;MsoNormal&quot; align=&quot;center&quot; style=&quot;text-align:center;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size:9.0pt;font-family:&amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;;
  color:black;&quot;&gt;Dns_xfr&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td rowspan=&quot;2&quot; style=&quot;border-top:medium none;border-left:medium none;border-bottom:1.0pt solid windowtext;
  border-right:1.0pt solid windowtext;height:16.15pt; padding-left:5.4pt; padding-right:5.4pt; padding-top:0cm; padding-bottom:0cm&quot;&gt;&lt;p class=&quot;MsoNormal&quot; align=&quot;center&quot; style=&quot;text-align:center;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size:9.0pt;font-family:&amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;;
  color:black;&quot;&gt;Hash&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td width=&quot;43&quot; style=&quot;width:32.0pt;border-top:medium none;border-left:medium none;border-bottom:
  1.0pt solid windowtext;border-right:1.0pt solid windowtext;height:16.15pt; padding-left:5.4pt; padding-right:5.4pt; padding-top:0cm; padding-bottom:0cm&quot;&gt;&lt;p class=&quot;MsoNormal&quot; align=&quot;center&quot; style=&quot;text-align:center;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size:9.0pt;font-family:&amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;;
  color:black;&quot;&gt;key&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td width=&quot;140&quot; valign=&quot;top&quot; style=&quot;width:105.2pt;border-top:medium none;border-left:
  medium none;border-bottom:1.0pt solid windowtext;border-right:1.0pt solid windowtext;
  height:16.15pt; padding-left:5.4pt; padding-right:5.4pt; padding-top:0cm; padding-bottom:0cm&quot;&gt;&lt;p class=&quot;MsoNormal&quot; align=&quot;left&quot; style=&quot;text-align:left;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size:9.0pt;font-family:&amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;;
  color:black;&quot;&gt;zone&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;height:16.15pt&quot;&gt;&lt;td width=&quot;43&quot; style=&quot;width:32.0pt;border-top:medium none;border-left:medium none;border-bottom:
  1.0pt solid windowtext;border-right:1.0pt solid windowtext;height:16.15pt; padding-left:5.4pt; padding-right:5.4pt; padding-top:0cm; padding-bottom:0cm&quot;&gt;&lt;p class=&quot;MsoNormal&quot; align=&quot;center&quot; style=&quot;text-align:center;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size:9.0pt;font-family:&amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;;
  color:black;&quot;&gt;value&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td width=&quot;140&quot; valign=&quot;top&quot; style=&quot;width:105.2pt;border-top:medium none;border-left:
  medium none;border-bottom:1.0pt solid windowtext;border-right:1.0pt solid windowtext;
  height:16.15pt; padding-left:5.4pt; padding-right:5.4pt; padding-top:0cm; padding-bottom:0cm&quot;&gt;&lt;p class=&quot;MsoNormal&quot; align=&quot;left&quot; style=&quot;text-align:left;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size:9.0pt;font-family:&amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;;
  color:black;&quot;&gt;host&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;height:16.15pt&quot;&gt;&lt;td rowspan=&quot;2&quot; style=&quot;border-left:1.0pt solid windowtext; border-right:1.0pt solid windowtext; border-bottom:1.0pt solid windowtext; border-top:medium none; height:16.15pt; padding-left:5.4pt; padding-right:5.4pt; padding-top:0cm; padding-bottom:0cm&quot;&gt;&lt;p class=&quot;MsoNormal&quot; align=&quot;center&quot; style=&quot;text-align:center;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size:9.0pt;font-family:&amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;;
  color:black;&quot;&gt;Dns_zone&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td rowspan=&quot;2&quot; style=&quot;border-top:medium none;border-left:medium none;border-bottom:1.0pt solid windowtext;
  border-right:1.0pt solid windowtext;height:16.15pt; padding-left:5.4pt; padding-right:5.4pt; padding-top:0cm; padding-bottom:0cm&quot;&gt;&lt;p class=&quot;MsoNormal&quot; align=&quot;center&quot; style=&quot;text-align:center;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size:9.0pt;font-family:&amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;;
  color:black;&quot;&gt;Btree&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td width=&quot;43&quot; style=&quot;width:32.0pt;border-top:medium none;border-left:medium none;border-bottom:
  1.0pt solid windowtext;border-right:1.0pt solid windowtext;height:16.15pt; padding-left:5.4pt; padding-right:5.4pt; padding-top:0cm; padding-bottom:0cm&quot;&gt;&lt;p class=&quot;MsoNormal&quot; align=&quot;center&quot; style=&quot;text-align:center;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size:9.0pt;font-family:&amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;;
  color:black;&quot;&gt;key&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td width=&quot;140&quot; valign=&quot;top&quot; style=&quot;width:105.2pt;border-top:medium none;border-left:
  medium none;border-bottom:1.0pt solid windowtext;border-right:1.0pt solid windowtext;
  height:16.15pt; padding-left:5.4pt; padding-right:5.4pt; padding-top:0cm; padding-bottom:0cm&quot;&gt;&lt;p class=&quot;MsoNormal&quot; align=&quot;left&quot; style=&quot;text-align:left;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size:9.0pt;font-family:&amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;;
  color:black;&quot;&gt;Reverse zone&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;height:16.15pt&quot;&gt;&lt;td width=&quot;43&quot; style=&quot;width:32.0pt;border-top:medium none;border-left:medium none;border-bottom:
  1.0pt solid windowtext;border-right:1.0pt solid windowtext;height:16.15pt; padding-left:5.4pt; padding-right:5.4pt; padding-top:0cm; padding-bottom:0cm&quot;&gt;&lt;p class=&quot;MsoNormal&quot; align=&quot;center&quot; style=&quot;text-align:center;line-height:9.75pt;
  &quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size:9.0pt;
  font-family:&amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;;color:black;&quot;&gt;value&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td width=&quot;140&quot; valign=&quot;top&quot; style=&quot;width:105.2pt;border-top:medium none;border-left:
  medium none;border-bottom:1.0pt solid windowtext;border-right:1.0pt solid windowtext;
  height:16.15pt; padding-left:5.4pt; padding-right:5.4pt; padding-top:0cm; padding-bottom:0cm&quot;&gt;&lt;p class=&quot;MsoNormal&quot; align=&quot;left&quot; style=&quot;text-align:left;line-height:9.75pt;
  &quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size:9.0pt;
  font-family:&amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;;color:black;&quot;&gt;NULL&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;height:16.15pt&quot;&gt;&lt;td rowspan=&quot;2&quot; style=&quot;border-left:1.0pt solid windowtext; border-right:1.0pt solid windowtext; border-bottom:1.0pt solid windowtext; border-top:medium none; height:16.15pt; padding-left:5.4pt; padding-right:5.4pt; padding-top:0cm; padding-bottom:0cm&quot;&gt;&lt;p class=&quot;MsoNormal&quot; align=&quot;center&quot; style=&quot;text-align:center;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size:9.0pt;font-family:&amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;;
  color:black;&quot;&gt;Dns_client&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td rowspan=&quot;2&quot; style=&quot;border-top:medium none;border-left:medium none;border-bottom:1.0pt solid windowtext;
  border-right:1.0pt solid windowtext;height:16.15pt; padding-left:5.4pt; padding-right:5.4pt; padding-top:0cm; padding-bottom:0cm&quot;&gt;&lt;p class=&quot;MsoNormal&quot; align=&quot;center&quot; style=&quot;text-align:center;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size:9.0pt;font-family:&amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;;
  color:black;&quot;&gt;Hash&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td width=&quot;43&quot; style=&quot;width:32.0pt;border-top:medium none;border-left:medium none;border-bottom:
  1.0pt solid windowtext;border-right:1.0pt solid windowtext;height:16.15pt; padding-left:5.4pt; padding-right:5.4pt; padding-top:0cm; padding-bottom:0cm&quot;&gt;&lt;p class=&quot;MsoNormal&quot; align=&quot;center&quot; style=&quot;text-align:center;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size:9.0pt;font-family:&amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;;
  color:black;&quot;&gt;key&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td width=&quot;140&quot; valign=&quot;top&quot; style=&quot;width:105.2pt;border-top:medium none;border-left:
  medium none;border-bottom:1.0pt solid windowtext;border-right:1.0pt solid windowtext;
  height:16.15pt; padding-left:5.4pt; padding-right:5.4pt; padding-top:0cm; padding-bottom:0cm&quot;&gt;&lt;p class=&quot;MsoNormal&quot; align=&quot;left&quot; style=&quot;text-align:left;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size:9.0pt;font-family:&amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;;
  color:black;&quot;&gt;Zone&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;height:16.15pt&quot;&gt;&lt;td width=&quot;47&quot; style=&quot;width:35.1pt;border-top:medium none;border-left:medium none;border-bottom:
  1.0pt solid windowtext;border-right:1.0pt solid windowtext;height:16.15pt; padding-left:5.4pt; padding-right:5.4pt; padding-top:0cm; padding-bottom:0cm&quot;&gt;&lt;p class=&quot;MsoNormal&quot; align=&quot;center&quot; style=&quot;text-align:center;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size:9.0pt;font-family:&amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;;
  color:black;&quot;&gt;value&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td width=&quot;140&quot; valign=&quot;top&quot; style=&quot;width:105.2pt;border-top:medium none;border-left:
  medium none;border-bottom:1.0pt solid windowtext;border-right:1.0pt solid windowtext;
  height:16.15pt; padding-left:5.4pt; padding-right:5.4pt; padding-top:0cm; padding-bottom:0cm&quot;&gt;&lt;p class=&quot;MsoNormal&quot; align=&quot;left&quot; style=&quot;text-align:left;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size:9.0pt;font-family:&amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;;
  color:black;&quot;&gt;Xfr ip&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/p&gt;&lt;p&gt;&lt;span lang=&quot;EN-US&quot;&gt;&lt;o:p&gt;&lt;font size=&quot;3&quot; face=&quot;Times New Roman&quot;&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;font size=&quot;3&quot; face=&quot;Times New Roman&quot;&gt;&lt;p&gt;3.&lt;font size=&quot;3&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;  dns data&lt;span style=&quot;FONT-FAMILY: 宋体; &quot;&gt;字段：&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;&lt;font size=&quot;3&quot;&gt;&lt;div align=&quot;center&quot;&gt;&lt;table style=&quot;border:1pt solid blue; &quot; class=&quot;MsoNormalTable&quot; border=&quot;1&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;border:1pt solid blue; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 2.25pt; PADDING-RIGHT: 2.25pt; PADDING-TOP: 0cm; &quot;&gt;&lt;p style=&quot;TEXT-ALIGN: center; margin-left:0cm; margin-right:0cm; margin-top:0cm; margin-bottom:0pt&quot; class=&quot;MsoNormal&quot; align=&quot;center&quot;&gt;&lt;b&gt;&lt;span style=&quot;FONT-FAMILY: Verdana; FONT-SIZE: 10pt; &quot; lang=&quot;EN-US&quot;&gt;Order&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;border:1pt solid blue; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 2.25pt; PADDING-RIGHT: 2.25pt; PADDING-TOP: 0cm; &quot;&gt;&lt;p style=&quot;TEXT-ALIGN: center; margin-left:0cm; margin-right:0cm; margin-top:0cm; margin-bottom:0pt&quot; class=&quot;MsoNormal&quot; align=&quot;center&quot;&gt;&lt;b&gt;&lt;span style=&quot;FONT-FAMILY: Verdana; FONT-SIZE: 10pt; &quot; lang=&quot;EN-US&quot;&gt;Name&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;border:1pt solid blue; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 2.25pt; PADDING-RIGHT: 2.25pt; PADDING-TOP: 0cm; &quot;&gt;&lt;p style=&quot;TEXT-ALIGN: center; margin-left:0cm; margin-right:0cm; margin-top:0cm; margin-bottom:0pt&quot; class=&quot;MsoNormal&quot; align=&quot;center&quot;&gt;&lt;b&gt;&lt;span style=&quot;FONT-FAMILY: Verdana; FONT-SIZE: 10pt; &quot; lang=&quot;EN-US&quot;&gt;Data Type&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;border:1pt solid blue; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 2.25pt; PADDING-RIGHT: 2.25pt; PADDING-TOP: 0cm; &quot;&gt;&lt;p style=&quot;TEXT-ALIGN: center; margin-left:0cm; margin-right:0cm; margin-top:0cm; margin-bottom:0pt&quot; class=&quot;MsoNormal&quot; align=&quot;center&quot;&gt;&lt;b&gt;&lt;span style=&quot;FONT-FAMILY: Verdana; FONT-SIZE: 10pt; &quot; lang=&quot;EN-US&quot;&gt;Description&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;border:1pt solid blue; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 2.25pt; PADDING-RIGHT: 2.25pt; PADDING-TOP: 0cm; &quot;&gt;&lt;p style=&quot;TEXT-ALIGN: center; margin-left:0cm; margin-right:0cm; margin-top:0cm; margin-bottom:0pt&quot; class=&quot;MsoNormal&quot; align=&quot;center&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; FONT-SIZE: 12pt; &quot; lang=&quot;EN-US&quot;&gt;1&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;border:1pt solid blue; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 2.25pt; PADDING-RIGHT: 2.25pt; PADDING-TOP: 0cm; &quot;&gt;&lt;p style=&quot;TEXT-ALIGN: center; margin-left:0cm; margin-right:0cm; margin-top:0cm; margin-bottom:0pt&quot; class=&quot;MsoNormal&quot; align=&quot;center&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; FONT-SIZE: 12pt; &quot; lang=&quot;EN-US&quot;&gt;replication_id&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;border:1pt solid blue; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 2.25pt; PADDING-RIGHT: 2.25pt; PADDING-TOP: 0cm; &quot;&gt;&lt;p style=&quot;TEXT-ALIGN: center; margin-left:0cm; margin-right:0cm; margin-top:0cm; margin-bottom:0pt&quot; class=&quot;MsoNormal&quot; align=&quot;center&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; FONT-SIZE: 12pt; &quot; lang=&quot;EN-US&quot;&gt;string&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;border:1pt solid blue; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 2.25pt; PADDING-RIGHT: 2.25pt; PADDING-TOP: 0cm; &quot;&gt;&lt;p style=&quot;TEXT-ALIGN: center; margin-left:0cm; margin-right:0cm; margin-top:0cm; margin-bottom:0pt&quot; class=&quot;MsoNormal&quot; align=&quot;center&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; FONT-SIZE: 12pt; &quot; lang=&quot;EN-US&quot;&gt;a unique alpha-numeric id for this  record.&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;border:1pt solid blue; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 2.25pt; PADDING-RIGHT: 2.25pt; PADDING-TOP: 0cm; &quot;&gt;&lt;p style=&quot;TEXT-ALIGN: center; margin-left:0cm; margin-right:0cm; margin-top:0cm; margin-bottom:0pt&quot; class=&quot;MsoNormal&quot; align=&quot;center&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; FONT-SIZE: 12pt; &quot; lang=&quot;EN-US&quot;&gt;2&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;border:1pt solid blue; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 2.25pt; PADDING-RIGHT: 2.25pt; PADDING-TOP: 0cm; &quot;&gt;&lt;p style=&quot;TEXT-ALIGN: center; margin-left:0cm; margin-right:0cm; margin-top:0cm; margin-bottom:0pt&quot; class=&quot;MsoNormal&quot; align=&quot;center&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; FONT-SIZE: 12pt; &quot; lang=&quot;EN-US&quot;&gt;host&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;border:1pt solid blue; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 2.25pt; PADDING-RIGHT: 2.25pt; PADDING-TOP: 0cm; &quot;&gt;&lt;p style=&quot;TEXT-ALIGN: center; margin-left:0cm; margin-right:0cm; margin-top:0cm; margin-bottom:0pt&quot; class=&quot;MsoNormal&quot; align=&quot;center&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; FONT-SIZE: 12pt; &quot; lang=&quot;EN-US&quot;&gt;string&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;border:1pt solid blue; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 2.25pt; PADDING-RIGHT: 2.25pt; PADDING-TOP: 0cm; &quot;&gt;&lt;p style=&quot;TEXT-ALIGN: center; margin-left:0cm; margin-right:0cm; margin-top:0cm; margin-bottom:0pt&quot; class=&quot;MsoNormal&quot; align=&quot;center&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; FONT-SIZE: 12pt; &quot; lang=&quot;EN-US&quot;&gt;DNS host name&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;border:1pt solid blue; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 2.25pt; PADDING-RIGHT: 2.25pt; PADDING-TOP: 0cm; &quot;&gt;&lt;p style=&quot;TEXT-ALIGN: center; margin-left:0cm; margin-right:0cm; margin-top:0cm; margin-bottom:0pt&quot; class=&quot;MsoNormal&quot; align=&quot;center&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; FONT-SIZE: 12pt; &quot; lang=&quot;EN-US&quot;&gt;3&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;border:1pt solid blue; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 2.25pt; PADDING-RIGHT: 2.25pt; PADDING-TOP: 0cm; &quot;&gt;&lt;p style=&quot;TEXT-ALIGN: center; margin-left:0cm; margin-right:0cm; margin-top:0cm; margin-bottom:0pt&quot; class=&quot;MsoNormal&quot; align=&quot;center&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; FONT-SIZE: 12pt; &quot; lang=&quot;EN-US&quot;&gt;ttl&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;border:1pt solid blue; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 2.25pt; PADDING-RIGHT: 2.25pt; PADDING-TOP: 0cm; &quot;&gt;&lt;p style=&quot;TEXT-ALIGN: center; margin-left:0cm; margin-right:0cm; margin-top:0cm; margin-bottom:0pt&quot; class=&quot;MsoNormal&quot; align=&quot;center&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; FONT-SIZE: 12pt; &quot; lang=&quot;EN-US&quot;&gt;string (num)&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;border:1pt solid blue; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 2.25pt; PADDING-RIGHT: 2.25pt; PADDING-TOP: 0cm; &quot;&gt;&lt;p style=&quot;TEXT-ALIGN: center; margin-left:0cm; margin-right:0cm; margin-top:0cm; margin-bottom:0pt&quot; class=&quot;MsoNormal&quot; align=&quot;center&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; FONT-SIZE: 12pt; &quot; lang=&quot;EN-US&quot;&gt;Time to live (string must convert to  number)&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;border:1pt solid blue; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 2.25pt; PADDING-RIGHT: 2.25pt; PADDING-TOP: 0cm; &quot;&gt;&lt;p style=&quot;TEXT-ALIGN: center; margin-left:0cm; margin-right:0cm; margin-top:0cm; margin-bottom:0pt&quot; class=&quot;MsoNormal&quot; align=&quot;center&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; FONT-SIZE: 12pt; &quot; lang=&quot;EN-US&quot;&gt;4&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;border:1pt solid blue; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 2.25pt; PADDING-RIGHT: 2.25pt; PADDING-TOP: 0cm; &quot;&gt;&lt;p style=&quot;TEXT-ALIGN: center; margin-left:0cm; margin-right:0cm; margin-top:0cm; margin-bottom:0pt&quot; class=&quot;MsoNormal&quot; align=&quot;center&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; FONT-SIZE: 12pt; &quot; lang=&quot;EN-US&quot;&gt;type&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;border:1pt solid blue; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 2.25pt; PADDING-RIGHT: 2.25pt; PADDING-TOP: 0cm; &quot;&gt;&lt;p style=&quot;TEXT-ALIGN: center; margin-left:0cm; margin-right:0cm; margin-top:0cm; margin-bottom:0pt&quot; class=&quot;MsoNormal&quot; align=&quot;center&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; FONT-SIZE: 12pt; &quot; lang=&quot;EN-US&quot;&gt;string&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;border:1pt solid blue; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 2.25pt; PADDING-RIGHT: 2.25pt; PADDING-TOP: 0cm; &quot;&gt;&lt;p style=&quot;TEXT-ALIGN: center; margin-left:0cm; margin-right:0cm; margin-top:0cm; margin-bottom:0pt&quot; class=&quot;MsoNormal&quot; align=&quot;center&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; FONT-SIZE: 12pt; &quot; lang=&quot;EN-US&quot;&gt;DNS data type&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;border:1pt solid blue; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 2.25pt; PADDING-RIGHT: 2.25pt; PADDING-TOP: 0cm; &quot;&gt;&lt;p style=&quot;TEXT-ALIGN: center; margin-left:0cm; margin-right:0cm; margin-top:0cm; margin-bottom:0pt&quot; class=&quot;MsoNormal&quot; align=&quot;center&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; FONT-SIZE: 12pt; &quot; lang=&quot;EN-US&quot;&gt;5&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;border:1pt solid blue; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 2.25pt; PADDING-RIGHT: 2.25pt; PADDING-TOP: 0cm; &quot;&gt;&lt;p style=&quot;TEXT-ALIGN: center; margin-left:0cm; margin-right:0cm; margin-top:0cm; margin-bottom:0pt&quot; class=&quot;MsoNormal&quot; align=&quot;center&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; FONT-SIZE: 12pt; &quot; lang=&quot;EN-US&quot;&gt;mx_priority&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;border:1pt solid blue; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 2.25pt; PADDING-RIGHT: 2.25pt; PADDING-TOP: 0cm; &quot;&gt;&lt;p style=&quot;TEXT-ALIGN: center; margin-left:0cm; margin-right:0cm; margin-top:0cm; margin-bottom:0pt&quot; class=&quot;MsoNormal&quot; align=&quot;center&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; FONT-SIZE: 12pt; &quot; lang=&quot;EN-US&quot;&gt;string (num)&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;border:1pt solid blue; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 2.25pt; PADDING-RIGHT: 2.25pt; PADDING-TOP: 0cm; &quot;&gt;&lt;p style=&quot;TEXT-ALIGN: center; margin-left:0cm; margin-right:0cm; margin-top:0cm; margin-bottom:0pt&quot; class=&quot;MsoNormal&quot; align=&quot;center&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; FONT-SIZE: 12pt; &quot; lang=&quot;EN-US&quot;&gt;MX Priority (only for MX DNS types)&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;border:1pt solid blue; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 2.25pt; PADDING-RIGHT: 2.25pt; PADDING-TOP: 0cm; &quot;&gt;&lt;p style=&quot;TEXT-ALIGN: center; margin-left:0cm; margin-right:0cm; margin-top:0cm; margin-bottom:0pt&quot; class=&quot;MsoNormal&quot; align=&quot;center&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; FONT-SIZE: 12pt; &quot; lang=&quot;EN-US&quot;&gt;6&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;border:1pt solid blue; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 2.25pt; PADDING-RIGHT: 2.25pt; PADDING-TOP: 0cm; &quot;&gt;&lt;p style=&quot;TEXT-ALIGN: center; margin-left:0cm; margin-right:0cm; margin-top:0cm; margin-bottom:0pt&quot; class=&quot;MsoNormal&quot; align=&quot;center&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; FONT-SIZE: 12pt; &quot; lang=&quot;EN-US&quot;&gt;data&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;border:1pt solid blue; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 2.25pt; PADDING-RIGHT: 2.25pt; PADDING-TOP: 0cm; &quot;&gt;&lt;p style=&quot;TEXT-ALIGN: center; margin-left:0cm; margin-right:0cm; margin-top:0cm; margin-bottom:0pt&quot; class=&quot;MsoNormal&quot; align=&quot;center&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; FONT-SIZE: 12pt; &quot; lang=&quot;EN-US&quot;&gt;string&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;border:1pt solid blue; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 2.25pt; PADDING-RIGHT: 2.25pt; PADDING-TOP: 0cm; &quot;&gt;&lt;p style=&quot;TEXT-ALIGN: center; margin-left:0cm; margin-right:0cm; margin-top:0cm; margin-bottom:0pt&quot; class=&quot;MsoNormal&quot; align=&quot;center&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; FONT-SIZE: 12pt; &quot; lang=&quot;EN-US&quot;&gt;IP address / Host name / Full domain  name&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;border:1pt solid blue; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 2.25pt; PADDING-RIGHT: 2.25pt; PADDING-TOP: 0cm; &quot;&gt;&lt;p style=&quot;TEXT-ALIGN: center; margin-left:0cm; margin-right:0cm; margin-top:0cm; margin-bottom:0pt&quot; class=&quot;MsoNormal&quot; align=&quot;center&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; FONT-SIZE: 12pt; &quot; lang=&quot;EN-US&quot;&gt;7&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;border:1pt solid blue; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 2.25pt; PADDING-RIGHT: 2.25pt; PADDING-TOP: 0cm; &quot;&gt;&lt;p style=&quot;TEXT-ALIGN: center; margin-left:0cm; margin-right:0cm; margin-top:0cm; margin-bottom:0pt&quot; class=&quot;MsoNormal&quot; align=&quot;center&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; FONT-SIZE: 12pt; &quot; lang=&quot;EN-US&quot;&gt;primary_ns&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;border:1pt solid blue; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 2.25pt; PADDING-RIGHT: 2.25pt; PADDING-TOP: 0cm; &quot;&gt;&lt;p style=&quot;TEXT-ALIGN: center; margin-left:0cm; margin-right:0cm; margin-top:0cm; margin-bottom:0pt&quot; class=&quot;MsoNormal&quot; align=&quot;center&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; FONT-SIZE: 12pt; &quot; lang=&quot;EN-US&quot;&gt;string&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;border:1pt solid blue; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 2.25pt; PADDING-RIGHT: 2.25pt; PADDING-TOP: 0cm; &quot;&gt;&lt;p style=&quot;TEXT-ALIGN: center; margin-left:0cm; margin-right:0cm; margin-top:0cm; margin-bottom:0pt&quot; class=&quot;MsoNormal&quot; align=&quot;center&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; FONT-SIZE: 12pt; &quot; lang=&quot;EN-US&quot;&gt;Primary name server SOA record (SOA ONLY)&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;border:1pt solid blue; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 2.25pt; PADDING-RIGHT: 2.25pt; PADDING-TOP: 0cm; &quot;&gt;&lt;p style=&quot;TEXT-ALIGN: center; margin-left:0cm; margin-right:0cm; margin-top:0cm; margin-bottom:0pt&quot; class=&quot;MsoNormal&quot; align=&quot;center&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; FONT-SIZE: 12pt; &quot; lang=&quot;EN-US&quot;&gt;8&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;border:1pt solid blue; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 2.25pt; PADDING-RIGHT: 2.25pt; PADDING-TOP: 0cm; &quot;&gt;&lt;p style=&quot;TEXT-ALIGN: center; margin-left:0cm; margin-right:0cm; margin-top:0cm; margin-bottom:0pt&quot; class=&quot;MsoNormal&quot; align=&quot;center&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; FONT-SIZE: 12pt; &quot; lang=&quot;EN-US&quot;&gt;resp_person&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;border:1pt solid blue; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 2.25pt; PADDING-RIGHT: 2.25pt; PADDING-TOP: 0cm; &quot;&gt;&lt;p style=&quot;TEXT-ALIGN: center; margin-left:0cm; margin-right:0cm; margin-top:0cm; margin-bottom:0pt&quot; class=&quot;MsoNormal&quot; align=&quot;center&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; FONT-SIZE: 12pt; &quot; lang=&quot;EN-US&quot;&gt;string&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;border:1pt solid blue; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 2.25pt; PADDING-RIGHT: 2.25pt; PADDING-TOP: 0cm; &quot;&gt;&lt;p style=&quot;TEXT-ALIGN: center; margin-left:0cm; margin-right:0cm; margin-top:0cm; margin-bottom:0pt&quot; class=&quot;MsoNormal&quot; align=&quot;center&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; FONT-SIZE: 12pt; &quot; lang=&quot;EN-US&quot;&gt;Responsible person SOA record (SOA ONLY)&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;border:1pt solid blue; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 2.25pt; PADDING-RIGHT: 2.25pt; PADDING-TOP: 0cm; &quot;&gt;&lt;p style=&quot;TEXT-ALIGN: center; margin-left:0cm; margin-right:0cm; margin-top:0cm; margin-bottom:0pt&quot; class=&quot;MsoNormal&quot; align=&quot;center&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; FONT-SIZE: 12pt; &quot; lang=&quot;EN-US&quot;&gt;9&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;border:1pt solid blue; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 2.25pt; PADDING-RIGHT: 2.25pt; PADDING-TOP: 0cm; &quot;&gt;&lt;p style=&quot;TEXT-ALIGN: center; margin-left:0cm; margin-right:0cm; margin-top:0cm; margin-bottom:0pt&quot; class=&quot;MsoNormal&quot; align=&quot;center&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; FONT-SIZE: 12pt; &quot; lang=&quot;EN-US&quot;&gt;serial&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;border:1pt solid blue; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 2.25pt; PADDING-RIGHT: 2.25pt; PADDING-TOP: 0cm; &quot;&gt;&lt;p style=&quot;TEXT-ALIGN: center; margin-left:0cm; margin-right:0cm; margin-top:0cm; margin-bottom:0pt&quot; class=&quot;MsoNormal&quot; align=&quot;center&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; FONT-SIZE: 12pt; &quot; lang=&quot;EN-US&quot;&gt;string (num)&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;border:1pt solid blue; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 2.25pt; PADDING-RIGHT: 2.25pt; PADDING-TOP: 0cm; &quot;&gt;&lt;p style=&quot;TEXT-ALIGN: center; margin-left:0cm; margin-right:0cm; margin-top:0cm; margin-bottom:0pt&quot; class=&quot;MsoNormal&quot; align=&quot;center&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; FONT-SIZE: 12pt; &quot; lang=&quot;EN-US&quot;&gt;Serial # for SOA record (SOA ONLY)&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;border:1pt solid blue; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 2.25pt; PADDING-RIGHT: 2.25pt; PADDING-TOP: 0cm; &quot;&gt;&lt;p style=&quot;TEXT-ALIGN: center; margin-left:0cm; margin-right:0cm; margin-top:0cm; margin-bottom:0pt&quot; class=&quot;MsoNormal&quot; align=&quot;center&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; FONT-SIZE: 12pt; &quot; lang=&quot;EN-US&quot;&gt;10&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;border:1pt solid blue; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 2.25pt; PADDING-RIGHT: 2.25pt; PADDING-TOP: 0cm; &quot;&gt;&lt;p style=&quot;TEXT-ALIGN: center; margin-left:0cm; margin-right:0cm; margin-top:0cm; margin-bottom:0pt&quot; class=&quot;MsoNormal&quot; align=&quot;center&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; FONT-SIZE: 12pt; &quot; lang=&quot;EN-US&quot;&gt;refresh&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;border:1pt solid blue; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 2.25pt; PADDING-RIGHT: 2.25pt; PADDING-TOP: 0cm; &quot;&gt;&lt;p style=&quot;TEXT-ALIGN: center; margin-left:0cm; margin-right:0cm; margin-top:0cm; margin-bottom:0pt&quot; class=&quot;MsoNormal&quot; align=&quot;center&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; FONT-SIZE: 12pt; &quot; lang=&quot;EN-US&quot;&gt;string (num)&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;border:1pt solid blue; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 2.25pt; PADDING-RIGHT: 2.25pt; PADDING-TOP: 0cm; &quot;&gt;&lt;p style=&quot;TEXT-ALIGN: center; margin-left:0cm; margin-right:0cm; margin-top:0cm; margin-bottom:0pt&quot; class=&quot;MsoNormal&quot; align=&quot;center&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; FONT-SIZE: 12pt; &quot; lang=&quot;EN-US&quot;&gt;Refresh timefor SOA record (SOA ONLY)&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;border:1pt solid blue; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 2.25pt; PADDING-RIGHT: 2.25pt; PADDING-TOP: 0cm; &quot;&gt;&lt;p style=&quot;TEXT-ALIGN: center; margin-left:0cm; margin-right:0cm; margin-top:0cm; margin-bottom:0pt&quot; class=&quot;MsoNormal&quot; align=&quot;center&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; FONT-SIZE: 12pt; &quot; lang=&quot;EN-US&quot;&gt;11&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;border:1pt solid blue; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 2.25pt; PADDING-RIGHT: 2.25pt; PADDING-TOP: 0cm; &quot;&gt;&lt;p style=&quot;TEXT-ALIGN: center; margin-left:0cm; margin-right:0cm; margin-top:0cm; margin-bottom:0pt&quot; class=&quot;MsoNormal&quot; align=&quot;center&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; FONT-SIZE: 12pt; &quot; lang=&quot;EN-US&quot;&gt;retry&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;border:1pt solid blue; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 2.25pt; PADDING-RIGHT: 2.25pt; PADDING-TOP: 0cm; &quot;&gt;&lt;p style=&quot;TEXT-ALIGN: center; margin-left:0cm; margin-right:0cm; margin-top:0cm; margin-bottom:0pt&quot; class=&quot;MsoNormal&quot; align=&quot;center&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; FONT-SIZE: 12pt; &quot; lang=&quot;EN-US&quot;&gt;string (num)&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;border:1pt solid blue; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 2.25pt; PADDING-RIGHT: 2.25pt; PADDING-TOP: 0cm; &quot;&gt;&lt;p style=&quot;TEXT-ALIGN: center; margin-left:0cm; margin-right:0cm; margin-top:0cm; margin-bottom:0pt&quot; class=&quot;MsoNormal&quot; align=&quot;center&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; FONT-SIZE: 12pt; &quot; lang=&quot;EN-US&quot;&gt;Retry time for SOA record (SOA ONLY)&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;border:1pt solid blue; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 2.25pt; PADDING-RIGHT: 2.25pt; PADDING-TOP: 0cm; &quot;&gt;&lt;p style=&quot;TEXT-ALIGN: center; margin-left:0cm; margin-right:0cm; margin-top:0cm; margin-bottom:0pt&quot; class=&quot;MsoNormal&quot; align=&quot;center&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; FONT-SIZE: 12pt; &quot; lang=&quot;EN-US&quot;&gt;12&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;border:1pt solid blue; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 2.25pt; PADDING-RIGHT: 2.25pt; PADDING-TOP: 0cm; &quot;&gt;&lt;p style=&quot;TEXT-ALIGN: center; margin-left:0cm; margin-right:0cm; margin-top:0cm; margin-bottom:0pt&quot; class=&quot;MsoNormal&quot; align=&quot;center&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; FONT-SIZE: 12pt; &quot; lang=&quot;EN-US&quot;&gt;expire&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;border:1pt solid blue; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 2.25pt; PADDING-RIGHT: 2.25pt; PADDING-TOP: 0cm; &quot;&gt;&lt;p style=&quot;TEXT-ALIGN: center; margin-left:0cm; margin-right:0cm; margin-top:0cm; margin-bottom:0pt&quot; class=&quot;MsoNormal&quot; align=&quot;center&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; FONT-SIZE: 12pt; &quot; lang=&quot;EN-US&quot;&gt;string (num)&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;border:1pt solid blue; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 2.25pt; PADDING-RIGHT: 2.25pt; PADDING-TOP: 0cm; &quot;&gt;&lt;p style=&quot;TEXT-ALIGN: center; margin-left:0cm; margin-right:0cm; margin-top:0cm; margin-bottom:0pt&quot; class=&quot;MsoNormal&quot; align=&quot;center&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; FONT-SIZE: 12pt; &quot; lang=&quot;EN-US&quot;&gt;Expire time for SOA record (SOA ONLY)&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;border:1pt solid blue; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 2.25pt; PADDING-RIGHT: 2.25pt; PADDING-TOP: 0cm; &quot;&gt;&lt;p style=&quot;TEXT-ALIGN: center; margin-left:0cm; margin-right:0cm; margin-top:0cm; margin-bottom:0pt&quot; class=&quot;MsoNormal&quot; align=&quot;center&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; FONT-SIZE: 12pt; &quot; lang=&quot;EN-US&quot;&gt;13&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;border:1pt solid blue; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 2.25pt; PADDING-RIGHT: 2.25pt; PADDING-TOP: 0cm; &quot;&gt;&lt;p style=&quot;TEXT-ALIGN: center; margin-left:0cm; margin-right:0cm; margin-top:0cm; margin-bottom:0pt&quot; class=&quot;MsoNormal&quot; align=&quot;center&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; FONT-SIZE: 12pt; &quot; lang=&quot;EN-US&quot;&gt;minimum&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;border:1pt solid blue; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 2.25pt; PADDING-RIGHT: 2.25pt; PADDING-TOP: 0cm; &quot;&gt;&lt;p style=&quot;TEXT-ALIGN: center; margin-left:0cm; margin-right:0cm; margin-top:0cm; margin-bottom:0pt&quot; class=&quot;MsoNormal&quot; align=&quot;center&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; FONT-SIZE: 12pt; &quot; lang=&quot;EN-US&quot;&gt;string (num)&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;border:1pt solid blue; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 2.25pt; PADDING-RIGHT: 2.25pt; PADDING-TOP: 0cm; &quot;&gt;&lt;p style=&quot;TEXT-ALIGN: center; margin-left:0cm; margin-right:0cm; margin-top:0cm; margin-bottom:0pt&quot; class=&quot;MsoNormal&quot; align=&quot;center&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; FONT-SIZE: 12pt; &quot; lang=&quot;EN-US&quot;&gt;Minimum time for SOA record (SOA ONLY)&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt;&lt;font size=&quot;3&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;4.&lt;span style=&quot;FONT-FAMILY: 宋体; &quot;&gt;各表之间的逻辑关系&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;&lt;font size=&quot;3&quot;&gt;&lt;p&gt;Dns_client是控制客户端多台同步&lt;br /&gt; 		Dns_xfr是Dns_client允许增量传输的zone和host&lt;br /&gt; 		Dns_zone是reverse zone能提高查询速度，其值为空，当查询zone的时候其关系为：&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;Dns_zone--&amp;gt;dns_xfr--&amp;gt;dns_data&lt;br /&gt; 		Dns_data 是最终数据集，当查host时的关系为：&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;Dns_xfr--&amp;gt;dns_data&lt;br /&gt; &amp;nbsp;&lt;/p&gt; 		5.实例数据&lt;br /&gt; 		注：bind+bdbhpt官方文档有几个错误，数据要严格按照下面的来定义&lt;br /&gt;&lt;br /&gt;[dns_zone] key: moc.tset , data: &lt;br /&gt;[dns_client] key: test.com , data: 127.0.0.1&lt;br /&gt;[dns_client] key: test.com , data: 192.168.1.10&lt;br /&gt;[dns_xfr] key: test.com , data: @&lt;br /&gt;[dns_data] key: test.com @ , data: 1 @ 86400 SOA ns1.test.com. hostmaster.test.com. 2006112401 28800 7200 604800 86400&lt;br /&gt;[dns_xfr] key: test.com , data: download&lt;br /&gt;[dns_data] key: test.com download , data: 18 download 600 A 192.168.1.15&lt;br /&gt;[dns_data] key: test.com download , data: 19 download 600 A 192.168.1.16&lt;br /&gt;[dns_xfr] key: test.com , data: video&lt;br /&gt;[dns_data] key: test.com video , data: 20 video 600 A 192.168.1.17&lt;br /&gt;[dns_data] key: test.com video , data: 21 video 600 A 192.168.1.18&lt;br /&gt;[dns_xfr] key: test.com , data: www&lt;br /&gt;[dns_data] key: test.com www , data: 10 www 600 A 192.168.1.19&lt;br /&gt;[dns_data] key: test.com www , data: 11 www 600 A 192.168.1.10&lt;br /&gt;[dns_data] key: test.com www , data: 12 www 600 A 192.168.1.20&lt;br /&gt;&amp;nbsp;&lt;font size=&quot;3&quot; face=&quot;Times New Roman&quot;&gt;&lt;p&gt;&lt;b&gt;四、程序设计与实现（以下是以c来实现的）&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;TEXT-INDENT: -18pt; margin-left:36pt; margin-right:0cm; margin-top:0cm; margin-bottom:0pt&quot; class=&quot;MsoNormal&quot;&gt;1．&amp;nbsp; 需求:&lt;/p&gt;&lt;p&gt;据以上来看，由于数据库只有API,不支持sql,也没server概念，数据库的维护管理全由程序来完成，其基本模块为：&lt;/p&gt;&lt;p&gt;A：添加&lt;br /&gt;B：查找&lt;br /&gt;C：删除&lt;br /&gt;D：同步&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;TEXT-INDENT: -18pt; margin-left:36pt; margin-right:0cm; margin-top:0cm; margin-bottom:0pt&quot; class=&quot;MsoNormal&quot;&gt;2．&amp;nbsp; 细节（子模块）&lt;/p&gt;&lt;p&gt;&amp;nbsp;从上面我们知道要实现上面的功能，其子模块有：&lt;/p&gt;&lt;p&gt;A：复制ID的获得&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp; 通过取得dns_xfr中的zone+a  space+host遍历dns_data的值，复制ID初值为1(为SOA的),其后相同的zone，复制ID++;&lt;/p&gt;&lt;p&gt;B：reverse  zone&lt;/p&gt;&lt;p&gt;&amp;nbsp;  也就是把zone反向存储.&lt;/p&gt;&lt;p&gt;C：分离字符串判断是否为SOA记录，如果是则repid=1,否则repid++;&lt;/p&gt;&lt;p&gt;D：把整数转化为字符串函数&lt;/p&gt;&lt;p&gt;E：字符串分离与连接函数&lt;/p&gt;&lt;p&gt;F：命令行getop获取参数函数&lt;/p&gt;&lt;p&gt;H：btree和hash表要实现一Key多值，必须支持key值的复制，而且要提高查找的速度的话，还要支持数据的排序，默认为字典顺序，实现更好的算法则以自定义的callback函数来实现。&lt;/p&gt;&lt;p style=&quot;TEXT-INDENT: -18pt; margin-left:36pt; margin-right:0cm; margin-top:0cm; margin-bottom:0pt&quot; class=&quot;MsoNormal&quot;&gt;3．&amp;nbsp; 程序实现&lt;/p&gt;&lt;pre&gt;&lt;ol class=&quot;dp-cpp&quot;&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&lt;span class=&quot;preprocessor&quot;&gt;#include&amp;nbsp;&amp;lt;sys/types.h&amp;gt;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&lt;span class=&quot;preprocessor&quot;&gt;#include&amp;nbsp;&amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&lt;span class=&quot;preprocessor&quot;&gt;#define&amp;nbsp;dlz_data&amp;nbsp;&amp;quot;dns_data&amp;quot;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&lt;span class=&quot;preprocessor&quot;&gt;#define&amp;nbsp;dlz_zone&amp;nbsp;&amp;quot;dns_zone&amp;quot;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&lt;span class=&quot;preprocessor&quot;&gt;#define&amp;nbsp;dlz_xfr&amp;nbsp;&amp;quot;dns_xfr&amp;quot;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&lt;span class=&quot;preprocessor&quot;&gt;#define&amp;nbsp;dlz_client&amp;nbsp;&amp;quot;dns_client&amp;quot;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&lt;span class=&quot;comment&quot;&gt;//……………………………………………….&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&lt;span class=&quot;keyword&quot;&gt;void&lt;/span&gt;&lt;span&gt;&amp;nbsp;Usage(&lt;/span&gt;&lt;span class=&quot;keyword&quot;&gt;void&lt;/span&gt;&lt;span&gt;)&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&lt;span class=&quot;datatypes&quot;&gt;char&lt;/span&gt;&lt;span&gt;&amp;nbsp;*soa(&lt;/span&gt;&lt;span class=&quot;datatypes&quot;&gt;char&lt;/span&gt;&lt;span&gt;&amp;nbsp;*str);&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&lt;span class=&quot;datatypes&quot;&gt;int&lt;/span&gt;&lt;span&gt;&amp;nbsp;bdbhpt_open(DBTYPE&amp;nbsp;db_type,&amp;nbsp;DB&amp;nbsp;**db_out,&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;keyword&quot;&gt;const&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;datatypes&quot;&gt;char&lt;/span&gt;&lt;span&gt;&amp;nbsp;*db_name,&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;datatypes&quot;&gt;int&lt;/span&gt;&lt;span&gt;&amp;nbsp;flags);&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&lt;span class=&quot;datatypes&quot;&gt;int&lt;/span&gt;&lt;span&gt;&amp;nbsp;bdbhpt_create(&lt;/span&gt;&lt;span class=&quot;keyword&quot;&gt;void&lt;/span&gt;&lt;span&gt;);&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&lt;span class=&quot;keyword&quot;&gt;void&lt;/span&gt;&lt;span&gt;&amp;nbsp;put_data(&lt;/span&gt;&lt;span class=&quot;datatypes&quot;&gt;char&lt;/span&gt;&lt;span&gt;&amp;nbsp;*db_name,&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;datatypes&quot;&gt;char&lt;/span&gt;&lt;span&gt;&amp;nbsp;*input_key,&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;datatypes&quot;&gt;char&lt;/span&gt;&lt;span&gt;&amp;nbsp;*input_data);&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&lt;span class=&quot;keyword&quot;&gt;void&lt;/span&gt;&lt;span&gt;&amp;nbsp;bdbhpt_close(&lt;/span&gt;&lt;span class=&quot;keyword&quot;&gt;void&lt;/span&gt;&lt;span&gt;);&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&lt;span class=&quot;keyword&quot;&gt;void&lt;/span&gt;&lt;span&gt;&amp;nbsp;bdbhpt_find(&lt;/span&gt;&lt;span class=&quot;keyword&quot;&gt;void&lt;/span&gt;&lt;span&gt;&amp;nbsp;);&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&lt;span class=&quot;keyword&quot;&gt;void&lt;/span&gt;&lt;span&gt;&amp;nbsp;bdbhpt_dele();&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&lt;span class=&quot;keyword&quot;&gt;void&lt;/span&gt;&lt;span&gt;&amp;nbsp;bdbhpt_add(&lt;/span&gt;&lt;span class=&quot;keyword&quot;&gt;void&lt;/span&gt;&lt;span&gt;);&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&lt;span class=&quot;keyword&quot;&gt;static&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;datatypes&quot;&gt;char&lt;/span&gt;&lt;span&gt;&amp;nbsp;*&amp;nbsp;bdbhpt_strrev&amp;nbsp;(&lt;/span&gt;&lt;span class=&quot;datatypes&quot;&gt;char&lt;/span&gt;&lt;span&gt;&amp;nbsp;*str);&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&lt;span class=&quot;datatypes&quot;&gt;int&lt;/span&gt;&lt;span&gt;&amp;nbsp;get_last_repid(&lt;/span&gt;&lt;span class=&quot;keyword&quot;&gt;void&lt;/span&gt;&lt;span&gt;);&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&lt;span class=&quot;datatypes&quot;&gt;int&lt;/span&gt;&lt;span&gt;&amp;nbsp;IntToStr(&lt;/span&gt;&lt;span class=&quot;datatypes&quot;&gt;int&lt;/span&gt;&lt;span&gt;&amp;nbsp;num,&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;datatypes&quot;&gt;char&lt;/span&gt;&lt;span&gt;&amp;nbsp;*buffer);&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&lt;span class=&quot;comment&quot;&gt;//…………………………………………………………&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&lt;span class=&quot;datatypes&quot;&gt;int&lt;/span&gt;&lt;span&gt;&amp;nbsp;main(&lt;/span&gt;&lt;span class=&quot;datatypes&quot;&gt;int&lt;/span&gt;&lt;span&gt;&amp;nbsp;argc,&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;datatypes&quot;&gt;char&lt;/span&gt;&lt;span&gt;&amp;nbsp;*argv[])&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;{&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;datatypes&quot;&gt;char&lt;/span&gt;&lt;span&gt;&amp;nbsp;ch;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;datatypes&quot;&gt;int&lt;/span&gt;&lt;span&gt;&amp;nbsp;ret;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;opterr&amp;nbsp;=&amp;nbsp;0;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;keyword&quot;&gt;while&lt;/span&gt;&lt;span&gt;&amp;nbsp;((ch&amp;nbsp;=&amp;nbsp;getopt(argc,&amp;nbsp;argv,&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;&amp;quot;c:f:h:i:j:m:z:adsn&amp;quot;&lt;/span&gt;&lt;span&gt;))&amp;nbsp;!=&amp;nbsp;-1)&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;keyword&quot;&gt;switch&lt;/span&gt;&lt;span&gt;&amp;nbsp;(ch)&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;keyword&quot;&gt;case&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;&apos;a&apos;&lt;/span&gt;&lt;span&gt;:&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;operation&amp;nbsp;=&amp;nbsp;add;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;keyword&quot;&gt;break&lt;/span&gt;&lt;span&gt;;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;keyword&quot;&gt;case&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;&apos;d&apos;&lt;/span&gt;&lt;span&gt;:&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;operation&amp;nbsp;=&amp;nbsp;dele;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;keyword&quot;&gt;break&lt;/span&gt;&lt;span&gt;;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;keyword&quot;&gt;case&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;&apos;s&apos;&lt;/span&gt;&lt;span&gt;:&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;operation&amp;nbsp;=&amp;nbsp;list;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;keyword&quot;&gt;break&lt;/span&gt;&lt;span&gt;;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;keyword&quot;&gt;case&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;&apos;n&apos;&lt;/span&gt;&lt;span&gt;:&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;key_val&amp;nbsp;=1;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;operation&amp;nbsp;=&amp;nbsp;add;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;keyword&quot;&gt;break&lt;/span&gt;&lt;span&gt;;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;keyword&quot;&gt;case&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;&apos;z&apos;&lt;/span&gt;&lt;span&gt;:&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;zone&amp;nbsp;=&amp;nbsp;optarg;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;keyword&quot;&gt;break&lt;/span&gt;&lt;span&gt;;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;keyword&quot;&gt;case&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;&apos;h&apos;&lt;/span&gt;&lt;span&gt;:&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;host&amp;nbsp;=&amp;nbsp;optarg;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;keyword&quot;&gt;break&lt;/span&gt;&lt;span&gt;;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;keyword&quot;&gt;case&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;&apos;c&apos;&lt;/span&gt;&lt;span&gt;:&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;c_zone&amp;nbsp;=&amp;nbsp;optarg;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;keyword&quot;&gt;break&lt;/span&gt;&lt;span&gt;;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;keyword&quot;&gt;case&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;&apos;i&apos;&lt;/span&gt;&lt;span&gt;:&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;c_ip&amp;nbsp;=&amp;nbsp;optarg;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;keyword&quot;&gt;break&lt;/span&gt;&lt;span&gt;;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;keyword&quot;&gt;case&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;&apos;j&apos;&lt;/span&gt;&lt;span&gt;:&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;a_data&amp;nbsp;=&amp;nbsp;optarg;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;keyword&quot;&gt;break&lt;/span&gt;&lt;span&gt;;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;keyword&quot;&gt;case&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;&apos;m&apos;&lt;/span&gt;&lt;span&gt;:&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;db_envdir&amp;nbsp;=&amp;nbsp;optarg;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;keyword&quot;&gt;break&lt;/span&gt;&lt;span&gt;;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;keyword&quot;&gt;case&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;&apos;f&apos;&lt;/span&gt;&lt;span&gt;:&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;db_file&amp;nbsp;=&amp;nbsp;optarg;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;keyword&quot;&gt;break&lt;/span&gt;&lt;span&gt;;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;keyword&quot;&gt;case&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;&apos;?&apos;&lt;/span&gt;&lt;span&gt;:&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;keyword&quot;&gt;default&lt;/span&gt;&lt;span&gt;:&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;printf(&lt;span class=&quot;string&quot;&gt;&amp;quot;please&amp;nbsp;use&amp;nbsp;-H\n&amp;quot;&lt;/span&gt;&lt;span&gt;);&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Usage();&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;keyword&quot;&gt;if&lt;/span&gt;&lt;span&gt;&amp;nbsp;(argc&amp;nbsp;&amp;lt;&amp;nbsp;2)&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;fprintf(stderr,&amp;nbsp;&lt;span class=&quot;string&quot;&gt;&amp;quot;Both&amp;nbsp;a&amp;nbsp;Berkeley&amp;nbsp;DB&amp;nbsp;environment&amp;nbsp;and&amp;nbsp;file&amp;nbsp;must&amp;nbsp;be&amp;nbsp;specified\n&amp;quot;&lt;/span&gt;&lt;span&gt;);&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;keyword&quot;&gt;switch&lt;/span&gt;&lt;span&gt;(operation)&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;keyword&quot;&gt;case&lt;/span&gt;&lt;span&gt;&amp;nbsp;list:&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;bdbhpt_find();&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;keyword&quot;&gt;break&lt;/span&gt;&lt;span&gt;;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;keyword&quot;&gt;case&lt;/span&gt;&lt;span&gt;&amp;nbsp;dele:&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;bdbhpt_dele();&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;keyword&quot;&gt;break&lt;/span&gt;&lt;span&gt;;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;keyword&quot;&gt;case&lt;/span&gt;&lt;span&gt;&amp;nbsp;add:&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;bdbhpt_add();&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;keyword&quot;&gt;break&lt;/span&gt;&lt;span&gt;;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;keyword&quot;&gt;default&lt;/span&gt;&lt;span&gt;:&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;fprintf(stderr,&amp;nbsp;&lt;span class=&quot;string&quot;&gt;&amp;quot;\nNo&amp;nbsp;operation&amp;nbsp;was&amp;nbsp;selected.&amp;nbsp;&amp;quot;&lt;/span&gt;&lt;span&gt;\&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;string&quot;&gt;&amp;quot;Select&amp;nbsp;an&amp;nbsp;operation&amp;nbsp;(s&amp;nbsp;d&amp;nbsp;a&amp;nbsp;f)\n&amp;quot;&lt;/span&gt;&lt;span&gt;);&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;keyword&quot;&gt;break&lt;/span&gt;&lt;span&gt;;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;}&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;p&gt;&lt;font class=&quot;Apple-style-span&quot; face=&quot;Verdana&quot;&gt;&lt;font size=&quot;3&quot;&gt;&lt;font face=&quot;Times New Roman&quot; size=&quot;3&quot;&gt;&lt;font size=&quot;3&quot; face=&quot;Times New Roman&quot;&gt;&lt;font size=&quot;3&quot;&gt;&lt;font size=&quot;3&quot;&gt;&lt;font size=&quot;3&quot; face=&quot;Times New Roman&quot;&gt;&lt;div&gt;&lt;p&gt;&lt;b&gt;四、应用&lt;/b&gt;&lt;/p&gt;&lt;p&gt;1．&amp;nbsp; 帮助&lt;/p&gt;&lt;p&gt;###############show record##################&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;Find Zone=&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bdbhpt -s -z test.com&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;Find Host=&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bdbhpt -s -z test.com -h  www&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;Find Client=&amp;gt;&amp;nbsp;&amp;nbsp; bdbhpt -s -c test.com&lt;/p&gt;&lt;p&gt;###############show record##################&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;Drop Zone=&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bdbhpt -d -z test.com&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;Drop Host=&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bdbhpt -d -z test.com -h  www&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;Drop Client=&amp;gt;&amp;nbsp;&amp;nbsp; bdbhpt -d -c test.com&lt;/p&gt;&lt;p&gt;&amp;nbsp;###############show  record##################&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;New Create=&amp;gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;bdbhpt -n -z test.com -h @ -j &amp;quot;@ 10 SOA ns1.example.com. root.example.com. 2 2800 7200 604800 86400&amp;quot;&amp;nbsp;&amp;nbsp; -m /dns-root -f dbfile&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;Append Data=&amp;gt;&amp;nbsp;&amp;nbsp; bdbhpt -a -z test.com -h www -j &amp;quot;www &lt;st1:chmetcnv tcsc=&quot;0&quot; numbertype=&quot;1&quot; negative=&quot;False&quot; hasspace=&quot;True&quot; sourcevalue=&quot;10&quot; unitname=&quot;a&quot; w:st=&quot;on&quot;&gt;10 A&lt;/st1:chmetcnv&gt; 192.168.0.1&amp;quot; -m  /dns-root -f dbfile&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;Append Client=&amp;gt; bdbhpt -a -c test.com -i 192.168.1.11&lt;/p&gt;&lt;p&gt;1.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 添加数据&lt;/p&gt;&lt;p&gt;A:  添加SOA&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 新建库：&lt;/p&gt;&lt;p style=&quot;TEXT-INDENT: 21pt; MARGIN: 0cm 0cm 0pt&quot; class=&quot;MsoNormal&quot;&gt;bdbhpt -n  -z test.com -h @ -j &amp;quot;@ 86400 SOA ns1.test.com. hostmaster.test.com. 2006112401  28800 7200 604800 86400&amp;quot; -m /dns-root -f demo.db&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 追加：&lt;/p&gt;&lt;p style=&quot;TEXT-INDENT: 21pt; MARGIN: 0cm 0cm 0pt&quot; class=&quot;MsoNormal&quot;&gt;bdbhpt -a  -z test1.com -h @ -j &amp;quot;@ 86400 SOA ns1.test1.com. hostmaster.test1.com.  2006112401 28800 7200 604800 86400&amp;quot; -m /dns-root -f demo.db&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 添加A记录：&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bdbhpt -a -z test.com -h www -j &amp;quot;www &lt;st1:chmetcnv tcsc=&quot;0&quot; numbertype=&quot;1&quot; negative=&quot;False&quot; hasspace=&quot;True&quot; sourcevalue=&quot;600&quot; unitname=&quot;a&quot; w:st=&quot;on&quot;&gt;600 A&lt;/st1:chmetcnv&gt; 192.168.1.11&amp;quot; -m  /dns-root -f demo.db&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 添加client：&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bdbhpt -a -c test.com -i 192.168.1.10 -m  /dns-root -f demo.db&lt;/p&gt;&lt;p&gt;2.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 查找数据&lt;/p&gt;&lt;p&gt;查找zone:&lt;/p&gt;&lt;p&gt;bdbhpt -s  -z test.com -m /dns-root/test/main/ -f demo.db&lt;/p&gt;&lt;p&gt;查找host:&lt;/p&gt;&lt;p&gt;bdbhpt -s  -z test.com -h www -m /dns-root/test/main/ -f demo.db&lt;/p&gt;&lt;p&gt;查找client:&lt;/p&gt;&lt;p&gt;bdbhpt -s  -c test.com&amp;nbsp; -m /dns-root/test/main/ -f demo.db&lt;/p&gt;&lt;p&gt;3.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 删除数据&lt;/p&gt;&lt;p&gt;删除整个client:&lt;/p&gt;&lt;p&gt;bdbhpt -d  -c test.com&amp;nbsp; -m /dns-root/test/main/ -f demo.db&lt;/p&gt;&lt;p&gt;删除一个client的IP:&lt;/p&gt;&lt;p&gt;bdbhpt -d  -c test2.com -i 192.168.1.15 -m /dns-root/test/main/ -f demo.db&lt;/p&gt;&lt;p&gt;删除整个zone:&lt;/p&gt;&lt;p&gt;bdbhpt -d  -z test.com&amp;nbsp; -m /dns-root/test/main/ -f demo.db&lt;/p&gt;&lt;p&gt;删除zone所属host:&lt;/p&gt;&lt;p&gt;bdbhpt -d  -z test2.com -h www&amp;nbsp; -m  /dns-root/test/main/ -f demo.db&lt;/p&gt;&lt;p&gt;删除zone所属host的一个记录:&lt;/p&gt;&lt;p&gt;bdbhpt -d  -z test2.com -h www -j &amp;quot;4 www &lt;st1:chmetcnv tcsc=&quot;0&quot; numbertype=&quot;1&quot; negative=&quot;False&quot; hasspace=&quot;True&quot; sourcevalue=&quot;600&quot; unitname=&quot;a&quot; w:st=&quot;on&quot;&gt;600  A&lt;/st1:chmetcnv&gt; 192.168.1.13&amp;quot; -m /dns-root/test/main/ -f demo.db&lt;/p&gt;&lt;p&gt;&lt;b&gt;五、测试&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;margin-left: 0cm; margin-right: 0cm; margin-top: 0cm; margin-bottom: 0pt&quot; class=&quot;MsoNormal&quot; align=&quot;left&quot;&gt;测试环境: linux AS4 kernel: 2.6.9-22.Elsmp &lt;br /&gt;bind9.4.1 &lt;br /&gt;测试工具: DnsPerf &lt;br /&gt;&lt;br /&gt;服务器配置: 双cpu Intel(R) Xeon(TM) CPU 3.00GHz L2 &lt;br /&gt;CPU: L2 cache: 2048K &lt;br /&gt;RAM:4G &lt;br /&gt;测试方法 : 查询10个WIDIP,时间限定6分,不同测试点并发,查看其CPU与RAM的使用情况以及qps数&lt;br /&gt;&amp;nbsp;&lt;/p&gt;&lt;table class=&quot;MsoTableGrid&quot; border=&quot;1&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; style=&quot;border-collapse: collapse; border: medium none&quot;&gt;&lt;tbody&gt;&lt;tr style=&quot;height: 24.25pt&quot;&gt;&lt;td style=&quot;height: 24.25pt; border: 1.0pt solid black; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0cm; padding-bottom: 0cm&quot;&gt;&lt;p class=&quot;MsoNormal&quot; align=&quot;center&quot; style=&quot;text-align: center&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 12.0pt; font-family: &apos;Times New Roman&apos;,serif&quot;&gt;Node&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;height: 24.25pt; border-left: medium none; border-right: 1.0pt solid black; border-top: 1.0pt solid black; border-bottom: 1.0pt solid black; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0cm; padding-bottom: 0cm&quot;&gt;&lt;p class=&quot;MsoNormal&quot; align=&quot;center&quot; style=&quot;text-align: center&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 12.0pt; font-family: &apos;Times New Roman&apos;,serif&quot;&gt;Chn-hz-3-574&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;height: 24.25pt; border-left: medium none; border-right: 1.0pt solid black; border-top: 1.0pt solid black; border-bottom: 1.0pt solid black; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0cm; padding-bottom: 0cm&quot;&gt;&lt;p class=&quot;MsoNormal&quot; align=&quot;center&quot; style=&quot;text-align: center&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 12.0pt; font-family: &apos;Times New Roman&apos;,serif&quot;&gt;Cnc-xa-1-571&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;height: 24.25pt; border-left: medium none; border-right: 1.0pt solid black; border-top: 1.0pt solid black; border-bottom: 1.0pt solid black; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0cm; padding-bottom: 0cm&quot;&gt;&lt;p class=&quot;MsoNormal&quot; align=&quot;center&quot; style=&quot;text-align: center&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 12.0pt; font-family: &apos;Times New Roman&apos;,serif&quot;&gt;Chn-fs-1-573&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;height: 24.25pt; border-left: medium none; border-right: 1.0pt solid black; border-top: 1.0pt solid black; border-bottom: 1.0pt solid black; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0cm; padding-bottom: 0cm&quot;&gt;&lt;p class=&quot;MsoNormal&quot; align=&quot;center&quot; style=&quot;text-align: center&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 12.0pt; font-family: &apos;Times New Roman&apos;,serif&quot;&gt;Chn-sh-2-571&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;height: 24.25pt&quot;&gt;&lt;td style=&quot;height: 24.25pt; border-left: 1.0pt solid black; border-right: 1.0pt solid black; border-top: medium none; border-bottom: 1.0pt solid black; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0cm; padding-bottom: 0cm&quot;&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 12.0pt; font-family: &apos;Times New Roman&apos;,serif&quot;&gt;Queries sent&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;height: 24.25pt; border-left: medium none; border-right: 1.0pt solid black; border-top: medium none; border-bottom: 1.0pt solid black; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0cm; padding-bottom: 0cm&quot;&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 12.0pt; font-family: &apos;Times New Roman&apos;,serif&quot;&gt;173295&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;height: 24.25pt; border-left: medium none; border-right: 1.0pt solid black; border-top: medium none; border-bottom: 1.0pt solid black; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0cm; padding-bottom: 0cm&quot;&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 12.0pt; font-family: &apos;Times New Roman&apos;,serif&quot;&gt;27033&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;height: 24.25pt; border-left: medium none; border-right: 1.0pt solid black; border-top: medium none; border-bottom: 1.0pt solid black; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0cm; padding-bottom: 0cm&quot;&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 12.0pt; font-family: &apos;Times New Roman&apos;,serif&quot;&gt;90522&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;height: 24.25pt; border-left: medium none; border-right: 1.0pt solid black; border-top: medium none; border-bottom: 1.0pt solid black; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0cm; padding-bottom: 0cm&quot;&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 12.0pt; font-family: &apos;Times New Roman&apos;,serif&quot;&gt;178760&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;height: 24.25pt&quot;&gt;&lt;td style=&quot;height: 24.25pt; border-left: 1.0pt solid black; border-right: 1.0pt solid black; border-top: medium none; border-bottom: 1.0pt solid black; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0cm; padding-bottom: 0cm&quot;&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 12.0pt; font-family: &apos;Times New Roman&apos;,serif&quot;&gt;Queries completed&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;height: 24.25pt; border-left: medium none; border-right: 1.0pt solid black; border-top: medium none; border-bottom: 1.0pt solid black; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0cm; padding-bottom: 0cm&quot;&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 12.0pt; font-family: &apos;Times New Roman&apos;,serif&quot;&gt;173274&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;height: 24.25pt; border-left: medium none; border-right: 1.0pt solid black; border-top: medium none; border-bottom: 1.0pt solid black; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0cm; padding-bottom: 0cm&quot;&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 12.0pt; font-family: &apos;Times New Roman&apos;,serif&quot;&gt;26927&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;height: 24.25pt; border-left: medium none; border-right: 1.0pt solid black; border-top: medium none; border-bottom: 1.0pt solid black; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0cm; padding-bottom: 0cm&quot;&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 12.0pt; font-family: &apos;Times New Roman&apos;,serif&quot;&gt;90259&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;height: 24.25pt; border-left: medium none; border-right: 1.0pt solid black; border-top: medium none; border-bottom: 1.0pt solid black; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0cm; padding-bottom: 0cm&quot;&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 12.0pt; font-family: &apos;Times New Roman&apos;,serif&quot;&gt;178512&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;height: 24.25pt&quot;&gt;&lt;td style=&quot;height: 24.25pt; border-left: 1.0pt solid black; border-right: 1.0pt solid black; border-top: medium none; border-bottom: 1.0pt solid black; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0cm; padding-bottom: 0cm&quot;&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 12.0pt; font-family: &apos;Times New Roman&apos;,serif&quot;&gt;Queries lost&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;height: 24.25pt; border-left: medium none; border-right: 1.0pt solid black; border-top: medium none; border-bottom: 1.0pt solid black; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0cm; padding-bottom: 0cm&quot;&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 12.0pt; font-family: &apos;Times New Roman&apos;,serif&quot;&gt;21&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;height: 24.25pt; border-left: medium none; border-right: 1.0pt solid black; border-top: medium none; border-bottom: 1.0pt solid black; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0cm; padding-bottom: 0cm&quot;&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 12.0pt; font-family: &apos;Times New Roman&apos;,serif&quot;&gt;106&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;height: 24.25pt; border-left: medium none; border-right: 1.0pt solid black; border-top: medium none; border-bottom: 1.0pt solid black; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0cm; padding-bottom: 0cm&quot;&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 12.0pt; font-family: &apos;Times New Roman&apos;,serif&quot;&gt;263&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;height: 24.25pt; border-left: medium none; border-right: 1.0pt solid black; border-top: medium none; border-bottom: 1.0pt solid black; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0cm; padding-bottom: 0cm&quot;&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 12.0pt; font-family: &apos;Times New Roman&apos;,serif&quot;&gt;248&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;height: 24.25pt&quot;&gt;&lt;td style=&quot;height: 24.25pt; border-left: 1.0pt solid black; border-right: 1.0pt solid black; border-top: medium none; border-bottom: 1.0pt solid black; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0cm; padding-bottom: 0cm&quot;&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 12.0pt; font-family: &apos;Times New Roman&apos;,serif&quot;&gt;Percentage completed&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;height: 24.25pt; border-left: medium none; border-right: 1.0pt solid black; border-top: medium none; border-bottom: 1.0pt solid black; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0cm; padding-bottom: 0cm&quot;&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 12.0pt; font-family: &apos;Times New Roman&apos;,serif&quot;&gt;99.99%&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;height: 24.25pt; border-left: medium none; border-right: 1.0pt solid black; border-top: medium none; border-bottom: 1.0pt solid black; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0cm; padding-bottom: 0cm&quot;&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 12.0pt; font-family: &apos;Times New Roman&apos;,serif&quot;&gt;99.61%&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;height: 24.25pt; border-left: medium none; border-right: 1.0pt solid black; border-top: medium none; border-bottom: 1.0pt solid black; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0cm; padding-bottom: 0cm&quot;&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 12.0pt; font-family: &apos;Times New Roman&apos;,serif&quot;&gt;99.71%&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;height: 24.25pt; border-left: medium none; border-right: 1.0pt solid black; border-top: medium none; border-bottom: 1.0pt solid black; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0cm; padding-bottom: 0cm&quot;&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 12.0pt; font-family: &apos;Times New Roman&apos;,serif&quot;&gt;99.86%&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;height: 24.25pt&quot;&gt;&lt;td style=&quot;height: 24.25pt; border-left: 1.0pt solid black; border-right: 1.0pt solid black; border-top: medium none; border-bottom: 1.0pt solid black; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0cm; padding-bottom: 0cm&quot;&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 12.0pt; font-family: &apos;Times New Roman&apos;,serif&quot;&gt;Percentage lost&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;height: 24.25pt; border-left: medium none; border-right: 1.0pt solid black; border-top: medium none; border-bottom: 1.0pt solid black; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0cm; padding-bottom: 0cm&quot;&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 12.0pt; font-family: &apos;Times New Roman&apos;,serif&quot;&gt;0.01%&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;height: 24.25pt; border-left: medium none; border-right: 1.0pt solid black; border-top: medium none; border-bottom: 1.0pt solid black; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0cm; padding-bottom: 0cm&quot;&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 12.0pt; font-family: &apos;Times New Roman&apos;,serif&quot;&gt;0.39%&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;height: 24.25pt; border-left: medium none; border-right: 1.0pt solid black; border-top: medium none; border-bottom: 1.0pt solid black; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0cm; padding-bottom: 0cm&quot;&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 12.0pt; font-family: &apos;Times New Roman&apos;,serif&quot;&gt;0.29%&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;height: 24.25pt; border-left: medium none; border-right: 1.0pt solid black; border-top: medium none; border-bottom: 1.0pt solid black; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0cm; padding-bottom: 0cm&quot;&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 12.0pt; font-family: &apos;Times New Roman&apos;,serif&quot;&gt;0.14%&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;height: 24.25pt&quot;&gt;&lt;td style=&quot;height: 24.25pt; border-left: 1.0pt solid black; border-right: 1.0pt solid black; border-top: medium none; border-bottom: 1.0pt solid black; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0cm; padding-bottom: 0cm&quot;&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 12.0pt; font-family: &apos;Times New Roman&apos;,serif&quot;&gt;Queries per second&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;height: 24.25pt; border-left: medium none; border-right: 1.0pt solid black; border-top: medium none; border-bottom: 1.0pt solid black; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0cm; padding-bottom: 0cm&quot;&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 12.0pt; font-family: &apos;Times New Roman&apos;,serif&quot;&gt;481.27&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;height: 24.25pt; border-left: medium none; border-right: 1.0pt solid black; border-top: medium none; border-bottom: 1.0pt solid black; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0cm; padding-bottom: 0cm&quot;&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 12.0pt; font-family: &apos;Times New Roman&apos;,serif&quot;&gt;73.45&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;height: 24.25pt; border-left: medium none; border-right: 1.0pt solid black; border-top: medium none; border-bottom: 1.0pt solid black; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0cm; padding-bottom: 0cm&quot;&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 12.0pt; font-family: &apos;Times New Roman&apos;,serif&quot;&gt;245.83&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;height: 24.25pt; border-left: medium none; border-right: 1.0pt solid black; border-top: medium none; border-bottom: 1.0pt solid black; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0cm; padding-bottom: 0cm&quot;&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 12.0pt; font-family: &apos;Times New Roman&apos;,serif&quot;&gt;484.41&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;Cpu&lt;span style=&quot;FONT-FAMILY: 宋体; COLOR: black; FONT-SIZE: 9pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana&quot;&gt;占用：80%&lt;span style=&quot;FONT-FAMILY: 宋体; COLOR: black; FONT-SIZE: 9pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana&quot;&gt;左右&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;Ram&lt;span style=&quot;FONT-FAMILY: 宋体; COLOR: black; FONT-SIZE: 9pt; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana&quot;&gt;占用：0.2%&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;</description>
		<guid>http://www.517sou.net/Article/BIND-and-Berkeley-DB-realization-of-DNS-dynamic-update.aspx</guid>
		<trackback:ping>http://www.517sou.net/Article/528/Trackback.ashx</trackback:ping>
		<comments>http://www.517sou.net/Article/BIND-and-Berkeley-DB-realization-of-DNS-dynamic-update.aspx#CommentPostAnchor</comments>
		<wfw:commentRss>http://www.517sou.net/Article/528/Feeds.ashx</wfw:commentRss>
	</item>
	<item>
		<link>http://www.517sou.net/Article/bind-dlz-with-mysql.aspx</link>
		<title>Bind-DLZ with MySQL</title>
		<author>shanyiwan@live.com()</author>
		<category>DNS技术</category>
		<pubDate>Thu, 02 Sep 2010 00:43:53 GMT</pubDate>
		<description>&lt;h2&gt;Bind-DLZ with MySQL&lt;/h2&gt;&lt;div class=&quot;entry&quot;&gt;&lt;p&gt;DNS management with Bind has traditionally been flat files and slave/master configurations. Bind also has a feature/extension called DLZ — dynamically loaded zones. This feature can be very useful when designing applications that use databases or directories for storage rather than having to design your application to address a filesystem to create resource records or zone files.&lt;/p&gt;&lt;p&gt;In this article, I will explain how to set this up for a configuration where there are thousands of name-based virtual hosts hosted on the same VIP/email infrastructure using the same resource record on a CentOS 5.X system using MySQL to store records. The Bind version is 9.6.0-P1.&lt;/p&gt;&lt;p&gt;The first step is to install any pre-requisites:&lt;/p&gt;&lt;pre&gt;
yum install openssl-devel mysql-devel openldap-devel unixODBC-devel gcc
&lt;/pre&gt;&lt;p&gt;Note that you’ll want to uninstall &lt;code&gt;gcc&lt;/code&gt; after this process is complete to reduce the likelihood of an attacker compiling an exploit on this box if they were to gain unprivileged access.&lt;/p&gt;&lt;p&gt;Next, download and extract the Bind sources:&lt;/p&gt;&lt;pre&gt;
pushd /tmp/
curl -C - -L -O &apos;http://ftp.isc.org/isc/bind9/9.6.0-P1/bind-9.6.0-P1.tar.gz&apos;
tar xzvf bind-9.6.0-P1.tar.gz
pushd bind-9.6.0-P1
&lt;/pre&gt;&lt;p&gt;If compiling on a 64 bit system, you might have to setup some variables so that the appropriate mysql libraries are found:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;export CPPFLAGS=&amp;quot;-I/usr/lib64/mysql $CPPFLAGS&amp;quot;&lt;br /&gt;export LDFLAGS=&amp;quot;-L/usr/lib64/mysql $LDFLAGS&amp;quot;&lt;br /&gt;export LD_LIBRARY_PATH=&amp;quot;/usr/lib64/mysql&amp;quot;&lt;br /&gt;&lt;/code&gt;&lt;/p&gt;&lt;p&gt;The next step is to run configure — this example uses mysql only:&lt;/p&gt;&lt;pre&gt;
./configure  \
  --prefix=/usr/local/bind  \
  --disable-openssl-version-check \
  --with-dlz-mysql=yes
&lt;/pre&gt;&lt;p&gt;Once successful with configure, the next step is to install:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;make &amp;amp;&amp;amp; sudo make install&lt;br /&gt;&lt;/code&gt;&lt;/p&gt;&lt;p&gt;Be sure to add a user and group, as well as setup some basic directories for data:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;groupadd -r -g 25 named&lt;br /&gt;useradd -r -u 25 -s /bin/nologin -d /usr/local/named -g named named&lt;br /&gt;mkdir /var/cache/bind&lt;br /&gt;chown named:named /var/cache/bind&lt;br /&gt;&lt;/code&gt;&lt;/p&gt;&lt;p&gt;Now that the easy part is finished, the next step is to setup MySQL to store the appropriate DNS records.&lt;/p&gt;&lt;p&gt;In this example, data is populated in MySQL via a stored procedure in SQL Server via a linked server to a MySQL master (ODBC). A python script then creates the necessary entries in the postfix database to allow mail routing to occur. One of the tables populated here is the postfix.domains table. This is simply a list of all domains that are hosted at this site. I take advantage of this to replicate only this table to each of my DNS servers running MySQL and Bind-DLZ locally. This explanation will help the reader understand the next portion where I setup tables and views and populate them with data.&lt;/p&gt;&lt;p&gt;The next step is to create the database which will store the records. I use a database called postfix since my setup is tightly coupled with email routing and replication from the email database. (Login to MySQL to perform the following actions or script as appropriate.)&lt;br /&gt;&lt;code&gt;&lt;br /&gt;mysql&amp;gt; create database postfix;&lt;br /&gt;&lt;/code&gt;&lt;/p&gt;&lt;p&gt;Next, I create a template of resource records that will apply to all zones hosted within MySQL. (Note that this is a site which hosts thousands of domains on the same VIP/email architecture.)&lt;/p&gt;&lt;pre&gt;
DROP TABLE IF EXISTS dns_values;
CREATE TABLE dns_values (
  host VARCHAR(255) DEFAULT &apos;&apos; NOT NULL,
  type ENUM(&apos;SOA&apos;,&apos;NS&apos;,&apos;MX&apos;,&apos;A&apos;,&apos;CNAME&apos;,&apos;TXT&apos;,&apos;HINFO&apos;,&apos;PTR&apos;) NOT NULL DEFAULT &apos;SOA&apos;,
  data VARCHAR(255),
  ttl INT(11) DEFAULT 300 NOT NULL,
  mx_priority VARCHAR(10),
  refresh INT(11) DEFAULT 0 NOT NULL,
  retry INT(11) DEFAULT 0 NOT NULL,
  expire INT(11) DEFAULT 0 NOT NULL,
  minimum INT(11) DEFAULT 0 NOT NULL,
  serial BIGINT(20) DEFAULT 0 NOT NULL,
  resp_person VARCHAR(255),
  primary_ns VARCHAR(255),
  key host_index (host),
  key type_index (type)
) ENGINE=MyISAM;
&lt;/pre&gt;&lt;p&gt;The next step is to populate the basic set:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;mysql&amp;gt; LOCK TABLES `dns_values` WRITE;&lt;br /&gt;/*!40000 ALTER TABLE `dns_values` DISABLE KEYS */;&lt;br /&gt;INSERT INTO `dns_values` VALUES&lt;br /&gt;(&apos;@&apos;,&apos;SOA&apos;,&apos;root.mail.example.com.&apos;,300,NULL,10800,900,604800,600,2009020401,&apos;root.mail.example.com.&apos;,&apos;ns1.example.com.&apos;),&lt;br /&gt;(&apos;@&apos;,&apos;NS&apos;,&apos;ns1.example.com.&apos;,300,NULL,10800,900,604800,600,2009020401,NULL,NULL),&lt;br /&gt;(&apos;@&apos;,&apos;NS&apos;,&apos;ns2.example.com.&apos;,300,NULL,10800,900,604800,600,2009020401,NULL,NULL),&lt;br /&gt;(&apos;@&apos;,&apos;A&apos;,&apos;xxx.xxx.xxx.xxx&apos;,300,NULL,10800,900,604800,600,2009020401,NULL,NULL),&lt;br /&gt;(&apos;images&apos;,&apos;A&apos;,&apos;xxx.xxx.xxx.xxx&apos;,300,NULL,10800,900,604800,600,2009020401,NULL,NULL),&lt;br /&gt;(&apos;mail&apos;,&apos;A&apos;,&apos;xxx.xxx.xxx.xxx&apos;,300,NULL,10800,900,604800,600,2009020401,NULL,NULL),&lt;br /&gt;(&apos;*&apos;,&apos;A&apos;,&apos;xxx.xxx.xxx.xxx&apos;,300,NULL,10800,900,604800,600,2009020401,NULL,NULL),&lt;br /&gt;(&apos;imap&apos;,&apos;CNAME&apos;,&apos;mail.example.com.&apos;,300,NULL,10800,900,604800,600,2009020401,NULL,NULL),&lt;br /&gt;(&apos;smtp&apos;,&apos;CNAME&apos;,&apos;mail.example.com.&apos;,300,NULL,10800,900,604800,600,2009020401,NULL,NULL),&lt;br /&gt;(&apos;@&apos;,&apos;TXT&apos;,&apos;v=spf2.0/pra mx ip4:xxx.xxx.xxx.0/24 -all&apos;,300,NULL,10800,900,604800,600,2009020401,NULL,NULL),&lt;br /&gt;(&apos;@&apos;,&apos;TXT&apos;,&apos;v=spf1 mx ip4:xxx.xxx.xxx.0/24 -all&apos;,300,NULL,10800,900,604800,600,2009020401,NULL,NULL),&lt;br /&gt;(&apos;@&apos;,&apos;MX&apos;,&apos;mail.example.com.&apos;,300,&apos;10&apos;,10800,900,604800,600,2009020401,NULL,NULL),&lt;br /&gt;(&apos;webmail&apos;,&apos;CNAME&apos;,&apos;mail.example.com.&apos;,300,NULL,10800,900,604800,600,2009020401,NULL,NULL);&lt;br /&gt;/*!40000 ALTER TABLE `dns_values` ENABLE KEYS */;&lt;br /&gt;UNLOCK TABLES;&lt;br /&gt;&lt;/code&gt;&lt;/p&gt;&lt;p&gt;Create the postfix.domains table:&lt;/p&gt;&lt;pre&gt;
mysql&amp;gt; CREATE TABLE domains (
  domain varchar(128) NOT NULL default &apos;&apos;,
  PRIMARY KEY  (domain)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
&lt;/pre&gt;&lt;p&gt;Go ahead and populate the domains table with some values. Note that I replicate data from another table but you can just as well enter any values manually.&lt;br /&gt;&lt;code&gt;&lt;br /&gt;mysql&amp;gt; insert into domains (domain) values(&apos;example.com&apos;);&lt;br /&gt;&lt;/code&gt;&lt;/p&gt;&lt;p&gt;The next step is to create a view that will combine the dns_values table with the domains table to present all records as one table:&lt;/p&gt;&lt;pre&gt;
mysql&amp;gt;CREATE VIEW dns_records AS
SELECT
  d.domain        as zone
  ,dv.host        as host
  ,dv.type        as type
  ,dv.data        as data
  ,dv.ttl         as ttl
  ,dv.mx_priority as mx_priority
  ,dv.refresh     as refresh
  ,dv.retry       as retry
  ,dv.expire      as expire
  ,dv.minimum     as minimum
  ,dv.serial      as serial
  ,dv.resp_person as resp_person
  ,dv.primary_ns  as primary_ns
FROM domains d, dns_values dv ;
&lt;/pre&gt;&lt;p&gt;Next, setup grants on MySQL to allow the user who is accessing MySQL from Bind access:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;mysql&amp;gt; GRANT USAGE,SELECT ON postfix.* TO binddlz@localhost identified by &apos;trickypassword&apos;;&lt;br /&gt;FLUSH PRIVILEGES;&lt;br /&gt;&lt;/code&gt;&lt;/p&gt;&lt;p&gt;I started with a pretty basic named.conf file:&lt;/p&gt;&lt;pre&gt;
key rndc {
  algorithm hmac-md5 ;
  secret &amp;quot;longsecret&amp;quot;;
};
controls {
  inet 127.0.0.1 allow { localhost; } keys { rndc; };
};
include &amp;quot;/usr/local/bind/etc/named.conf.options&amp;quot;;
// prime the server with knowledge of the root servers
zone &amp;quot;.&amp;quot; {
  type hint;
  file &amp;quot;/usr/local/bind/etc/db.root&amp;quot;;
};
// setup local zones
zone &amp;quot;localhost&amp;quot; {
  type master;
  file &amp;quot;/usr/local/bind/etc/db.local&amp;quot;;
};
zone &amp;quot;127.in-addr.arpa&amp;quot; {
  type master;
  file &amp;quot;/usr/local/bind/etc/db.127&amp;quot;;
};
zone &amp;quot;0.in-addr.arpa&amp;quot; {
  type master;
  file &amp;quot;/usr/local/bind/etc/db.0&amp;quot;;
};
zone &amp;quot;255.in-addr.arpa&amp;quot; {
  type master;
  file &amp;quot;/usr/local/bind/etc/db.255&amp;quot;;
};
include &amp;quot;/usr/local/bind/etc/named.custom.zones&amp;quot;;
include &amp;quot;/usr/local/bind/etc/named.dlz.zones&amp;quot;;
&lt;/pre&gt;&lt;p&gt;As far as &lt;code&gt;named.conf.options&lt;/code&gt;, it is also pretty basic:&lt;/p&gt;&lt;pre&gt;
options {
  directory &amp;quot;/var/cache/bind&amp;quot;;
  allow-transfer { xxx.xxx.xxx.xxx; xxx.xxx.xxx.xxx; };
  zone-statistics yes;
  statistics-file &amp;quot;/usr/local/bind/var/stats/named-stats.out&amp;quot;;
  recursion no;
};
&lt;/pre&gt;&lt;p&gt;As you can see, I simply included the following configuration portion as &lt;code&gt;named.dlz.zones&lt;/code&gt;.&lt;/p&gt;&lt;pre&gt;
dlz &amp;quot;mysql zone&amp;quot; {
  database &amp;quot;mysql
  {host=localhost dbname=postfix user=binddlz pass=trickypassword ssl=false}
  {select zone from dns_records where zone = &apos;%zone%&apos;}
  {select ttl, type, mx_priority, case
      when lower(type)=&apos;txt&apos; then concat(&apos;\&amp;quot;&apos;, data, &apos;\&amp;quot;&apos;)
      when lower(type) = &apos;soa&apos; then concat_ws(&apos; &apos;, data, resp_person, serial, refresh, retry, expire, minimum)
    else data end from dns_records_view where zone = &apos;%zone%&apos; and host = &apos;%record%&apos;}&amp;quot;;
};
&lt;/pre&gt;&lt;p&gt;Now start Bind with the following command and test:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;/usr/local/bind/sbin/named -c /usr/local/bind/etc/named.conf -f -g -u named&lt;br /&gt;&lt;/code&gt;&lt;/p&gt;&lt;p&gt;Useful tips:&lt;br /&gt;* do not include both ns and contact in SOA record, use only respo_contact in either data or resp_contact fields&lt;br /&gt;* make sure you restart Bind every time you restart MySQL or you will lose your connection(s)&lt;br /&gt;* if you would like to create the dns_records table without a view, simply use the dns_values table and add the zone as the first column&lt;/p&gt;&lt;/div&gt;&lt;p&gt;来源：&lt;a href=&quot;http://itsecureadmin.com/2010/09/bind-dlz-with-mysql/&quot; target=&quot;_blank&quot;&gt;http://itsecureadmin.com/2010/09/bind-dlz-with-mysql/&lt;/a&gt;&lt;/p&gt;</description>
		<guid>http://www.517sou.net/Article/bind-dlz-with-mysql.aspx</guid>
		<trackback:ping>http://www.517sou.net/Article/516/Trackback.ashx</trackback:ping>
		<comments>http://www.517sou.net/Article/bind-dlz-with-mysql.aspx#CommentPostAnchor</comments>
		<wfw:commentRss>http://www.517sou.net/Article/516/Feeds.ashx</wfw:commentRss>
	</item>
	<item>
		<link>http://www.517sou.net/Article/433.aspx</link>
		<title>Logfile format for BIND queries</title>
		<author>shanyiwan@live.com()</author>
		<category>DNS技术</category>
		<pubDate>Fri, 23 Apr 2010 08:09:26 GMT</pubDate>
		<description>&lt;p&gt;BIND查询日志格式分析&lt;/p&gt;&lt;p&gt;Nov 21 12:34:41 dns named[780]: [ID 866145 local0.info] client 1.2.3.4#32773: query: yikes.com IN MX -E&lt;/p&gt;&lt;p&gt;23-Apr-2010 15:21:15.316 queries: client 192.168.146.18#55771: query: 2030m.com IN A +ED (192.168.146.149)&lt;br /&gt;23-Apr-2010 15:21:15.348 queries: client 192.168.146.18#47779: query: 20304050.cn IN A +ED (192.168.146.149)&lt;br /&gt;23-Apr-2010 15:21:15.348 queries: client 192.168.146.18#21651: query: 2032.cc IN A +ED (192.168.146.149)&lt;br /&gt;23-Apr-2010 15:21:15.348 queries: client 192.168.146.30#33151: query: 2mysite.net IN A + (192.168.146.150)&lt;br /&gt;23-Apr-2010 15:21:15.351 queries: client 192.168.146.30#39878: query: 2mysite.net IN A +T (192.168.146.150)&lt;/p&gt;&lt;p&gt;The entries should be clear enough: the date and time the query was received; the source IP address and port number used by the client;and the name, class and qtype. The final field shows if the query had the rd (recursion desired) bit set (+) or not (-) -- typically showing if the query came from a name server or stub resolver -- or if EDNS0 (E) was used.&lt;/p&gt;&lt;p&gt;All of the text up to the record type (MX in this case) made sense, but I had no idea what the “-E” meant. Being the curious person I am, I dug through the BIND source code to locate the logging code. After a couple of find statements, I was able to locate the logging code in query.c:&lt;/p&gt;&lt;pre&gt;
ns_client_log(client, NS_LOGCATEGORY_QUERIES, NS_LOGMODULE_QUERY,
                     level, &amp;quot;query: %s %s %s %s%s%s&amp;quot;, namebuf, classname,
                     typename, WANTRECURSION(client) ? &amp;quot;+&amp;quot; : &amp;quot;-&amp;quot;,
                     (client-&amp;gt;signer != NULL) ? &amp;quot;S&amp;quot;: &amp;quot;&amp;quot;,
                     (client-&amp;gt;opt != NULL) ? &amp;quot;E&amp;quot; : &amp;quot;&amp;quot;);
&lt;/pre&gt;&lt;p&gt;So a “+” or “-” in a query log entry indicates that a client requested recursion, and the “E” means that the query requested &lt;a onclick=&quot;javascript:pageTracker._trackPageview(&apos;/outbound/article/http://tools.ietf.org/html/rfc2671&apos;);&quot; href=&quot;http://tools.ietf.org/html/rfc2671&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#800080&quot;&gt;EDNS0&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;. I would like to thank Knobee for his feedback on this post.&lt;/p&gt;</description>
		<guid>http://www.517sou.net/Article/433.aspx</guid>
		<trackback:ping>http://www.517sou.net/Article/433/Trackback.ashx</trackback:ping>
		<comments>http://www.517sou.net/Article/433.aspx#CommentPostAnchor</comments>
		<wfw:commentRss>http://www.517sou.net/Article/433/Feeds.ashx</wfw:commentRss>
	</item>
	<item>
		<link>http://www.517sou.net/Article/265.aspx</link>
		<title>High Performance caching-only (recursive) BIND9 Setup</title>
		<author>shanyiwan@live.com()</author>
		<category>DNS技术</category>
		<pubDate>Sun, 27 Sep 2009 07:04:21 GMT</pubDate>
		<description>&lt;h1&gt;High Performance caching-only (recursive) BIND9 Setup&lt;/h1&gt;&lt;h2&gt;In The Beginning there was nothing, which exploded. -- Terry Pratchett&lt;/h2&gt;&lt;div id=&quot;center&quot;&gt;&lt;img class=&quot;Image&quot; alt=&quot;was-zum-frell.png&quot; src=&quot;http://www.517sou.net/Attach/month_0909/0mnh5s_150646_1.png&quot; /&gt;&lt;p&gt;Ok, so what happened here? Well we migrated our two singlethreading BIND8 processes to one multithreading BIND9 process. The query-load did not change at all, but keeping its in-memory database in order using a modell that is thread-safe seems to have cost us a huge amount of user cpu time. Wasn&apos;t BIND9 supposed to even work better on an SMP system with two CPUs than two BIND8 processes for it only needs to keep one database in order? Well apparently not. Lets ask the bind9-workers Mailinglist i thought, and i got the following very helpful replies from Jinmei Tatuya:&lt;/p&gt;&lt;pre&gt;
 I&apos;d first like to recommend disabling threads.  From my experiences,
 enable-threads buys almost nothing for most OSes, unfortunately.  If
 you can allow the configuration with 2 named processes, it should
 provide better performance than a single BIND9 process with 2 threads.
 
 Secondly, according to your memory usage and configuration (i.e.,
 max-cache-size=700M, 623m used), it looks like named reaches the
 high-water mark for the specified maximum, and tries to purge some
 cache entries.  If this periodically happens, it may be the reason for
 the high CPU usage.  So, if possible, it might help if you can add
 more memory which can afford the typical use case under the high-water
 level.
 
 ...
 
 If you go with disabling threads, you may also want to enable
 &amp;quot;internal memory allocation&amp;quot;.  (I hear that) it should use memory more
 efficiently (and can make the server faster) but is disabled by
 default due to response-performance reasons in the threaded case.  You
 can enable this feature by adding the following line
 
 #define ISC_MEM_USE_INTERNAL_MALLOC 1
 
 just before the following part of bind9/lib/isc/mem.c:
 
 #ifndef ISC_MEM_USE_INTERNAL_MALLOC
 #define ISC_MEM_USE_INTERNAL_MALLOC 0
 #endif
&lt;span style=&quot;color: #ff0000&quot;&gt;注：9.6.1-P1版本位置：lib/isc/include/isc/mem.h，其中已经设置：#define ISC_MEM_USE_INTERNAL_MALLOC 1&lt;/span&gt;&lt;/pre&gt;&lt;p&gt;I opted for the latter option, to disable threading, and applied this &lt;a href=&quot;http://zaphods.net/~zaphodb/bind-9.3.1-internal-malloc.patch&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;patch&lt;/font&gt;&lt;/u&gt;&lt;/a&gt; and set up my BIND9 configuration and loadbalancer to support two processes. You can achieve this by taking care never to bind more than one BIND9 process to the same IP-Address, giving it a custom pidfile and last but not least configure rndc to connect for another port on localhost for the second process.&lt;/p&gt;&lt;img class=&quot;Image&quot; alt=&quot;bind-comparison.png&quot; src=&quot;http://www.517sou.net/Attach/month_0909/k5fxp1_150650_2.png&quot; /&gt;&lt;img class=&quot;Image&quot; alt=&quot;bind9qstats.gif&quot; src=&quot;http://www.517sou.net/Attach/month_0909/5dg4aa_150651_3.gif&quot; /&gt;&lt;/div&gt;&lt;p&gt;From:http://zaphods.net/~zaphodb/high-performance-bind9.html&lt;/p&gt;</description>
		<guid>http://www.517sou.net/Article/265.aspx</guid>
		<trackback:ping>http://www.517sou.net/Article/265/Trackback.ashx</trackback:ping>
		<comments>http://www.517sou.net/Article/265.aspx#CommentPostAnchor</comments>
		<wfw:commentRss>http://www.517sou.net/Article/265/Feeds.ashx</wfw:commentRss>
	</item>
	<item>
		<link>http://www.517sou.net/Article/263.aspx</link>
		<title>支持海量域名的dns架构</title>
		<author>shanyiwan@live.com()</author>
		<category>DNS技术</category>
		<pubDate>Fri, 25 Sep 2009 07:54:48 GMT</pubDate>
		<description>&lt;p&gt;&lt;font color=&quot;#ff4500&quot;&gt;&lt;font color=&quot;#000000&quot;&gt;支持海量域名的dns架构&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font color=&quot;#ff4500&quot;&gt;&lt;strong&gt;环境&lt;/strong&gt;&lt;/font&gt; 操作系统： Redhat 5.2 64位&lt;/p&gt;&lt;p&gt;dns服务器：bind9.5.0-p1&lt;/p&gt;&lt;p&gt;数据库： mysql5.1&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;h1&gt;1. 缘起&lt;/h1&gt;&lt;blockquote&gt;&lt;p&gt;公司前些年成为了域名注册商，起初采用&lt;strong&gt;一个zone文件存放一个zone配置&lt;/strong&gt;的传统方式。后了解zone的增长量将会非常大，在n个百万级。在进行了测试和使用一段时间后，发现当zone数量巨大的情况下，采用传统的zone文件存放zone配置，存在着很大的问题。如将所有域名都放在同一服务器上，在需要重新启动bind时，花费的时间惊人，从下图看出当zone的数量达到30万时，载入时间已经需要近1小时，这显然是不能接受的&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;http://www.517sou.net/Attach/month_0909/85l5vx_160851_1.jpg&quot; rel=&quot;lightbox&quot; target=&quot;_blank&quot;&gt;&lt;img class=&quot;alignnone size-medium wp-image-240&quot; title=&quot;dns-mysql&quot; alt=&quot;&quot; src=&quot;http://www.517sou.net/Attach/month_0909/3fwwpl_160852_2.jpg&quot; width=&quot;300&quot; height=&quot;202&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;后经过权衡，决定以10万为分界，毎10万域名使用一主一辅2台服务器。这种结构尽管有一些不方便，但因为传统的方式稳定性好、查询效率高，所以也用了一段时间。然而当zone的数量到了60多万时，服务器达到了14台，终于觉得不能容忍这种方式了，因为一、太浪费服务器了，二、管理非常不方便，于是乎决心寻找替代的方案&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;h1&gt;2. 方案选择&lt;/h1&gt;&lt;blockquote&gt;&lt;p&gt;在查找一些资料之后，毋庸置疑，基于bind的DLZ（dynamic load zone）是首选。但在DLZ支持的诸多后台数据库中，并不是起初就选择mysql的。bind的查询效率可以达到2万~3万每秒，在DLZ官方，性能评测只有Berkerly DB的查询效率可以达到4000至12000 bps每秒，比较接近bind的原始查询效率，而其他的mysql什么的都只有600~800每秒，Berkerly DB的优势非常明显，因此起初试图使用Berkerly DB作为后台数据库，但最终还是选择了mysql，主要原因如下：&lt;/p&gt;&lt;/blockquote&gt;&lt;ul&gt;&lt;li&gt;使用Berkerly DB的资料非常少&lt;/li&gt;&lt;li&gt;使用Berkerly DB不支持类似mysql的sql语句，而仅仅支持api接口，测试和使用门槛比较高&lt;/li&gt;&lt;li&gt;没有熟悉Berkerly DB的人员支持，而mysql有同部门的DBA支持 = 性能问题 =&lt;/li&gt;&lt;/ul&gt;&lt;blockquote&gt;&lt;p&gt;在初步确定采用mysql作为数据库之后，必需要解决查询效率的问题，否则就很难真正投入生产环境。mysql作为后台的查询效率经测试在600-800之间，而我们预期的查询效率必需要达到3k~4k。该结构为什么会慢呢？主要原因就是采用mysql作为后台数据库时，bind不能起用多线程，只能采用单进程。而毎查询一个域名需要执行3~5条sql，所有的sql只能串行处理，所以效率才这么低。解决办法：&lt;/p&gt;&lt;/blockquote&gt;&lt;ul&gt;&lt;li&gt;修改DLZ源码，将单进程改为多线程&lt;/li&gt;&lt;/ul&gt;&lt;blockquote&gt;&lt;p&gt;该方法经一位熟悉C的同事验证，不可行。(也许CU有大虾能搞定的，那就更方便易行了)&lt;/p&gt;&lt;/blockquote&gt;&lt;ul&gt;&lt;li&gt;在bind和mysql之间加一层cache&lt;/li&gt;&lt;/ul&gt;&lt;blockquote&gt;&lt;p&gt;在我们的结构中，zone数量非常大，单个域名在短时间被重复查询的几率并不高，分析认为该方法不是特别适合我们的结构，因此未进行测试&lt;/p&gt;&lt;/blockquote&gt;&lt;ul&gt;&lt;li&gt;人造“&lt;strong&gt;&lt;font color=&quot;#ff4500&quot;&gt;多线程&lt;/font&gt;&lt;/strong&gt;”&lt;/li&gt;&lt;/ul&gt;&lt;blockquote&gt;&lt;p&gt;查询效率低的关键原因是串行，因此我们试图人为的实现并行，经过测试后发现可以通过起多个named进程的方式，实现该想法。最终是服务器起8个地址，每个地址单独起一个named。起8个named之后的查询效率如下图，我们可以看出，单个named的查询效率随着named数量的增加从700多降至400，特别是到后期下降趋势很不明显。总体性能从700升至3200左右，两台dns服务器可达到6000多，完全可以满足我们的需要：&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;http://www.517sou.net/Attach/month_0909/qjs11l_160852_3.jpg&quot; rel=&quot;lightbox&quot; target=&quot;_blank&quot;&gt;&lt;img class=&quot;alignnone size-medium wp-image-242&quot; title=&quot;rate&quot; alt=&quot;&quot; src=&quot;http://www.517sou.net/Attach/month_0909/3slamm_160852_4.jpg&quot; width=&quot;300&quot; height=&quot;178&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;h1&gt;3. 框架结构&lt;/h1&gt;&lt;blockquote&gt;&lt;p&gt;这个系统的结构最前端是两台F5的负载均衡设备（这原来就有），后面是两台dns服务器，每台起8个named进程，分别连至后台的mysql数据库。F5的每个vip对应每台dns服务器4个进程，这样整个系统没有任何单点。任何一台设备down了bouquet不影响使用。结构图如下：&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;http://www.517sou.net/Attach/month_0909/rwhfwn_160853_5.jpg&quot; rel=&quot;lightbox&quot; target=&quot;_blank&quot;&gt;&lt;img class=&quot;alignnone size-medium wp-image-243&quot; title=&quot;jiegou&quot; alt=&quot;&quot; src=&quot;http://www.517sou.net/Attach/month_0909/pw20g9_160853_6.jpg&quot; width=&quot;300&quot; height=&quot;225&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;h1&gt;4. 安装配置&lt;/h1&gt;&lt;p&gt;&lt;/p&gt;&lt;h2&gt;4.1. 首先安装mysql（不然bind找不到mysql，无法安装mysql的dlz插件）&lt;/h2&gt;&lt;p&gt;&lt;/p&gt;&lt;h3&gt;4.1.1. 创建OS帐号&lt;/h3&gt;&lt;p&gt;#添加mysql组和用户，之所以指定为601，主要是为了方便各台服务器之间权限统一&lt;/p&gt;&lt;pre&gt;&lt;ol class=&quot;dp-xml&quot;&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&lt;span&gt;groupadd&amp;nbsp;-g&amp;nbsp;601&amp;nbsp;mysql&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;useradd&amp;nbsp;-c&amp;nbsp;“mysql&amp;nbsp;software&amp;nbsp;owner”&amp;nbsp;-g&amp;nbsp;mysql&amp;nbsp;-u&amp;nbsp;601&amp;nbsp;mysql&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;p&gt;&lt;/p&gt;&lt;h3&gt;4.1.2. 目录结构准备&lt;/h3&gt;&lt;p&gt;#编辑自己的配置文件my.cnf和log以及innodb的相关目录&lt;/p&gt;&lt;pre&gt;&lt;ol class=&quot;dp-xml&quot;&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&lt;span&gt;mkdir&amp;nbsp;/usr/local/mysql&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&lt;span&gt;mkdir&amp;nbsp;/usr/local/mysql/sock&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&lt;span&gt;mkdir&amp;nbsp;/usr/local/mysql/log &amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;su&amp;nbsp;-&amp;nbsp;mysql&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;mkdir&amp;nbsp;/home/mysql/mysqldata&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;mkdir&amp;nbsp;/home/mysql/mysqldata/binlog&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;mkdir&amp;nbsp;/home/mysql/mysqldata/mydata&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;mkdir&amp;nbsp;/home/mysql/mysqldata/innodb_ts&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;mkdir&amp;nbsp;/home/mysql/mysqldata/innodb_log&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;mkdir&amp;nbsp;/home/mysql/mysqldata/tmpdir &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;exit&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;mkdir&amp;nbsp;/data&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;ln&amp;nbsp;-s&amp;nbsp;/home/mysql/mysqldata&amp;nbsp;/data/mysqldata &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;chown&amp;nbsp;-R&amp;nbsp;mysql:mysql&amp;nbsp;/usr/local/mysql/log&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;chown&amp;nbsp;-R&amp;nbsp;mysql:mysql&amp;nbsp;/usr/local/mysql/sock&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;chown&amp;nbsp;-R&amp;nbsp;mysql:mysql&amp;nbsp;/data/mysqldata&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;chown&amp;nbsp;-R&amp;nbsp;mysql:mysql&amp;nbsp;/data/mysqldata/mydata&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;chown&amp;nbsp;-R&amp;nbsp;mysql:mysql&amp;nbsp;/data/mysqldata/binlog&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;chown&amp;nbsp;-R&amp;nbsp;mysql:mysql&amp;nbsp;/data/mysqldata/innodb_ts&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;chown&amp;nbsp;-R&amp;nbsp;mysql:mysql&amp;nbsp;/data/mysqldata/innodb_log&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;chown&amp;nbsp;-R&amp;nbsp;mysql:mysql&amp;nbsp;/data/mysqldata/tmpdir &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;p&gt;4.1.3. 编译安装源码&lt;/p&gt;&lt;pre&gt;&lt;ol class=&quot;dp-xml&quot;&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&lt;span&gt;make&amp;nbsp;clean&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;p&gt;#这里的config参数可以根据数据库相关需求稍作调整&lt;/p&gt;&lt;pre&gt;&lt;ol class=&quot;dp-xml&quot;&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&lt;span&gt;./configure&amp;nbsp;–&lt;/span&gt;&lt;span class=&quot;attribute&quot;&gt;prefix&lt;/span&gt;&lt;span&gt;=/usr/local/mysql&amp;nbsp;\ &amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;–without-debug&amp;nbsp;\ &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;–without-bench&amp;nbsp;\ &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;–disable-shared&amp;nbsp;\ &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;–enable-thread-safe-client&amp;nbsp;\ &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;–enable-assembler&amp;nbsp;\ &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;–enable-profiling&amp;nbsp;\ &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;–&lt;/span&gt;&lt;span class=&quot;attribute&quot;&gt;with-mysqld-ldflags&lt;/span&gt;&lt;span&gt;=-all-static&amp;nbsp;\ &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;–&lt;/span&gt;&lt;span class=&quot;attribute&quot;&gt;with-client-ldflags&lt;/span&gt;&lt;span&gt;=-all-static&amp;nbsp;\ &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;–&lt;/span&gt;&lt;span class=&quot;attribute&quot;&gt;with-charset&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span class=&quot;attribute-value&quot;&gt;latin1&lt;/span&gt;&lt;span&gt;&amp;nbsp;\ &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;–&lt;/span&gt;&lt;span class=&quot;attribute&quot;&gt;with-extra-charset&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span class=&quot;attribute-value&quot;&gt;utf8&lt;/span&gt;&lt;span&gt;,gbk&amp;nbsp;\ &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;–with-innodb&amp;nbsp;\ &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;–with-csv-storage-engine&amp;nbsp;\ &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;–with-federated-storage-engine&amp;nbsp;\ &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;–&lt;/span&gt;&lt;span class=&quot;attribute&quot;&gt;with-mysqld-user&lt;/span&gt;&lt;span&gt;=mysql&amp;nbsp;\ &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;–without-embedded-server&amp;nbsp;\ &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;–&lt;/span&gt;&lt;span class=&quot;attribute&quot;&gt;with-server-suffix&lt;/span&gt;&lt;span&gt;=-community&amp;nbsp;\ &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;–&lt;/span&gt;&lt;span class=&quot;attribute&quot;&gt;with-unix-socket-path&lt;/span&gt;&lt;span&gt;=/usr/local/mysql/sock/mysql.sock&amp;nbsp;\&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;–&lt;/span&gt;&lt;span class=&quot;attribute&quot;&gt;with-mysqld-libs&lt;/span&gt;&lt;span&gt;=-lmtmalloc&amp;nbsp;\ &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;make&amp;nbsp;make&amp;nbsp;install&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;p&gt;#准备my.cnf文件需要注意的几个目录配置：&lt;/p&gt;&lt;pre&gt;&lt;ol class=&quot;dp-xml&quot;&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&lt;span class=&quot;attribute&quot;&gt;log-error&lt;/span&gt;&lt;span&gt;=/usr/local/mysql/log/error.log&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class=&quot;attribute&quot;&gt;log_slow_queries&lt;/span&gt;&lt;span&gt;=/usr/local/mysql/log/slow_query.log&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span class=&quot;attribute&quot;&gt;datadir&lt;/span&gt;&lt;span&gt;=/data/mysqldata/mydata&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;attribute&quot;&gt;tmpdir&lt;/span&gt;&lt;span&gt;=/data/mysqldata/tmpdir&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class=&quot;attribute&quot;&gt;bin-log&lt;/span&gt;&lt;span&gt;=/data/mysqldata/binlog/mysql-bin&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span class=&quot;attribute&quot;&gt;innodb_data_home_dir&lt;/span&gt;&lt;span&gt;=/data/mysqldata/innodb_ts&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class=&quot;attribute&quot;&gt;innodb_log_group_home_dir&lt;/span&gt;&lt;span&gt;=/data/mysqldata/innodb_log&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;p&gt;其他相关参数进行针对性调整将准备好的my.cnf配置文件cp一份到/etc/my.cnf&lt;/p&gt;&lt;p&gt;创建系统表并修改目录权限&lt;/p&gt;&lt;pre&gt;&lt;ol class=&quot;dp-xml&quot;&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&lt;span&gt;cd&amp;nbsp;/usr/local/mysql &amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;bin/mysql_install_db&amp;nbsp;–&lt;/span&gt;&lt;span class=&quot;attribute&quot;&gt;user&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span class=&quot;attribute-value&quot;&gt;mysql&lt;/span&gt;&lt;span&gt;&amp;nbsp;–&lt;/span&gt;&lt;span class=&quot;attribute&quot;&gt;socket&lt;/span&gt;&lt;span&gt;=/usr/local/mysql/sock/mysql.sock&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;chown&amp;nbsp;-R&amp;nbsp;root&amp;nbsp;.&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;chgrp&amp;nbsp;-R&amp;nbsp;mysql&amp;nbsp;.&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;chown&amp;nbsp;-R&amp;nbsp;mysql&amp;nbsp;sock&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;chown&amp;nbsp;-R&amp;nbsp;mysql&amp;nbsp;log&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;p&gt;&lt;/p&gt;&lt;h3&gt;4.1.4. 启动&lt;/h3&gt;&lt;pre&gt;&lt;ol class=&quot;dp-xml&quot;&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&lt;span&gt;bin/mysqld_safe&amp;nbsp;–&lt;/span&gt;&lt;span class=&quot;attribute&quot;&gt;socket&lt;/span&gt;&lt;span&gt;=/usr/local/mysql/sock/mysql.sock&amp;nbsp;–&lt;/span&gt;&lt;span class=&quot;attribute&quot;&gt;user&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span class=&quot;attribute-value&quot;&gt;mysql&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;amp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;p&gt;&lt;/p&gt;&lt;h2&gt;4.2. 安装bind&lt;/h2&gt;&lt;p&gt;&lt;/p&gt;&lt;h3&gt;4.2.1. 创建用户&lt;/h3&gt;&lt;pre&gt;&lt;ol class=&quot;dp-xml&quot;&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&lt;span&gt;useradd&amp;nbsp;-d&amp;nbsp;/etc/namedb&amp;nbsp;-s&amp;nbsp;/bin/false&amp;nbsp;named&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;p&gt;&lt;/p&gt;&lt;h3&gt;4.2.2. 创建var目录并修改权限&lt;/h3&gt;&lt;pre&gt;&lt;ol class=&quot;dp-xml&quot;&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&lt;span&gt;mkdir&amp;nbsp;-p&amp;nbsp;/var/named&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&lt;span&gt;chown&amp;nbsp;-R&amp;nbsp;named:named&amp;nbsp;/etc/namedb&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&lt;span&gt;chown&amp;nbsp;-R&amp;nbsp;named:named&amp;nbsp;/var/named&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;p&gt;&lt;/p&gt;&lt;h3&gt;4.2.3. 编译安装&lt;/h3&gt;&lt;pre&gt;&lt;ol class=&quot;dp-xml&quot;&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&lt;span&gt;tar&amp;nbsp;-xzvf&amp;nbsp;bind-9.5.0-p1.tar.gz&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;./configure&amp;nbsp;–&lt;/span&gt;&lt;span class=&quot;attribute&quot;&gt;prefix&lt;/span&gt;&lt;span&gt;=/opt/named.9.5.0-p1&amp;nbsp;–&lt;/span&gt;&lt;span class=&quot;attribute&quot;&gt;sysconfdir&lt;/span&gt;&lt;span&gt;=/etc/namedb&amp;nbsp;–&lt;/span&gt;&lt;span class=&quot;attribute&quot;&gt;with-dlz-mysql&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span class=&quot;attribute-value&quot;&gt;yes&lt;/span&gt;&lt;span&gt;&amp;nbsp;–enable-largefile&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;p&gt;&lt;span style=&quot;color: #ff0000&quot;&gt;&amp;nbsp;注：&lt;/span&gt;采用mysql做后台数据库，千万不能用–enable-threads选项启用多线程，网上有一些朋友使用mysql做后台，谈到bind会莫名中断服务，大部分都是因为打开了多线程。&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;h3&gt;4.2.4. 修改/etc/init.d/named文件&lt;/h3&gt;&lt;p&gt;关键部分如下：&lt;/p&gt;&lt;pre&gt;&lt;ol class=&quot;dp-xml&quot;&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&lt;span&gt;[&amp;nbsp;-f&amp;nbsp;/opt/named/sbin/named&amp;nbsp;]&amp;nbsp;||&amp;nbsp;exit&amp;nbsp;0 &amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;[&amp;nbsp;-f&amp;nbsp;/etc/namedb/named.conf.11&amp;nbsp;]&amp;nbsp;||&amp;nbsp;exit&amp;nbsp;0 &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;#&amp;nbsp;See&amp;nbsp;how&amp;nbsp;we&amp;nbsp;were&amp;nbsp;called. &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;case&amp;nbsp;&amp;quot;$1&amp;quot;&amp;nbsp;in &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;start) &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;#&amp;nbsp;Start&amp;nbsp;daemons. &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;echo&amp;nbsp;-n&amp;nbsp;&amp;quot;Starting&amp;nbsp;named:&amp;nbsp;&amp;quot; &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;daemon&amp;nbsp;/opt/named/sbin/named&amp;nbsp;-c&amp;nbsp;/etc/namedb/named.conf.11&amp;nbsp;-u&amp;nbsp;named &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;daemon&amp;nbsp;/opt/named/sbin/named&amp;nbsp;-c&amp;nbsp;/etc/namedb/named.conf.12&amp;nbsp;-u&amp;nbsp;named &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;daemon&amp;nbsp;/opt/named/sbin/named&amp;nbsp;-c&amp;nbsp;/etc/namedb/named.conf.13&amp;nbsp;-u&amp;nbsp;named &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;daemon&amp;nbsp;/opt/named/sbin/named&amp;nbsp;-c&amp;nbsp;/etc/namedb/named.conf.14&amp;nbsp;-u&amp;nbsp;named &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;daemon&amp;nbsp;/opt/named/sbin/named&amp;nbsp;-c&amp;nbsp;/etc/namedb/named.conf.15&amp;nbsp;-u&amp;nbsp;named &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;daemon&amp;nbsp;/opt/named/sbin/named&amp;nbsp;-c&amp;nbsp;/etc/namedb/named.conf.16&amp;nbsp;-u&amp;nbsp;named &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;daemon&amp;nbsp;/opt/named/sbin/named&amp;nbsp;-c&amp;nbsp;/etc/namedb/named.conf.17&amp;nbsp;-u&amp;nbsp;named &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;daemon&amp;nbsp;/opt/named/sbin/named&amp;nbsp;-c&amp;nbsp;/etc/namedb/named.conf.18&amp;nbsp;-u&amp;nbsp;named&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;p&gt;&lt;/p&gt;&lt;h3&gt;4.2.5. named.conf配置&lt;/h3&gt;&lt;p&gt;关键部分如下,替代了原来对每一个zone的配置：&lt;/p&gt;&lt;pre&gt;&lt;ol class=&quot;dp-xml&quot;&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&lt;span&gt;dlz&amp;nbsp;&amp;quot;Mysql&amp;nbsp;zone&amp;quot;&amp;nbsp;{ &amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;database&amp;nbsp;&amp;quot;mysql &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/span&gt;&lt;span class=&quot;attribute&quot;&gt;host&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span class=&quot;attribute-value&quot;&gt;localhost&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;attribute&quot;&gt;dbname&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span class=&quot;attribute-value&quot;&gt;dns&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;attribute&quot;&gt;user&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span class=&quot;attribute-value&quot;&gt;dns&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;attribute&quot;&gt;pass&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span class=&quot;attribute-value&quot;&gt;12345678&lt;/span&gt;&lt;span&gt;} &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;{SELECT&amp;nbsp;zone&amp;nbsp;FROM&amp;nbsp;records&amp;nbsp;WHERE&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;attribute&quot;&gt;zone&lt;/span&gt;&lt;span&gt;&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;attribute-value&quot;&gt;&apos;%zone%&apos;&lt;/span&gt;&lt;span&gt;} &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;{SELECT&amp;nbsp;ttl,&amp;nbsp;type,&amp;nbsp;mx_priority,&amp;nbsp;data &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;FROM&amp;nbsp;records &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;WHERE&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;attribute&quot;&gt;zone&lt;/span&gt;&lt;span&gt;&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;attribute-value&quot;&gt;&apos;%zone%&apos;&lt;/span&gt;&lt;span&gt;&amp;nbsp;AND&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;attribute&quot;&gt;host&lt;/span&gt;&lt;span&gt;&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;attribute-value&quot;&gt;&apos;%record%&apos;&lt;/span&gt;&lt;span&gt;&amp;nbsp;AND&amp;nbsp;type&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;tag&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;tag&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&apos;SOA&apos;&amp;nbsp;AND&amp;nbsp;type&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;tag&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;tag&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&apos;NS&apos;} &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;{SELECT&amp;nbsp;ttl,&amp;nbsp;type,&amp;nbsp;data,&amp;nbsp;primary_ns,&amp;nbsp;resp_contact,&amp;nbsp;serial,&amp;nbsp;refresh,&amp;nbsp;retry,&amp;nbsp;expire,&amp;nbsp;minimum &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;FROM&amp;nbsp;records &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;WHERE&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;attribute&quot;&gt;zone&lt;/span&gt;&lt;span&gt;&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;attribute-value&quot;&gt;&apos;%zone%&apos;&lt;/span&gt;&lt;span&gt;&amp;nbsp;AND&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;attribute&quot;&gt;type&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span class=&quot;attribute-value&quot;&gt;&apos;NS&apos;&lt;/span&gt;&lt;span&gt;} &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;{SELECT&amp;nbsp;ttl,&amp;nbsp;type,&amp;nbsp;host,&amp;nbsp;mx_priority,&amp;nbsp;data,&amp;nbsp;resp_contact,&amp;nbsp;serial,&amp;nbsp;refresh,&amp;nbsp;retry,&amp;nbsp;expire,&amp;nbsp;minimum &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;FROM&amp;nbsp;records &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;WHERE&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;attribute&quot;&gt;zone&lt;/span&gt;&lt;span&gt;&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;attribute-value&quot;&gt;&apos;%zone%&apos;&lt;/span&gt;&lt;span&gt;&amp;nbsp;AND&amp;nbsp;type&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;tag&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;tag&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&apos;NS&apos;}&amp;quot;; &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;};&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;p&gt;&lt;/p&gt;&lt;h1&gt;5. 可扩展性&lt;/h1&gt;&lt;p&gt;该结构的可扩展性非常好，可采用的方式如下：&lt;/p&gt;&lt;ul&gt;&lt;li&gt;在单台服务器上增加named的数量&lt;/li&gt;&lt;li&gt;增加物理服务器，作为新节点添加到负载均衡设备里&lt;/li&gt;&lt;li&gt;增加授权的dns服务器，例如：原授权dns服务器为ns1.test.com,ns2.test.com,我们可将授权dns增加到4台为ns1.test.com,ns2.test.com、ns3.test.com,ns4.test.com，通过在ns3.test.com,ns4.test.com后搭建同样的架构系统，可大大增加系统的查询能力，同时将该架构放置在不同的地理位置，还可以实现dns的灾备、冗余。&lt;/li&gt;&lt;li&gt;如果mysql的压力大，也随时可以扩充mysql的节点。分担mysql的压力。&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;/p&gt;&lt;h1&gt;6. 使用现状&lt;/h1&gt;&lt;blockquote&gt;&lt;p&gt;目前dns上的zone数量为约90万，查询速率为500，系统的load不到1，启动可以在秒级完成，并且已稳定运行近两个月。现在的架构，dns和mysql在同一物理机上，仅仅需要两台服务器，而这个数据量按原来的架构需要18台服务器，同时维护非常不便。&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;注：&lt;/p&gt;&lt;p&gt;&lt;span&gt;&lt;span&gt;1、dns一开始会有启动报错： &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;pre&gt;&lt;ol class=&quot;dp-xml&quot;&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;#service&amp;nbsp;named&amp;nbsp;start &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;Starting&amp;nbsp;named:&amp;nbsp;/opt/named/sbin/named:&amp;nbsp;error&amp;nbsp;while&amp;nbsp;loading&amp;nbsp;shared&amp;nbsp;libraries:&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;p&gt;2、&lt;span style=&quot;color: #ff0000&quot;&gt;libmysqlclient.so.15: cannot open shared object file: No such file or directory&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [FAILED]&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &lt;b&gt;解决办法：&lt;/b&gt;&lt;br /&gt;&amp;nbsp; a、编辑/etc/ld.so.conf 将mysql的lib目录加入&lt;/p&gt;&lt;pre&gt;&lt;ol class=&quot;dp-xml&quot;&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&lt;span&gt;include&amp;nbsp;ld.so.conf.d/*.conf &amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;usr/local/mysql/lib/mysql/&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;p&gt;&amp;nbsp; b、执行ldconfig 命令&lt;/p&gt;&lt;p&gt;3、dns是否关闭递归查询，对该结构的查询效率有一定影响。因为关闭递归会少执行n多sql语句。&lt;/p&gt;</description>
		<guid>http://www.517sou.net/Article/263.aspx</guid>
		<trackback:ping>http://www.517sou.net/Article/263/Trackback.ashx</trackback:ping>
		<comments>http://www.517sou.net/Article/263.aspx#CommentPostAnchor</comments>
		<wfw:commentRss>http://www.517sou.net/Article/263/Feeds.ashx</wfw:commentRss>
	</item>
	<item>
		<link>http://www.517sou.net/Article/261.aspx</link>
		<title>Building Scalable DNS Cluster using LVS</title>
		<author>shanyiwan@live.com()</author>
		<category>DNS技术</category>
		<pubDate>Thu, 24 Sep 2009 01:42:06 GMT</pubDate>
		<description>&lt;h2&gt;&lt;span class=&quot;mw-headline&quot;&gt;Introduction &lt;/span&gt;&lt;/h2&gt;&lt;p&gt;DNS (Domain Name Service) is one of the primary Internet services, which is to map human-friendly domain names to machine-friendly IP address. If there are a lot of people using DNS service (for example, subscribers use ISP&apos;s DNS server), one DNS server might be becoming a bottleneck, and the server might fail.&lt;/p&gt;&lt;p&gt;Scalable DNS cluster can help provide scalability and availability of DNS service.&lt;/p&gt;&lt;p&gt;The Example below is about setting up a cluster for recursive DNS but you can just as well use the same method for authorative DNS as well. Just remember that clients who use your cluster as a secondary nameservice would need to also-notify{} each of your realservers, not just the service-IP. &lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;h2&gt;&lt;span class=&quot;mw-headline&quot;&gt;Architecture &lt;/span&gt;&lt;/h2&gt;&lt;p&gt;DNS is a simple service, there is no affinity between requests from the same client. DNS usually listens for queries at UDP port 53 and TCP port 53.&lt;/p&gt;&lt;p&gt;LVS can simply load balance UDP port 53 and TCP port 53 among a set of DNS servers, and there is no need to setup any persistence options.&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;h2&gt;&lt;span class=&quot;mw-headline&quot;&gt;Configuration Example &lt;/span&gt;&lt;/h2&gt;&lt;p&gt;keepalived.conf:&lt;/p&gt;&lt;pre&gt;&lt;ol class=&quot;dp-xml&quot;&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&lt;span&gt;!&amp;nbsp;Balancer-Set&amp;nbsp;for&amp;nbsp;udp/53 &amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;virtual_server&amp;nbsp;194.97.173.124&amp;nbsp;53&amp;nbsp;{ &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;delay_loop&amp;nbsp;10 &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;lb_algo&amp;nbsp;wrr &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;lb_kind&amp;nbsp;DR &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;protocol&amp;nbsp;UDP &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;!&amp;nbsp;persistence_timeout&amp;nbsp;1 &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;!&amp;nbsp;persistence_granularity&amp;nbsp;255.255.255.255 &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;!&amp;nbsp;eth1.105&amp;nbsp;-&lt;/span&gt;&lt;span class=&quot;tag&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span&gt;&amp;nbsp;kai&amp;nbsp;eth1.105 &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;real_server&amp;nbsp;10.1.53.2&amp;nbsp;53&amp;nbsp;{ &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;weight&amp;nbsp;1 &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;MISC_CHECK&amp;nbsp;{ &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;misc_path&amp;nbsp;&amp;quot;/usr/bin/dig&amp;nbsp;-b&amp;nbsp;10.1.53.1&amp;nbsp;a&amp;nbsp;resolve.test.roka.net&amp;nbsp;@10.1.53.2&amp;nbsp;+&lt;/span&gt;&lt;span class=&quot;attribute&quot;&gt;time&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span class=&quot;attribute-value&quot;&gt;1&lt;/span&gt;&lt;span&gt;&amp;nbsp;+&lt;/span&gt;&lt;span class=&quot;attribute&quot;&gt;tries&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span class=&quot;attribute-value&quot;&gt;5&lt;/span&gt;&lt;span&gt;&amp;nbsp;+fail&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;tag&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span&gt;&amp;nbsp;/dev/null&amp;quot; &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;misc_timeout&amp;nbsp;6 &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;!&amp;nbsp;eth1.109&amp;nbsp;-&lt;/span&gt;&lt;span class=&quot;tag&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span&gt;&amp;nbsp;kai&amp;nbsp;eth1.109 &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;real_server&amp;nbsp;10.3.53.2&amp;nbsp;53&amp;nbsp;{ &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;weight&amp;nbsp;1 &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;MISC_CHECK&amp;nbsp;{ &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;misc_path&amp;nbsp;&amp;quot;/usr/bin/dig&amp;nbsp;-b&amp;nbsp;10.3.53.1&amp;nbsp;a&amp;nbsp;resolve.test.roka.net&amp;nbsp;@10.3.53.2&amp;nbsp;+&lt;/span&gt;&lt;span class=&quot;attribute&quot;&gt;time&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span class=&quot;attribute-value&quot;&gt;1&lt;/span&gt;&lt;span&gt;&amp;nbsp;+&lt;/span&gt;&lt;span class=&quot;attribute&quot;&gt;tries&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span class=&quot;attribute-value&quot;&gt;5&lt;/span&gt;&lt;span&gt;&amp;nbsp;+fail&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;tag&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span&gt;&amp;nbsp;/dev/null&amp;quot; &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;misc_timeout&amp;nbsp;6 &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;}&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;p&gt;As you can dig (;-) we are using an A record with a low TTL to test the service for this setup is a recursive DNS cluster. So far dig works fine with 44 real_servers configured on an idle Dual PIII 800.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;on real_server kai we use the following netfilter setup to be able to direct the traffic to different BIND processes on the same machine/mac:&lt;/p&gt;&lt;pre&gt;&lt;ol class=&quot;dp-xml&quot;&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&lt;span&gt;#DNAT&amp;nbsp;194.97.173.124-&lt;/span&gt;&lt;span class=&quot;tag&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span&gt;10.1.53.2&amp;nbsp;eth1.105 &amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;iptables&amp;nbsp;-t&amp;nbsp;nat&amp;nbsp;-A&amp;nbsp;PREROUTING&amp;nbsp;-i&amp;nbsp;eth1.105&amp;nbsp;-s&amp;nbsp;$net&amp;nbsp;-d&amp;nbsp;194.97.173.124&amp;nbsp;-p&amp;nbsp;tcp&amp;nbsp;--dport&amp;nbsp;53&amp;nbsp;-j&amp;nbsp;DNAT&amp;nbsp;--to-destination&amp;nbsp;10.1.53.2:53 &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;iptables&amp;nbsp;-t&amp;nbsp;nat&amp;nbsp;-A&amp;nbsp;PREROUTING&amp;nbsp;-i&amp;nbsp;eth1.105&amp;nbsp;-s&amp;nbsp;$net&amp;nbsp;-d&amp;nbsp;194.97.173.124&amp;nbsp;-p&amp;nbsp;udp&amp;nbsp;--dport&amp;nbsp;53&amp;nbsp;-j&amp;nbsp;DNAT&amp;nbsp;--to-destination&amp;nbsp;10.1.53.2:53 &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;#DNAT&amp;nbsp;194.97.173.124-&lt;/span&gt;&lt;span class=&quot;tag&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span&gt;10.3.53.2&amp;nbsp;eth1.109 &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;iptables&amp;nbsp;-t&amp;nbsp;nat&amp;nbsp;-A&amp;nbsp;PREROUTING&amp;nbsp;-i&amp;nbsp;eth1.109&amp;nbsp;-s&amp;nbsp;$net&amp;nbsp;-d&amp;nbsp;194.97.173.124&amp;nbsp;-p&amp;nbsp;tcp&amp;nbsp;--dport&amp;nbsp;53&amp;nbsp;-j&amp;nbsp;DNAT&amp;nbsp;--to-destination&amp;nbsp;10.3.53.2:53 &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;iptables&amp;nbsp;-t&amp;nbsp;nat&amp;nbsp;-A&amp;nbsp;PREROUTING&amp;nbsp;-i&amp;nbsp;eth1.109&amp;nbsp;-s&amp;nbsp;$net&amp;nbsp;-d&amp;nbsp;194.97.173.124&amp;nbsp;-p&amp;nbsp;udp&amp;nbsp;--dport&amp;nbsp;53&amp;nbsp;-j&amp;nbsp;DNAT&amp;nbsp;--to-destination&amp;nbsp;10.3.53.2:53&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;p&gt;&lt;/p&gt;&lt;h3&gt;&lt;span class=&quot;mw-headline&quot;&gt;&lt;a class=&quot;external text&quot; title=&quot;http://www.isc.org/index.pl?/sw/bind/&quot; href=&quot;http://www.isc.org/index.pl?/sw/bind/&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;BIND9&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;&lt;/span&gt;&lt;/h3&gt;&lt;p&gt;When i wrote this example we were using two BIND processes on the same machine for BIND9 currently just runs faster when it is not threading. Here is something JINMEI Tatuya told me on the bind9-workers Mailinglist which turned out to be very true:&lt;/p&gt;&lt;pre&gt;&lt;ol class=&quot;dp-xml&quot;&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&lt;span&gt;If&amp;nbsp;you&amp;nbsp;go&amp;nbsp;with&amp;nbsp;disabling&amp;nbsp;threads,&amp;nbsp;you&amp;nbsp;may&amp;nbsp;also&amp;nbsp;want&amp;nbsp;to&amp;nbsp;enable &amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;quot;internal&amp;nbsp;memory&amp;nbsp;allocation&amp;quot;.&amp;nbsp;&amp;nbsp;(I&amp;nbsp;hear&amp;nbsp;that)&amp;nbsp;it&amp;nbsp;should&amp;nbsp;use&amp;nbsp;memory&amp;nbsp;more &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;efficiently&amp;nbsp;(and&amp;nbsp;can&amp;nbsp;make&amp;nbsp;the&amp;nbsp;server&amp;nbsp;faster)&amp;nbsp;but&amp;nbsp;is&amp;nbsp;disabled&amp;nbsp;by &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;default&amp;nbsp;due&amp;nbsp;to&amp;nbsp;response-performance&amp;nbsp;reasons&amp;nbsp;in&amp;nbsp;the&amp;nbsp;threaded&amp;nbsp;case.&amp;nbsp;&amp;nbsp;You &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;can&amp;nbsp;enable&amp;nbsp;this&amp;nbsp;feature&amp;nbsp;by&amp;nbsp;adding&amp;nbsp;the&amp;nbsp;following&amp;nbsp;line&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;pre&gt;&lt;ol class=&quot;dp-xml&quot;&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&lt;span&gt;#define&amp;nbsp;ISC_MEM_USE_INTERNAL_MALLOC&amp;nbsp;1&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;pre&gt;&lt;ol class=&quot;dp-xml&quot;&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&lt;span&gt;just&amp;nbsp;before&amp;nbsp;the&amp;nbsp;following&amp;nbsp;part&amp;nbsp;of&amp;nbsp;bind9/lib/isc/mem.c:&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;pre&gt;&lt;ol class=&quot;dp-xml&quot;&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&lt;span&gt;#ifndef&amp;nbsp;ISC_MEM_USE_INTERNAL_MALLOC &amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;#define&amp;nbsp;ISC_MEM_USE_INTERNAL_MALLOC&amp;nbsp;0 &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;#endif&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;p&gt;Try it and you will keep it.&amp;nbsp;;)&lt;/p&gt;&lt;p&gt;BIND 9.4 line makes use of this new internal malloc library by default now, but disabling threading will probably free you from the hickups some BIND9 users are experiencing.&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;h3&gt;&lt;span class=&quot;mw-headline&quot;&gt;&lt;a class=&quot;external text&quot; title=&quot;http://doc.powerdns.com/built-in-recursor.html&quot; href=&quot;http://doc.powerdns.com/built-in-recursor.html&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;PowerDNS recursor&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;&lt;/span&gt;&lt;/h3&gt;&lt;p&gt;This one is a recursive-only Nameserver with very limited authorative DNS capabilities. The author of this Example uses &lt;a class=&quot;external text&quot; title=&quot;http://doc.powerdns.com/built-in-recursor.html&quot; href=&quot;http://doc.powerdns.com/built-in-recursor.html&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;PowerDNS recursor&lt;/font&gt;&lt;/u&gt;&lt;/a&gt; exclusively for his caching-only DNS cluster by now and is glad that while giving roughly the same queries per second performance it generates less SERVFAIL answers and is generally several times more robust than BIND9.&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;h3&gt;&lt;span class=&quot;mw-headline&quot;&gt;added redundancy via iBGP &lt;/span&gt;&lt;/h3&gt;&lt;p&gt;If you have more than one Loadbalancer at different locations and you can convince your local Networker to let you speak BGP4+ to his routers you can use quagga with something like the following configuration to failover the service IP to the second LB if the first one goes down:&lt;/p&gt;&lt;pre&gt;&lt;ol class=&quot;dp-xml&quot;&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&lt;span&gt;! &amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;router&amp;nbsp;bgp&amp;nbsp;5430 &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;no&amp;nbsp;synchronization &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;bgp&amp;nbsp;router-id&amp;nbsp;a.b.c.d &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;redistribute&amp;nbsp;connected&amp;nbsp;route-map&amp;nbsp;benice &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;neighbor&amp;nbsp;c.d.e.f&amp;nbsp;remote-as&amp;nbsp;5430 &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;neighbor&amp;nbsp;c.d.e.f&amp;nbsp;description&amp;nbsp;ffm4-j2 &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;neighbor&amp;nbsp;c.d.e.f&amp;nbsp;send-community&amp;nbsp;both &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;neighbor&amp;nbsp;c.d.e.f&amp;nbsp;soft-reconfiguration&amp;nbsp;inbound &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;neighbor&amp;nbsp;c.d.e.f&amp;nbsp;route-map&amp;nbsp;nixda&amp;nbsp;in &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;neighbor&amp;nbsp;c.d.e.f&amp;nbsp;route-map&amp;nbsp;benice&amp;nbsp;out &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;neighbor&amp;nbsp;d.c.f.e&amp;nbsp;remote-as&amp;nbsp;5430 &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;neighbor&amp;nbsp;d.c.f.e&amp;nbsp;description&amp;nbsp;ffm4-j &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;neighbor&amp;nbsp;d.c.f.e&amp;nbsp;send-community&amp;nbsp;both &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;neighbor&amp;nbsp;d.c.f.e&amp;nbsp;soft-reconfiguration&amp;nbsp;inbound &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;neighbor&amp;nbsp;d.c.f.e&amp;nbsp;route-map&amp;nbsp;nixda&amp;nbsp;in &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;neighbor&amp;nbsp;d.c.f.e&amp;nbsp;route-map&amp;nbsp;benice&amp;nbsp;out &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;no&amp;nbsp;auto-summary &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;! &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;access-list&amp;nbsp;line&amp;nbsp;permit&amp;nbsp;127.0.0.1/32&amp;nbsp;exact-match &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;access-list&amp;nbsp;line&amp;nbsp;deny&amp;nbsp;any &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;! &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;ip&amp;nbsp;prefix-list&amp;nbsp;cns-dus2&amp;nbsp;description&amp;nbsp;dus2&amp;nbsp;high-metric&amp;nbsp;eq&amp;nbsp;low-perference &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;ip&amp;nbsp;prefix-list&amp;nbsp;cns-dus2&amp;nbsp;seq&amp;nbsp;5&amp;nbsp;permit&amp;nbsp;194.97.173.125/32 &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;ip&amp;nbsp;prefix-list&amp;nbsp;cns-dus2&amp;nbsp;seq&amp;nbsp;10&amp;nbsp;deny&amp;nbsp;any &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;ip&amp;nbsp;prefix-list&amp;nbsp;cns-ffm4&amp;nbsp;description&amp;nbsp;ffm4&amp;nbsp;low-metric&amp;nbsp;eq&amp;nbsp;high-preference &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;ip&amp;nbsp;prefix-list&amp;nbsp;cns-ffm4&amp;nbsp;seq&amp;nbsp;5&amp;nbsp;permit&amp;nbsp;194.97.173.124/32 &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;ip&amp;nbsp;prefix-list&amp;nbsp;cns-ffm4&amp;nbsp;seq&amp;nbsp;10&amp;nbsp;deny&amp;nbsp;any &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;! &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;route-map&amp;nbsp;benice&amp;nbsp;permit&amp;nbsp;10 &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;match&amp;nbsp;ip&amp;nbsp;address&amp;nbsp;prefix-list&amp;nbsp;cns-ffm4 &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;set&amp;nbsp;local-preference&amp;nbsp;100 &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;set&amp;nbsp;metric&amp;nbsp;0 &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;! &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;route-map&amp;nbsp;benice&amp;nbsp;permit&amp;nbsp;20 &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;match&amp;nbsp;ip&amp;nbsp;address&amp;nbsp;prefix-list&amp;nbsp;cns-dus2 &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;set&amp;nbsp;local-preference&amp;nbsp;100 &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;set&amp;nbsp;metric&amp;nbsp;1 &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;! &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;route-map&amp;nbsp;nixda&amp;nbsp;deny&amp;nbsp;10 &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;!&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;p&gt;This is the LB at FFM4. Note that the metric at the DUS2 LB is just the other way around. Here we fancy talking to two core-routers from each LB for extra redundancy. You can also have an internal anycast ServiceIP if you use the same metric at both LBs and make sure they are attached to the same level of router network-topology-wise. This way traffic gets shared between the two loadbalancers according to your network-topology most interesting of course for large dialin ISPs.&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;h3&gt;&lt;span class=&quot;mw-headline&quot;&gt;Problem &lt;/span&gt;&lt;/h3&gt;&lt;p&gt;dig does not return a non-zero error code when receiving a SERVFAIL but there are situations when some BIND9 versions return SERVFAIL for any query for example when they are out of memory. For a recursive DNS cluster situation we would want to take such BIND processes out of service.&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;h4&gt;&lt;span class=&quot;mw-headline&quot;&gt;Workaround &lt;/span&gt;&lt;/h4&gt;&lt;p&gt;use the following perl script as a wrapper for dig which is quite ugly for perl is an interpretated language and forking it is not much fun so this consumes much user cpu when executed every 6 seconds.&lt;/p&gt;&lt;pre&gt;&lt;ol class=&quot;dp-c&quot;&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&lt;span&gt;#!/usr/bin/perl &amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class=&quot;keyword&quot;&gt;use&lt;/span&gt;&lt;span&gt;&amp;nbsp;strict; &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span class=&quot;keyword&quot;&gt;use&lt;/span&gt;&lt;span&gt;&amp;nbsp;warnings; &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;#&amp;nbsp;cmdline&amp;nbsp;arguments:&amp;nbsp;&amp;lt;FromIP&amp;gt;&amp;nbsp;&amp;lt;Class&amp;gt;&amp;nbsp;&amp;lt;QTYPE&amp;gt;&amp;nbsp;&amp;lt;QNAME&amp;gt;&amp;nbsp;&amp;lt;ToIP&amp;gt;&amp;nbsp;&amp;lt;Times&amp;gt;&amp;nbsp;&amp;lt;Tries&amp;gt;&amp;nbsp;&amp;lt;ErrrorMatch&amp;gt;&amp;nbsp;&amp;lt;Transport&amp;gt; &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;#&amp;nbsp;/usr/bin/dig&amp;nbsp;-b&amp;nbsp;10.5.53.1&amp;nbsp;IN&amp;nbsp;A&amp;nbsp;2.0.0.127.my.test&amp;nbsp;@10.5.53.2&amp;nbsp;+time=1&amp;nbsp;+tries=5&amp;nbsp;+fail &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class=&quot;keyword&quot;&gt;if&lt;/span&gt;&lt;span&gt;( &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;((defined&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;vars&quot;&gt;$ARGV&lt;/span&gt;&lt;span&gt;[0])&amp;amp;&amp;amp;(&lt;/span&gt;&lt;span class=&quot;vars&quot;&gt;$ARGV&lt;/span&gt;&lt;span&gt;[0]=~/^\d+\.\d+\.\d+\.\d+$/)) &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;amp;&amp;amp;((defined&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;vars&quot;&gt;$ARGV&lt;/span&gt;&lt;span&gt;[1])&amp;amp;&amp;amp;(&lt;/span&gt;&lt;span class=&quot;vars&quot;&gt;$ARGV&lt;/span&gt;&lt;span&gt;[1]=~/^(IN|CHAOS)$/)) &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;amp;&amp;amp;((defined&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;vars&quot;&gt;$ARGV&lt;/span&gt;&lt;span&gt;[2])&amp;amp;&amp;amp;(&lt;/span&gt;&lt;span class=&quot;vars&quot;&gt;$ARGV&lt;/span&gt;&lt;span&gt;[2]=~/^(A|ANY|MX|PTR|SRV|TXT|AAAA|NS|CNAME|SOA)$/)) &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;amp;&amp;amp;((defined&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;vars&quot;&gt;$ARGV&lt;/span&gt;&lt;span&gt;[3])&amp;amp;&amp;amp;(&lt;/span&gt;&lt;span class=&quot;vars&quot;&gt;$ARGV&lt;/span&gt;&lt;span&gt;[3]=~/^[A-Za-z0-9\-\.]+$/)) &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;amp;&amp;amp;((defined&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;vars&quot;&gt;$ARGV&lt;/span&gt;&lt;span&gt;[4])&amp;amp;&amp;amp;(&lt;/span&gt;&lt;span class=&quot;vars&quot;&gt;$ARGV&lt;/span&gt;&lt;span&gt;[4]=~/^\d+\.\d+\.\d+\.\d+$/)) &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;amp;&amp;amp;((defined&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;vars&quot;&gt;$ARGV&lt;/span&gt;&lt;span&gt;[5])&amp;amp;&amp;amp;(&lt;/span&gt;&lt;span class=&quot;vars&quot;&gt;$ARGV&lt;/span&gt;&lt;span&gt;[5]=~/^\d+$/)) &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;amp;&amp;amp;((defined&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;vars&quot;&gt;$ARGV&lt;/span&gt;&lt;span&gt;[6])&amp;amp;&amp;amp;(&lt;/span&gt;&lt;span class=&quot;vars&quot;&gt;$ARGV&lt;/span&gt;&lt;span&gt;[6]=~/^\d+$/)) &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;amp;&amp;amp;((defined&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;vars&quot;&gt;$ARGV&lt;/span&gt;&lt;span&gt;[7])&amp;amp;&amp;amp;(&lt;/span&gt;&lt;span class=&quot;vars&quot;&gt;$ARGV&lt;/span&gt;&lt;span&gt;[7]=~/^\S+$/)) &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;)&amp;nbsp;{ &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;my&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;vars&quot;&gt;$transport&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;&amp;quot;notcp&amp;quot;&lt;/span&gt;&lt;span&gt;; &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;keyword&quot;&gt;if&lt;/span&gt;&lt;span&gt;((defined&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;vars&quot;&gt;$ARGV&lt;/span&gt;&lt;span&gt;[8])&amp;amp;&amp;amp;(&lt;/span&gt;&lt;span class=&quot;vars&quot;&gt;$ARGV&lt;/span&gt;&lt;span&gt;[8]=~/^tcp$/i))&amp;nbsp;{ &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;vars&quot;&gt;$transport&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;&amp;quot;tcp&amp;quot;&lt;/span&gt;&lt;span&gt;; &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&amp;nbsp;elsif&amp;nbsp;((defined&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;vars&quot;&gt;$ARGV&lt;/span&gt;&lt;span&gt;[8])&amp;amp;&amp;amp;(&lt;/span&gt;&lt;span class=&quot;vars&quot;&gt;$ARGV&lt;/span&gt;&lt;span&gt;[8]=~/^udp$/i))&amp;nbsp;{ &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;vars&quot;&gt;$transport&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;&amp;quot;notcp&amp;quot;&lt;/span&gt;&lt;span&gt;; &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;my&amp;nbsp;(@res)=`/usr/bin/dig&amp;nbsp;-b&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;vars&quot;&gt;$ARGV&lt;/span&gt;&lt;span&gt;[0]&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;vars&quot;&gt;$ARGV&lt;/span&gt;&lt;span&gt;[1]&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;vars&quot;&gt;$ARGV&lt;/span&gt;&lt;span&gt;[2]&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;vars&quot;&gt;$ARGV&lt;/span&gt;&lt;span&gt;[3]&amp;nbsp;\@&lt;/span&gt;&lt;span class=&quot;vars&quot;&gt;$ARGV&lt;/span&gt;&lt;span&gt;[4]&amp;nbsp;+time=&lt;/span&gt;&lt;span class=&quot;vars&quot;&gt;$ARGV&lt;/span&gt;&lt;span&gt;[5]&amp;nbsp;+tries=&lt;/span&gt;&lt;span class=&quot;vars&quot;&gt;$ARGV&lt;/span&gt;&lt;span&gt;[6]&amp;nbsp;+fail&amp;nbsp;+&lt;/span&gt;&lt;span class=&quot;vars&quot;&gt;$transport&lt;/span&gt;&lt;span&gt;&amp;nbsp;2&amp;gt;&amp;amp;1`; &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;my&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;vars&quot;&gt;$return&lt;/span&gt;&lt;span&gt;=$?; &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;keyword&quot;&gt;if&lt;/span&gt;&lt;span&gt;(my&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;vars&quot;&gt;$error&lt;/span&gt;&lt;span&gt;=(map&amp;nbsp;{/status:\s*(&lt;/span&gt;&lt;span class=&quot;vars&quot;&gt;$ARGV&lt;/span&gt;&lt;span&gt;[7])/&amp;nbsp;?&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;vars&quot;&gt;$1&lt;/span&gt;&lt;span&gt;&amp;nbsp;:&amp;nbsp;()}&amp;nbsp;@res)[0])&amp;nbsp;{ &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;keyword&quot;&gt;die&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;&amp;quot;$error&amp;quot;&lt;/span&gt;&lt;span&gt;); &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&amp;nbsp;elsif&amp;nbsp;(&lt;/span&gt;&lt;span class=&quot;vars&quot;&gt;$return&lt;/span&gt;&lt;span&gt;!=0)&amp;nbsp;{ &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;keyword&quot;&gt;die&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;&amp;quot;dig&amp;nbsp;returned:&amp;nbsp;\&amp;quot;$return\&amp;quot;&amp;quot;&lt;/span&gt;&lt;span&gt;); &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&amp;nbsp;elsif&amp;nbsp;(&lt;/span&gt;&lt;span class=&quot;vars&quot;&gt;$return&lt;/span&gt;&lt;span&gt;==0)&amp;nbsp;{ &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;func&quot;&gt;exit&lt;/span&gt;&lt;span&gt;&amp;nbsp;0; &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;keyword&quot;&gt;else&lt;/span&gt;&lt;span&gt;&amp;nbsp;{ &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;keyword&quot;&gt;die&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;&amp;quot;error:&amp;nbsp;\&amp;quot;$return\&amp;quot;&amp;nbsp;HAS&amp;nbsp;BAD&amp;nbsp;VALUE!&amp;quot;&lt;/span&gt;&lt;span&gt;); &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;}&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;keyword&quot;&gt;else&lt;/span&gt;&lt;span&gt;&amp;nbsp;{ &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;keyword&quot;&gt;die&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;&amp;quot;dig-wrapper.pl&amp;nbsp;&amp;lt;FromIP&amp;gt;&amp;nbsp;&amp;lt;Class&amp;gt;&amp;nbsp;&amp;lt;QTYPE&amp;gt;&amp;nbsp;&amp;lt;QNAME&amp;gt;&amp;nbsp;&amp;lt;ToIP&amp;gt;&amp;nbsp;&amp;lt;Times&amp;gt;&amp;nbsp;&amp;lt;Tries&amp;gt;&amp;nbsp;&amp;lt;ErrrorMatch&amp;gt;&amp;nbsp;&amp;lt;Transport&amp;gt;&amp;quot;&lt;/span&gt;&lt;span&gt;); &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;}&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;p&gt;Ah yes, forgot to say: The Dual PIII 800 is not idleing around anymore - its busy running this script 44 times every 6 seconds, which accounts for roughly 12% user cpu and 5% system used at a query rate of ~3600q/s.&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;h4&gt;&lt;span class=&quot;mw-headline&quot;&gt;Solution &lt;/span&gt;&lt;/h4&gt;&lt;p&gt;use a patched version of dig?&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;h2&gt;&lt;span class=&quot;mw-headline&quot;&gt;Conclusion &lt;/span&gt;&lt;/h2&gt;&lt;p&gt;It still just works.&lt;/p&gt;&lt;p&gt;&lt;b&gt;From&lt;br /&gt;&lt;/b&gt;&lt;a href=&quot;http://kb.linuxvirtualserver.org/wiki/Building_Scalable_DNS_Cluster_using_LVS&quot; target=&quot;_blank&quot;&gt;http://kb.linuxvirtualserver.org/wiki/Building_Scalable_DNS_Cluster_using_LVS&lt;/a&gt;&lt;/p&gt;</description>
		<guid>http://www.517sou.net/Article/261.aspx</guid>
		<trackback:ping>http://www.517sou.net/Article/261/Trackback.ashx</trackback:ping>
		<comments>http://www.517sou.net/Article/261.aspx#CommentPostAnchor</comments>
		<wfw:commentRss>http://www.517sou.net/Article/261/Feeds.ashx</wfw:commentRss>
	</item>
	<item>
		<link>http://www.517sou.net/Article/220.aspx</link>
		<title>chroot DNS无法写日志到/var/log/messages解决办法</title>
		<author>shanyiwan@live.com()</author>
		<category>DNS技术</category>
		<pubDate>Tue, 01 Sep 2009 03:40:09 GMT</pubDate>
		<description>&lt;p&gt;通常情况下，进程通过“/dev/log”向syslogd发送消息。由于“虚拟”根环境的限制，这种通信被禁止。因此syslogd需要改为监听“/var/named/chroot/dev/log”。可以通过编辑syslog的启动脚本来设定新的监听地点。&lt;br /&gt;编辑syslog脚本（vi +24 /etc/rc.d/init.d/syslog），改变&lt;span class=&quot;attribute&quot;&gt;&lt;font color=&quot;#ff0000&quot;&gt;SYSLOGD_OPTIONS &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;pre&gt;&lt;ol class=&quot;dp-xml&quot;&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&lt;span&gt;[root@ns8&amp;nbsp;log]#&amp;nbsp;cat&amp;nbsp;/etc/rc.d/init.d/syslog&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;#!/bin/bash &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;# &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;#&amp;nbsp;syslog&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Starts&amp;nbsp;syslogd/klogd. &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;# &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;# &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;#&amp;nbsp;chkconfig:&amp;nbsp;2345&amp;nbsp;12&amp;nbsp;88 &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;#&amp;nbsp;description:&amp;nbsp;Syslog&amp;nbsp;is&amp;nbsp;the&amp;nbsp;facility&amp;nbsp;by&amp;nbsp;which&amp;nbsp;many&amp;nbsp;daemons&amp;nbsp;use&amp;nbsp;to&amp;nbsp;log&amp;nbsp;\ &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;#&amp;nbsp;messages&amp;nbsp;to&amp;nbsp;various&amp;nbsp;system&amp;nbsp;log&amp;nbsp;files.&amp;nbsp;&amp;nbsp;It&amp;nbsp;is&amp;nbsp;a&amp;nbsp;good&amp;nbsp;idea&amp;nbsp;to&amp;nbsp;always&amp;nbsp;\ &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;#&amp;nbsp;run&amp;nbsp;syslog. &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;###&amp;nbsp;BEGIN&amp;nbsp;INIT&amp;nbsp;INFO &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;#&amp;nbsp;Provides:&amp;nbsp;$syslog &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;###&amp;nbsp;END&amp;nbsp;INIT&amp;nbsp;INFO &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;#&amp;nbsp;Source&amp;nbsp;function&amp;nbsp;library. &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;.&amp;nbsp;/etc/init.d/functions &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;[&amp;nbsp;-f&amp;nbsp;/sbin/syslogd&amp;nbsp;]&amp;nbsp;||&amp;nbsp;exit&amp;nbsp;0 &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;[&amp;nbsp;-f&amp;nbsp;/sbin/klogd&amp;nbsp;]&amp;nbsp;||&amp;nbsp;exit&amp;nbsp;0 &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;#&amp;nbsp;Source&amp;nbsp;config &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;if&amp;nbsp;[&amp;nbsp;-f&amp;nbsp;/etc/sysconfig/syslog&amp;nbsp;]&amp;nbsp;;&amp;nbsp;then &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.&amp;nbsp;/etc/sysconfig/syslog &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;else &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;#&lt;/span&gt;&lt;span class=&quot;attribute&quot;&gt;SYSLOGD_OPTIONS&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span class=&quot;attribute-value&quot;&gt;&amp;quot;-m&amp;nbsp;0&amp;quot;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;attribute&quot;&gt;SYSLOGD_OPTIONS&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span class=&quot;attribute-value&quot;&gt;&amp;quot;-m 0 -a /var/named/chroot/dev/log&amp;quot;&lt;/span&gt;&lt;span&gt;&amp;nbsp;#&lt;/span&gt;&lt;span style=&quot;color: #ff0000&quot;&gt;&lt;span&gt;修改此处&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;attribute&quot;&gt;KLOGD_OPTIONS&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span class=&quot;attribute-value&quot;&gt;&amp;quot;-2&amp;quot;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;fi &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;...&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;pre&gt;&lt;ol class=&quot;dp-xml&quot;&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&lt;span&gt;[root@ns8&amp;nbsp;log]#&amp;nbsp;vi&amp;nbsp;/etc/sysconfig/syslog&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;#&amp;nbsp;Options&amp;nbsp;to&amp;nbsp;syslogd &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;#&amp;nbsp;-m&amp;nbsp;0&amp;nbsp;disables&amp;nbsp;&apos;MARK&apos;&amp;nbsp;messages. &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;#&amp;nbsp;-r&amp;nbsp;enables&amp;nbsp;logging&amp;nbsp;from&amp;nbsp;remote&amp;nbsp;machines &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;#&amp;nbsp;-x&amp;nbsp;disables&amp;nbsp;DNS&amp;nbsp;lookups&amp;nbsp;on&amp;nbsp;messages&amp;nbsp;recieved&amp;nbsp;with&amp;nbsp;-r &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;#&amp;nbsp;See&amp;nbsp;syslogd(8)&amp;nbsp;for&amp;nbsp;more&amp;nbsp;details &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;#&lt;/span&gt;&lt;span class=&quot;attribute&quot;&gt;SYSLOGD_OPTIONS&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span class=&quot;attribute-value&quot;&gt;&amp;quot;-m&amp;nbsp;0&amp;quot;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span class=&quot;attribute&quot;&gt;SYSLOGD_OPTIONS&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span class=&quot;attribute-value&quot;&gt;&amp;quot;-m&amp;nbsp;0&amp;nbsp;-a&amp;nbsp;/var/named/chroot/dev/log&amp;quot;&lt;/span&gt;&lt;span&gt;&amp;nbsp;#修改此处&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;#&amp;nbsp;Options&amp;nbsp;to&amp;nbsp;klogd &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;#&amp;nbsp;-2&amp;nbsp;prints&amp;nbsp;all&amp;nbsp;kernel&amp;nbsp;oops&amp;nbsp;messages&amp;nbsp;twice;&amp;nbsp;once&amp;nbsp;for&amp;nbsp;klogd&amp;nbsp;to&amp;nbsp;decode,&amp;nbsp;and &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;#&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;once&amp;nbsp;for&amp;nbsp;processing&amp;nbsp;with&amp;nbsp;&apos;ksymoops&apos; &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;#&amp;nbsp;-x&amp;nbsp;disables&amp;nbsp;all&amp;nbsp;klogd&amp;nbsp;processing&amp;nbsp;of&amp;nbsp;oops&amp;nbsp;messages&amp;nbsp;entirely &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;#&amp;nbsp;See&amp;nbsp;klogd(8)&amp;nbsp;for&amp;nbsp;more&amp;nbsp;details &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span class=&quot;attribute&quot;&gt;KLOGD_OPTIONS&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span class=&quot;attribute-value&quot;&gt;&amp;quot;-x&amp;quot;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;</description>
		<guid>http://www.517sou.net/Article/220.aspx</guid>
		<trackback:ping>http://www.517sou.net/Article/220/Trackback.ashx</trackback:ping>
		<comments>http://www.517sou.net/Article/220.aspx#CommentPostAnchor</comments>
		<wfw:commentRss>http://www.517sou.net/Article/220/Feeds.ashx</wfw:commentRss>
	</item>
</channel>
</rss>
