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

<channel>
	<title>bind &#8211; Farlock.org</title>
	<atom:link href="https://www.farlock.org/tag/bind/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.farlock.org</link>
	<description>What you want to hack today?</description>
	<lastBuildDate>Fri, 28 Apr 2017 13:47:53 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.9.3</generator>
	<item>
		<title>Automatically clone zone from a bind master</title>
		<link>https://www.farlock.org/linux/automatically-clone-zone-from-a-bind-master/</link>
					<comments>https://www.farlock.org/linux/automatically-clone-zone-from-a-bind-master/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Fri, 28 Apr 2017 13:46:40 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[bind]]></category>
		<category><![CDATA[bind replica]]></category>
		<category><![CDATA[master]]></category>
		<category><![CDATA[slave]]></category>
		<guid isPermaLink="false">http://www.farlock.org/?p=289</guid>

					<description><![CDATA[<p>My situation, ns1 and ns2, master and slave. On ns1 I&#8217;ve installed smbind to simply manage my zones.</p> <p>Now I want that ns2 will be automatically updated with the new zones from ns1 but, unfortunately, I wasn&#8217;t able to find anything ready on internet.</p> <p>At the end I wrote a simple script that simply connect [...]]]></description>
										<content:encoded><![CDATA[<p>My situation, ns1 and ns2, master and slave. On ns1 I&#8217;ve installed smbind to simply manage my zones.</p>
<p>Now I want that ns2 will be automatically updated with the new zones from ns1 but, unfortunately, I wasn&#8217;t able to find anything ready on internet.</p>
<p>At the end I wrote a simple script that simply connect to the first machine via ssh, take the bind file with zones, and, if anything changed, adapt it for the slave server, copy in the bind directory and reload bind.</p>
<p>Obviously it needs to be adapted to your needs, I run it every hour.</p>
<blockquote><p>#!/bin/bash</p>
<p>VERSION=&#8221;0.1&#8243;</p>
<p># bind_auto_slave<br />
# Author:  info@farlock.org<br />
#<br />
# Description: copy bind file from master server, edit it and reload bind on slave<br />
#<br />
# ChangeLog: 0.1 &#8211; 28/04/17 &#8211; First Release</p>
<p>MASTER_SERVER=&#8221;ns1.xxx.com&#8221;<br />
MASTER_SERVER_PORT=&#8221;22&#8243;<br />
MASTER_SERVER_USER=&#8221;root&#8221;<br />
MASTER_FILE=&#8221;/etc/smbind/smbind.conf&#8221;</p>
<p>SLAVE_FILE=&#8221;/etc/bind/ns1.conf&#8221;<br />
SED_ARGUMENT=&#8221;s/master;/slave;\n\t\t\tmasters { servers_name; };/&#8221; # Argument that must be passed to sed</p>
<p>#SED_ARGUMENT=&#8221;s/master;/slave;/&#8221;</p>
<p># First of all download file from master<br />
TMP_FILE=$(mktemp)<br />
chmod g+r,o+r $TMP_FILE<br />
scp -q -P $MASTER_SERVER_PORT $MASTER_SERVER:$MASTER_FILE $TMP_FILE<br />
if [ $? -ne 0 ] ; then<br />
echo &#8220;Error downloading file from $MASTER_SERVER&#8221;<br />
exit 11<br />
fi</p>
<p># Execute sed on it<br />
#echo sed $SED_ARGUMENT $TMP_FILE<br />
sed -i &#8220;$SED_ARGUMENT&#8221; $TMP_FILE<br />
if [ $? -ne 0 ] ; then<br />
echo &#8220;Error executing sed on file $TMP_FILE&#8221;<br />
exit 12<br />
fi</p>
<p># Check differences<br />
diff -q $TMP_FILE $SLAVE_FILE &gt; /dev/null<br />
if [ $? -ne 0 ] ; then # files differ<br />
mv $TMP_FILE $SLAVE_FILE<br />
service bind9 reload<br />
if [ $? -ne 0 ] ; then<br />
echo &#8220;Error reloading bind9 on slave server&#8221;<br />
exit 13<br />
fi<br />
else<br />
rm $TMP_FILE<br />
fi</p>
<p>exit 0</p></blockquote>
<p>&nbsp;</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.farlock.org/linux/automatically-clone-zone-from-a-bind-master/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
