<?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>Lackhead.org &#187; route</title>
	<atom:link href="http://www.lackhead.org/tag/route/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.lackhead.org</link>
	<description>The irascible ramblings of some guy named Chad</description>
	<lastBuildDate>Sun, 28 Aug 2011 16:19:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Outgoing traffic with IP aliasing</title>
		<link>http://www.lackhead.org/2008/02/outgoing-traffic-with-ip-aliasing/</link>
		<comments>http://www.lackhead.org/2008/02/outgoing-traffic-with-ip-aliasing/#comments</comments>
		<pubDate>Sat, 02 Feb 2008 22:59:42 +0000</pubDate>
		<dc:creator>lackhead</dc:creator>
				<category><![CDATA[Computer-schmuter]]></category>
		<category><![CDATA[alias]]></category>
		<category><![CDATA[interface]]></category>
		<category><![CDATA[ip address]]></category>
		<category><![CDATA[route]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.lackhead.org/2008/02/outgoing-traffic-with-ip-aliasing/</guid>
		<description><![CDATA[I recently ran into an issue that, while it had a simple solution, stumped me for a while. I don&#8217;t know if said stumpitude came from my waning mental faculties or what. In any case, it took me longer than &#8230; <a href="http://www.lackhead.org/2008/02/outgoing-traffic-with-ip-aliasing/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I recently ran into an issue that, while it had a simple solution, stumped me for a while.  I don&#8217;t know if said stumpitude came from my waning mental faculties or what.  In any case, it took me longer than expected to track down the answer, and since there weren&#8217;t too many pages that I found out on the net that addressed this, I thought I&#8217;d at least get this down somewhere. </p>
<p>The issue came up on my main application server, which runs my web server, email server, and is a DNS master for one of my domains. I recently set up a virtual web server under apache, and since it was doing SSL I needed it to run using its own IP address so that I could use an IP-address based virtual server configuration.  Since the machine is running Ubuntu 7.04 (a Debian variant), the ethernet interfaces are set up in <em>/etc/network/interfaces</em>.  Here is what that file looked like before adding the alias:</p>
<blockquote><p><PRE><br />
# The loopback network interface<br />
auto lo<br />
iface lo inet loopback</p>
<p># The primary network interface<br />
auto eth0<br />
iface eth0 inet static<br />
        address 10.0.0.25<br />
        netmask 255.255.255.0<br />
        network 10.0.0.0<br />
        broadcast 10.0.0.255<br />
        gateway 10.0.0.1<br />
</PRE></p></blockquote>
<p>Easy enough to add an alias; I just copied/pasted in another stanza, identical to the eth0 stanza only with the alias set up so that it was set up as eth0:0:</p>
<blockquote><p><PRE><br />
# The secondary network interface<br />
auto eth0:0<br />
iface eth0:0 inet static<br />
        address 10.0.0.50<br />
        netmask 255.255.255.0<br />
        network 10.0.0.0<br />
        broadcast 10.0.0.255<br />
        gateway 10.0.0.1<br />
</PRE></p></blockquote>
<p><span id="more-113"></span></p>
<p>A quick <em>ifup eth0:0</em> and now I was up and running with my one ethernet interface answering to two IP addresses, one which was my original/main IP addr (10.0.0.25) and a new one that I could use for my new virtual web server (10.0.0.50).   </p>
<p>But I ran into a snag- I found out later that my DNS updates were no longer being pushed out to my secondary servers.  Why?  Well, being a good administrator I set up bind on my secondary DNS servers to only accept zone updates from the master server, via a stanza like this in <em>named.conf</em>:</p>
<blockquote><p><PRE><br />
// be secondary for lackhead.org<br />
zone &#8220;foobar.com&#8221; in  {<br />
       type slave;<br />
       notify no;<br />
       file &#8220;db.foobar.com&#8221;;<br />
       masters { 10.0.0.25; };<br />
};<br />
</PRE></p></blockquote>
<p>Looking at the named logs, I saw that the zone updates being pushed out by my master name server were coming from 10.0.0.50, the new IP alias I had just set up. In face, looking at the box, I saw that all outgoing traffic that originated from my server box was coming from this new IP alias I had set up, instead of what I thought of as the primary interface, eth0. </p>
<p>After a bit of digging, I found my error. If you notice up above when I created eth0:0 in the <em>/etc/network/interfaces</em> file, I just copied/pasted the stanza, and then just updated the IP address, and changed the interface name from eth0 to eth0:0.  One effect of this was that the IP alias also had a line that specified the gateway.  The result of this was that when Ubuntu was bringing up the interfaces, it essentially did a <em>ip route add default gw &#8230;.</em> command, which meant that a default route was added to the routing table for each interface. This is what my routing table looked like:</p>
<blockquote><p><PRE><br />
(508) root@myhost:/var/log:# netstat -nr<br />
Kernel IP routing table<br />
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface<br />
10.0.0.0        0.0.0.0         255.255.255.0   U         0 0          0 eth0<br />
0.0.0.0         10.0.0.1     0.0.0.0         UG        0 0          0 eth0<br />
0.0.0.0         10.0.0.1     0.0.0.0         UG        0 0          0 eth0<br />
(509) root@myhost:/var/log:#<br />
</PRE></p></blockquote>
<p>Note the duplicate entry for <em>0.0.0.0</em>.  This, I think, is where I got confused and/or misled, because netstat doesn&#8217;t seem to report sub interfaces, so while I say that I had two default routes, they both pointed to eth0, not eth0:0, and so in my mind I read this as all traffic should be going out eth0.  Honestly, I consider this a bug, and perhaps I&#8217;ll submit one to Ubuntu for it. </p>
<p>In any case, I did eventually figure out what was going on, and removed the gateway line from the eth0:0 stanza, did a quick <em>ifdown eth0:0 ; ifup eth0:0</em> and viola, not only did the duplicate entry in the routing table not show up, but I got the behavior I had expected; all outgoing traffic from my box now originated from eth0, but any traffic coming into the IP address bound to eth0:0 was responded to out of eth0:0. </p>
<p>Yay!  Lesson to be learned- be wary of perils of cut and paste. </p>
<p>-c</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lackhead.org/2008/02/outgoing-traffic-with-ip-aliasing/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

