<?xml version="1.0" encoding="utf-8" ?>

<?xml-stylesheet type="text/xsl" href="/templates/2k11/rss.xsl" media="screen" ?>
<rss version="2.0" 
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:admin="http://webns.net/mvcb/"
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
   xmlns:wfw="http://wellformedweb.org/CommentAPI/"
   xmlns:content="http://purl.org/rss/1.0/modules/content/"
   >
<channel>
    
    <title>Daniel Lange's blog (Entries tagged as bind)</title>
    <link>http://daniel-lange.com/</link>
    <description>agrep -pB IT /dev/life</description>
    <dc:language>en</dc:language>
    <generator>Serendipity 2.6.0 - http://www.s9y.org/</generator>
    <pubDate>Mon, 14 Oct 2013 14:55:44 GMT</pubDate>

    <image>
    <url>//daniel-lange.com/uploads/Avatar_Blog_144_234.png</url>
    <title>RSS: Daniel Lange's blog - agrep -pB IT /dev/life</title>
    <link>http://daniel-lange.com/</link>
    <width>144</width>
    <height>234</height>
</image>

<item>
    <title>Replicating BIND DNS slave configurations from BIND DNS master servers</title>
    <link>http://daniel-lange.com/archives/76-Replicating-BIND-DNS-slave-configurations-from-BIND-DNS-master-servers.html</link>
            <category>Internet</category>
    
    <comments>http://daniel-lange.com/archives/76-Replicating-BIND-DNS-slave-configurations-from-BIND-DNS-master-servers.html#comments</comments>
    <wfw:comment>http://daniel-lange.com/wfwcomment.php?cid=76</wfw:comment>

    <slash:comments>2</slash:comments>
    <wfw:commentRss>http://daniel-lange.com/rss.php?version=2.0&amp;type=comments&amp;cid=76</wfw:commentRss>
    

    <author>nospam@example.com (Daniel Lange)</author>
    <content:encoded>
    &lt;p&gt;Manually copying the &lt;a href=&quot;https://www.isc.org/software/bind&quot; title=&quot;BIND DNS server homepage&quot;&gt;BIND&lt;/a&gt; master zone configuration to slave servers is a tedious and error-prone process.
There are configuration management systems available for large deployments and BIND can support database backends as well which allow synchronization virtually behind the scenes.&lt;/p&gt;

&lt;p&gt;For my use these options are overly complex and have unwanted risks associated with it.&lt;/p&gt;

&lt;p&gt;The better option is to automate generating the BIND slave configuration from the BIND master  &lt;code&gt;named.conf.local&lt;/code&gt;.&lt;/p&gt;
 &lt;a class=&quot;block_level&quot; href=&quot;http://daniel-lange.com/archives/76-Replicating-BIND-DNS-slave-configurations-from-BIND-DNS-master-servers.html#extended&quot;&gt;Continue reading &quot;Replicating BIND DNS slave configurations from BIND DNS master servers&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Wed, 23 Jan 2013 17:00:00 +0000</pubDate>
    <guid isPermaLink="false">http://daniel-lange.com/archives/76-guid.html</guid>
    <category>awk</category>
<category>bind</category>
<category>config</category>
<category>convert</category>
<category>dns</category>
<category>isc</category>
<category>named</category>

</item>
<item>
    <title>Binding applications to a specific IP</title>
    <link>http://daniel-lange.com/archives/53-Binding-applications-to-a-specific-IP.html</link>
            <category>Linux</category>
    
    <comments>http://daniel-lange.com/archives/53-Binding-applications-to-a-specific-IP.html#comments</comments>
    <wfw:comment>http://daniel-lange.com/wfwcomment.php?cid=53</wfw:comment>

    <slash:comments>22</slash:comments>
    <wfw:commentRss>http://daniel-lange.com/rss.php?version=2.0&amp;type=comments&amp;cid=53</wfw:commentRss>
    

    <author>nospam@example.com (Daniel Lange)</author>
    <content:encoded>
    &lt;p&gt;These days many systems are multi-homed in the sense that they have more than one IP address bound at the same time.&lt;br /&gt;
