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

<channel>
	<title>thinking sysadmin &#187; bind</title>
	<atom:link href="http://andyleonard.com/tag/bind/feed/" rel="self" type="application/rss+xml" />
	<link>http://andyleonard.com</link>
	<description>qstat -u aleonard -s z</description>
	<lastBuildDate>Sun, 22 Jan 2012 03:46:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Git-driven BIND (plus Fabric)</title>
		<link>http://andyleonard.com/2011/12/28/git-driven-bind-plus-fabric/</link>
		<comments>http://andyleonard.com/2011/12/28/git-driven-bind-plus-fabric/#comments</comments>
		<pubDate>Thu, 29 Dec 2011 03:46:23 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[dns]]></category>
		<category><![CDATA[bind]]></category>
		<category><![CDATA[fabric]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[hook]]></category>
		<category><![CDATA[post-receive]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://andyleonard.com/?p=718</guid>
		<description><![CDATA[Step 0. Store your DNS configuration in Git. If you aren&#8217;t using some sort of version control system for your zone files and other BIND configuration, you ought to be. May I recommend Git? Put your entire configuration directory in there, but do read the &#8220;Downsides&#8221; section below for some important security considerations. Step 1. [...]]]></description>
			<content:encoded><![CDATA[<p>Step 0. <strong>Store your DNS configuration in Git.</strong>  If you aren&#8217;t using some sort of version control system for your zone files and other BIND configuration, you ought to be.  May I recommend <a href="http://git-scm.com/">Git</a>?  Put your entire configuration directory in there, but do read the &#8220;Downsides&#8221; section below for some important security considerations.</p>
<p>Step 1. <strong>Create a bare Git repository on your DNS server.</strong>  Using <a href="http://fabfile.org/">Fabric</a>, you&#8217;d do it something like this:</p>
<pre class="brush: python; light: true; title: ; notranslate">
def config_git():

    # Create bare git repo for direct DNS data pushes:
    sudo('/bin/mkdir /srv/bind.git')
    sudo('/bin/chown ubuntu:ubuntu /srv/bind.git')
    with cd('/srv/bind.git'):
        run('/usr/bin/git init --bare .')
    git_post_receive()
</pre>
<p>(The above assumes an Ubuntu system, where the &#8220;ubuntu&#8221; user has sudo privileges, such as on EC2; adjust to your environment as needed.)<br />
<span id="more-718"></span><br />
Step 2. <strong>Add a post-receive hook.</strong>  Notice that &#8220;git_post_receive()&#8221; in the fabfile snippet above?  That function is nothing more than something like this:</p>
<pre class="brush: python; light: true; title: ; notranslate">
def git_post_receive():
    put('git/post-receive', '/srv/bind.git/hooks/post-receive', mode=0755)
</pre>
<p>&#8220;git/post-receive&#8221; &#8211; which is, not surprisingly, a <a href="http://progit.org/book/ch7-3.html">post-receive Git hook</a> &#8211; is in turn something like this:</p>
<pre class="brush: plain; light: true; title: ; notranslate">
#!/bin/sh
sudo GIT_WORK_TREE=/etc/bind /usr/bin/git checkout -f
sudo chmod 0440 /etc/bind/rndc.key
</pre>
<p>(Again, assuming an Ubuntu environment, where BIND lives in /etc/bind.)</p>
<p>Step 3. <strong>Add some orchestration.</strong>  You could tack on an automatic DNS reload to your post-receive hook, but you may prefer to separate control of BIND into distinct functions in your fabfile, perhaps with some tests run before applying changes:</p>
<pre class="brush: python; light: true; title: ; notranslate">
def test():
    test_zones()
    test_conf()

def test_conf():
    run('/usr/sbin/named-checkconf')

def test_zones():
    with cd('/etc/bind'):
        run('for db in db.*; do zone=`/bin/grep SOA $db | /usr/bin/awk \'{ print $1 }\'`; echo ${zone}: $db; /usr/sbin/named-checkzone $zone $db; done')

def reload_bind():
    sudo('/usr/sbin/service bind9 reload')

def restart_bind():
    sudo('/usr/sbin/service bind9 restart')
</pre>
<p><strong>Downsides.</strong>  Note that you&#8217;re putting your rndc.key file (used to secure rndc) into Git if you put <em>all</em> your config files into your repository.  In that case, you&#8217;ll obviously want to restrict access to the repository.</p>
<p>Of course, it isn&#8217;t hard to imagine an adaptation of this system where the rndc.key file is not stored in Git, but is perhaps put in place by the post-receive hook.  (Call this an &#8220;exercise for the reader.&#8221;)</p>
<p><strong>Alternatives.</strong> If you are using DNSSEC, a tool like <a href="http://www-uxsup.csx.cam.ac.uk/~fanf2/hermes/conf/bind/bin/nsdiff">nsdiff</a> might be a better fit to manage updates to your zones.</p>
]]></content:encoded>
			<wfw:commentRss>http://andyleonard.com/2011/12/28/git-driven-bind-plus-fabric/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My small contribution to the update-your-DNS-server panic</title>
		<link>http://andyleonard.com/2008/07/14/my-small-contribution-to-the-update-your-dns-server-panic/</link>
		<comments>http://andyleonard.com/2008/07/14/my-small-contribution-to-the-update-your-dns-server-panic/#comments</comments>
		<pubDate>Mon, 14 Jul 2008 18:47:25 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[security]]></category>
		<category><![CDATA[bind]]></category>

		<guid isPermaLink="false">http://andyleonard.com/?p=47</guid>
		<description><![CDATA[How to find the version of BIND that you&#8217;re running: &#62; dig @localhost version.bind txt chaos ; &#60;&#60;&#62;&#62; DiG 9.3.2 &#60;&#60;&#62;&#62; @localhost version.bind txt chaos ; (2 servers found) ;; global options: printcmd ;; Got answer: ;; -&#62;&#62;HEADER&#60;&#60;- opcode: QUERY, status: NOERROR, id: 7775 ;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 1, [...]]]></description>
			<content:encoded><![CDATA[<p>How to find the version of BIND that you&#8217;re running:</p>
<p><code>&gt; dig @localhost version.bind txt chaos</code></p>
<p><code>; &lt;&lt;&gt;&gt; DiG 9.3.2  &lt;&lt;&gt;&gt; @localhost version.bind txt chaos<br />
; (2 servers found)<br />
;; global options:  printcmd<br />
;; Got answer:<br />
;; -&gt;&gt;HEADER&lt;&lt;- opcode: QUERY, status: NOERROR, id: 7775<br />
;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 0</code></p>
<p><code>;; QUESTION SECTION:<br />
;version.bind.                  CH      TXT</code></p>
<p><code>;; ANSWER SECTION:<br />
version.bind.           0       CH      TXT     "9.3.5-P1"</code></p>
<p><code>;; AUTHORITY SECTION:<br />
version.bind.           0       CH      NS      version.bind.</code></p>
<p><code>;; Query time: 57 msec<br />
;; SERVER: 127.0.0.1#53(127.0.0.1)<br />
;; WHEN: Mon Jul 14 11:45:14 2008<br />
;; MSG SIZE  rcvd: 65</code></p>
]]></content:encoded>
			<wfw:commentRss>http://andyleonard.com/2008/07/14/my-small-contribution-to-the-update-your-dns-server-panic/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

