<?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>Myatu&#039;s &#187; networking</title>
	<atom:link href="http://www.myatus.co.uk/tag/networking/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.myatus.co.uk</link>
	<description>Wasting bits and bytes daily</description>
	<lastBuildDate>Wed, 08 Sep 2010 19:01:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<atom:link rel='hub' href='http://www.myatus.co.uk/?pushpress=hub'/>
		<item>
		<title>Quick Debian/Ubuntu networking tips</title>
		<link>http://www.myatus.co.uk/2009/10/20/quick-debianubuntu-networking-tips/</link>
		<comments>http://www.myatus.co.uk/2009/10/20/quick-debianubuntu-networking-tips/#comments</comments>
		<pubDate>Mon, 19 Oct 2009 23:06:14 +0000</pubDate>
		<dc:creator>Myatu</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[networking]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.myatus.co.uk/?p=216</guid>
		<description><![CDATA[Like anyone else, at times I forget how to do certain things when it comes to networking. Here are a few reminders / tips specific to Debian and Ubuntu. IPv4 Specific Enable Proxy ARP (Address Resolution Protocol) Assuming eth0 as the interface, in /etc/network/interfaces add: iface eth0 inet static &#160; &#160; ... &#160; &#160; post_up [...]


Related posts:<ol><li><a href='http://www.myatus.co.uk/2009/09/07/compiling-nginx-on-debian-ubuntu/' rel='bookmark' title='Permanent Link: Compiling NginX on Debian / Ubuntu'>Compiling NginX on Debian / Ubuntu</a></li>
<li><a href='http://www.myatus.co.uk/2009/08/31/guide-firewall-and-router-with-proxmox/' rel='bookmark' title='Permanent Link: Guide: Firewall and router with Proxmox'>Guide: Firewall and router with Proxmox</a></li>
<li><a href='http://www.myatus.co.uk/2010/07/17/blocking-w00tw00t-scans/' rel='bookmark' title='Permanent Link: Blocking w00tw00t scans'>Blocking w00tw00t scans</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><img class="size-thumbnail wp-image-228 alignleft" title="Quick Debian/Ubuntu networking tips" src="http://www.myatus.co.uk/wp-content/uploads/2009/10/iptables-150x84.PNG" alt="Quick Debian/Ubuntu networking tips" width="150" height="84" /></p>
<p>Like anyone else, at times I forget how to do certain things when it comes to networking.</p>
<p>Here are a few reminders / tips specific to Debian and Ubuntu.</p>
<p><span id="more-216"></span></p>
<h2><span>IPv4 Specific</span></h2>
<h3>Enable Proxy ARP (<a title="Address Resolution Protocol" rel="wikipedia" href="http://en.wikipedia.org/wiki/Address_Resolution_Protocol" target="_blank">Address Resolution Protocol</a>)</h3>
<p>Assuming <em>eth0</em> as the interface, in <em>/etc/network/interfaces</em> add:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">iface eth0 inet static<br />
&nbsp; &nbsp; ...<br />
&nbsp; &nbsp; post_up echo 1 &gt; /proc/sys/net/ipv4/conf/eth0/proxy_arp</div></div>
</pre>
<h3>Route incoming traffic to another server</h3>
<p>In other words, all traffic arriving at a certain IP should be forwarded to another server (public or internal).</p>
<p>Using <em>iptables</em>, issue the following command from the shell:</p>
<pre>
<div class="codecolorer-container bash blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">iptables <span style="color: #660033;">-t</span> nat <span style="color: #660033;">-I</span> PREROUTING <span style="color: #660033;">-d</span> <span style="color: #000000; font-weight: bold;">&lt;</span>original ip<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #660033;">-j</span> DNAT <span style="color: #660033;">--to</span> <span style="color: #000000; font-weight: bold;">&lt;</span>other server<span style="color: #000000; font-weight: bold;">&gt;</span></div></div>
</pre>
<p>Where <em>&lt;original ip&gt;</em> is the IP where incoming traffic is  received, and <em>&lt;other server&gt;</em> is where the traffic should be routed to.</p>
<h3>Route outgoing web traffic via another IP</h3>
<p>In other words, make outgoing web traffic appear as if coming from another public IP address (registered to the server and router).</p>
<p>Assuming that <em>eth0</em> is the public interface, using <em>iptables</em> issue the following command from the shell:</p>
<pre>
<div class="codecolorer-container bash blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">iptables <span style="color: #660033;">-t</span> nat <span style="color: #660033;">-A</span> POSTROUTING <span style="color: #660033;">-o</span> eth0 <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">-m</span> tcp <span style="color: #660033;">--dport</span> <span style="color: #000000;">80</span> <span style="color: #660033;">-j</span> SNAT <span style="color: #660033;">--to-source</span> <span style="color: #000000; font-weight: bold;">&lt;</span>ip<span style="color: #000000; font-weight: bold;">&gt;</span></div></div>
</pre>
<p>Where <em>&lt;ip&gt;</em> is the IP address to be used.</p>
<p><em>Note: You can substitute tcp for udp, or use a different port for other applications such as FTP. Also, the IP must be routable to your server. </em></p>
<h3>Viewing the NAT table</h3>
<p>Issue the following command from the shell:</p>
<pre>
<div class="codecolorer-container bash blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">iptables <span style="color: #660033;">-t</span> nat <span style="color: #660033;">-L</span></div></div>
</pre>
<h3>Flush iptables</h3>
<p>The clear the <em>iptables</em> entirely,  issue the following command from the shell:</p>
<pre>
<div class="codecolorer-container bash blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">iptables <span style="color: #660033;">-F</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> iptables <span style="color: #660033;">-t</span> nat <span style="color: #660033;">-F</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> iptables <span style="color: #660033;">-t</span> mangle <span style="color: #660033;">-F</span></div></div>
</pre>
<h2><span>IPv6 Specific</span></h2>
<h3>Enable Proxy NDP for IPv6 (Neighbor Detection Protocol)</h3>
<p>Assuming <em>eth0</em> as the interface, in <em>/etc/network/interfaces</em> add:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">iface eth0 inet static<br />
&nbsp;...<br />
&nbsp;post_up echo 1 &gt; /proc/sys/net/ipv6/conf/eth0/proxy_ndp</div></div>
</pre>
<h3>Manually announce an IPv6 neighbor</h3>
<p>Assuming eth0 as the public IPv6 interface:</p>
<pre>
<div class="codecolorer-container bash blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">ip <span style="color: #660033;">-6</span> neigh add proxy <span style="color: #000000; font-weight: bold;">&lt;</span>ipv6<span style="color: #000000; font-weight: bold;">&gt;</span> dev eth0</div></div>
</pre>
<p>Where <em>&lt;ipv6&gt;</em> is the actual IPv6 address.</p>
<h3>Enable IPv6 forwarding</h3>
<p>In <em>/etc/sysctl.conf</em> uncomment:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">net.ipv6.conf.all.forwarding=1</div></div>

<em> </em></pre>
<h3>Adding more than one IPv6 address per interface</h3>
<p>Edit <em>/etc/network/interfaces</em>, add:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">iface eth0 inet6 static<br />
&nbsp; &nbsp; ...<br />
&nbsp; &nbsp; up /sbin/ifconfig eth0 inet6 add &lt;ip&gt;/&lt;netmask&gt;</div></div>
</pre>
<p>Where <em>&lt;ip&gt;/&lt;netmask&gt;</em> is the actual IPv6 and netmask respectively, i.e.: <em>dead:beef:cafe:1::1/64</em>.</p>
<p><em>Note:  The last entry takes priority.</em></p>
<h3>Setup a 6to4 tunnel (IPv6 to IPv4 translation)</h3>
<p>Obtain IPv6 address for 6to4:</p>
<pre>
<div class="codecolorer-container bash blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #7a0874; font-weight: bold;">printf</span> <span style="color: #ff0000;">&quot;2002:%02x%02x:%02x%02x::1<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> $<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #000000; font-weight: bold;">&lt;</span>ipv4<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">tr</span> . <span style="color: #ff0000;">' '</span><span style="color: #7a0874; font-weight: bold;">&#41;</span></div></div>
</pre>
<p>Where <em>&lt;ipv4&gt;</em> is the actual IPv4 address, i.e.., <em>91.2.3.4</em> would result in <em>2002:5b02:0304::1</em>.</p>
<p>Edit <em>/etc/network/interfaces</em>, add:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">auto tun6to4<br />
iface tun6to4 inet6 v4tunnel<br />
&nbsp; &nbsp; address &lt;ipv6 obtained&gt;<br />
&nbsp; &nbsp; netmask 16<br />
&nbsp; &nbsp; gateway ::192.88.99.1<br />
&nbsp; &nbsp; endpoint any<br />
&nbsp; &nbsp; local &lt;actual ipv4&gt;</div></div>
</pre>
<p>Where the &lt;ipv6 obtained&gt; and &lt;actual ipv4&gt; is from the explanation given earlier. For example:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">auto tun6to4<br />
iface tun6to4 inet6 v4tunnel<br />
&nbsp; &nbsp; address 2002:5b02:0304::1<br />
&nbsp; &nbsp; netmask 16<br />
&nbsp; &nbsp; gateway ::192.88.99.1<br />
&nbsp; &nbsp; endpoint any<br />
&nbsp; &nbsp; local 91.2.3.4</div></div>
</pre>
<p><em>Note: 192.88.99.1 will automatically select the nearest IPv6 to IPv4 gateway.</em></p>
<h2><span>Application Specific</span></h2>
<h3>Setup OpenVPN tap tunnel interface on a bridge</h3>
<p>Edit <em>/etc/network/interfaces</em>, add:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">iface vmbr0 inet static<br />
&nbsp; &nbsp; ...<br />
&nbsp; &nbsp; bridge_ports tap0<br />
&nbsp; &nbsp; ...<br />
&nbsp; &nbsp; pre-up /usr/sbin/openvpn --mktun --dev tap0<br />
&nbsp; &nbsp; post-down /usr/sbin/openvpn --rmtun --dev tap0</div></div>
</pre>
<h4>Enable OpenVZ/Proxmox for IPv6</h4>
<p>Edit <em>/etc/vz/vz.conf</em> and change:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">...<br />
IPV6=&quot;yes&quot;<br />
...</div></div>
</pre>
<h3>Adding a failover IP (OVH)</h3>
<p>Edit <em>/etc/network/interfaces</em> and add a new alias:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">auto eth0:&lt;alias number&gt;<br />
iface eth0:&lt;alias number&gt; inet static<br />
&nbsp; &nbsp; address &nbsp;&lt;failover ip&gt;<br />
&nbsp; &nbsp; netmask &nbsp;255.255.255.255</div></div>
</pre>
<p>Where <em>&lt;alias number&gt; </em>is a sequential number starting at 0 (zero) and <em>&lt;failover ip&gt;</em> is the actual failover IP address. For example:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">auto eth0:0<br />
iface eth0:0 inet static<br />
&nbsp; &nbsp; address &nbsp;91.2.3.4<br />
&nbsp; &nbsp; netmask &nbsp;255.255.255.255</div></div>
</pre>
<div class="shr-publisher-216"></div>

<p>Related posts:<ol><li><a href='http://www.myatus.co.uk/2009/09/07/compiling-nginx-on-debian-ubuntu/' rel='bookmark' title='Permanent Link: Compiling NginX on Debian / Ubuntu'>Compiling NginX on Debian / Ubuntu</a></li>
<li><a href='http://www.myatus.co.uk/2009/08/31/guide-firewall-and-router-with-proxmox/' rel='bookmark' title='Permanent Link: Guide: Firewall and router with Proxmox'>Guide: Firewall and router with Proxmox</a></li>
<li><a href='http://www.myatus.co.uk/2010/07/17/blocking-w00tw00t-scans/' rel='bookmark' title='Permanent Link: Blocking w00tw00t scans'>Blocking w00tw00t scans</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.myatus.co.uk/2009/10/20/quick-debianubuntu-networking-tips/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