I.e. for different network cards, virtual IPs for shared servers or just using WiFi and a wired network connection at the same time on a laptop.&lt;/p&gt;

&lt;p&gt;Murphy of course makes sure that your system will choose to worst IP (i.e. that on slow WiFi or the one reserved for admin access) when an application does not specifically supports binding to a selected IP address.
And Mozilla Firefox for example doesn&#039;t.&lt;/p&gt;

&lt;p&gt;The kernel chooses an outgoing IP from those in the routing table with the same metric:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;daniel@server:~$ route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.0.2.1         0.0.0.0         U     0      0        0 eth0
0.0.0.0         192.0.2.2         0.0.0.0         U     0      0        0 eth1
0.0.0.0         192.0.2.3         0.0.0.0         U     0      0        0 eth2
0.0.0.0         192.0.2.4         0.0.0.0         U     0      0        0 eth3
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;You can obviously play around with the metric and make the kernel router prefer the desired interface above others. This will affect all applications though.
Some people use the firewall to nat all packages to port 80 onto the network interface desired for web browsing. Gee, beware the http://somewebsite.tld:8080 links...&lt;/p&gt;

&lt;p&gt;Thankfully &lt;a href=&quot;http://www.ryde.net&quot; title=&quot;Daniel Ryde&#039;s homepage&quot;&gt;Daniel Ryde&lt;/a&gt; has solved the problem via a LD_PRELOAD shim. With his code you can run&lt;/p&gt;

&lt;div class=&quot;bash geshi&quot; style=&quot;text-align: left&quot;&gt;&lt;span style=&quot;color: #666666;&quot;&gt;daniel@laptop:~$ &lt;/span&gt;&lt;span style=&quot;color: #007800;&quot;&gt;BIND_ADDR&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;192.0.2.100&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #007800;&quot;&gt;LD_PRELOAD&lt;/span&gt;=&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;usr&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;lib&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;bind.so firefox &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;

&lt;p&gt;and happily surf away.&lt;/p&gt;

&lt;p&gt;To compile &lt;a href=&quot;http://www.ryde.net/code/bind.c.txt&quot; title=&quot;Bind.c LD_PRELOAD wrapper&quot;&gt;his code&lt;/a&gt; (3.3kB, &lt;a href=&quot;http://daniel-lange.com/software/bind.c&quot; title=&quot;Local copy of Daniel Ryde&#039;s Bind.c LD_PRELOAD wrapper&quot;&gt;local copy&lt;/a&gt;, see note 1)
you need to run&lt;/p&gt;

&lt;div class=&quot;bash geshi&quot; style=&quot;text-align: left&quot;&gt;&lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;gcc&lt;/span&gt; &lt;span style=&quot;color: #660033;&quot;&gt;-nostartfiles&lt;/span&gt; &lt;span style=&quot;color: #660033;&quot;&gt;-fpic&lt;/span&gt; &lt;span style=&quot;color: #660033;&quot;&gt;-shared&lt;/span&gt; bind.c &lt;span style=&quot;color: #660033;&quot;&gt;-o&lt;/span&gt; bind.so &lt;span style=&quot;color: #660033;&quot;&gt;-ldl&lt;/span&gt; -D_GNU_SOURCE&lt;br /&gt;&lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;strip&lt;/span&gt; bind.so&lt;br /&gt;&lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;cp&lt;/span&gt; &lt;span style=&quot;color: #660033;&quot;&gt;-i&lt;/span&gt; bind.so &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;usr&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;lib&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;&lt;/div&gt;

&lt;p&gt;and you&#039;re set to go.&lt;/p&gt;

&lt;p&gt;If you don&#039;t have gcc available (and trust me) you can download pre-compiled 32bit and 64bit (glibc-2) bind.so libraries &lt;a href=&quot;http://daniel-lange.com/software/bind_so_compiled.tar.gz&quot; title=&quot;Pre-compiled 32bit and 64bit bind.so libs&quot;&gt;here&lt;/a&gt; (4.5kB).&lt;/p&gt;

&lt;p&gt;I guess because Daniel Ryde hid his code so well on his webpage, Robert J. McKay wrote another LD_PRELOAD shim, called &lt;a href=&quot;http://wari.mckay.com/~rm/bindhack.c.txt&quot; title=&quot;Bindhack.c LD_PRELOAD wrapper&quot;&gt;Bindhack&lt;/a&gt; (4.5kB, &lt;a href=&quot;http://daniel-lange.com/software/bindhack.c&quot; title=&quot;Local mirror of Robert J. McKay&#039;s Bindhack.c LD_PRELOAD wrapper&quot;&gt;local mirror&lt;/a&gt;). This will - as is - only compile on 32bit machines. But YMMV.&lt;/p&gt;

&lt;p&gt;Run the above command &lt;strong&gt;(&amp;#42;)&lt;/strong&gt; with your desired (and locally bound) IP address in bash and visit &lt;a href=&quot;http://myip.dk&quot; title=&quot;MyIP.dk show-your-ip service&quot;&gt;MyIP.dk&lt;/a&gt; or &lt;a href=&quot;http://en.dnstools.ch/show-my-ip.html&quot; title=&quot;DNStools.ch show-your-ip service&quot;&gt;DNStools.ch&lt;/a&gt; or any of the other services that show your external IP to see whether you&#039;ve succeeded.&lt;/p&gt;

&lt;p&gt;Notes:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Daniel Ryde did not specify the -D_GNU_SOURCE in the comments section of bind.c. Modern glibc/gcc need that as he used RTLD_NEXT which is Unix98 and not POSIX. I amended the local copy of bind.c and sent him an email so he can update his.&lt;/li&gt;
&lt;li&gt;Both are IPv4 only, no IPv6 support.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;Updates:&lt;/h3&gt;

&lt;p&gt;19.03.15 madmakz wrote in to clarify that all of the bind LD_PRELOAD shims only work with TCP connections. So &lt;strong&gt;not&lt;/strong&gt; with UDP.&lt;br /&gt;
I&#039;m not aware of a shim that manipulates UDP sockets.&lt;/p&gt;

&lt;p&gt;14.01.14 Christian Pellegrin wrote a superb &lt;a href=&quot;http://www.evolware.org/?p=293&quot; title=&quot;Article: Using Linux Network Namespaces for per processes routing&quot;&gt;article&lt;/a&gt; on how to achieve per-application routing with the help of Linux network namespaces.&lt;/p&gt;

&lt;p&gt;16.06.13 showip.be seems to be gone, so I replaced it with dnstools.ch in the text above. There are &lt;a href=&quot;http://www.google.com/search?q=show+my+ip&quot; title=&quot;Google for see-your-external-IP services&quot;&gt;plenty of others&lt;/a&gt; as well.&lt;/p&gt;

&lt;p&gt;22.06.12 Lennart Poettering has a IPv4 only version of a shim and a rather good readme available at &lt;a href=&quot;http://0pointer.de/lennart/projects/fixsrcip/&quot; title=&quot;Lennart Poettering&#039;s FixSrcIP&quot;&gt;his site&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;29.11.10 Catalin M. Boie wrote another LD_PRELOAD shim, &lt;a href=&quot;http://kernel.embedromix.ro/us/&quot; title=&quot;Catalin(ux) Homepage&quot;&gt;force_bind&lt;/a&gt;. I have not tested this one. It&#039;s capable of handling IPv6 binds.&lt;/p&gt;

&lt;p&gt;11.01.09 Daniel Ryde has replied to my email and updated his local copy now as well.&lt;/p&gt;
 
    </content:encoded>

    <pubDate>Sat, 09 Jan 2010 19:00:00 +0000</pubDate>
    <guid isPermaLink="false">http://daniel-lange.com/archives/53-guid.html</guid>
    <category>address</category>
<category>bind</category>
<category>ip</category>
<category>ld_preload</category>
<category>multi-homed</category>
<category>network</category>
<category>updated</category>

</item>

</channel>
</rss>
