<?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>tolaris.com &#187; kernel</title>
	<atom:link href="http://www.tolaris.com/tag/kernel/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.tolaris.com</link>
	<description>When the going gets tough, the tough sniff packets.</description>
	<lastBuildDate>Tue, 24 Jan 2012 17:47:01 +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>Reverse-path filter part 2: OpenVPN and traceroute</title>
		<link>http://www.tolaris.com/2009/07/14/reverse-path-filter-part-2-openvpn/</link>
		<comments>http://www.tolaris.com/2009/07/14/reverse-path-filter-part-2-openvpn/#comments</comments>
		<pubDate>Tue, 14 Jul 2009 21:59:53 +0000</pubDate>
		<dc:creator>Tyler Wagner</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[kernel]]></category>
		<category><![CDATA[networking]]></category>
		<category><![CDATA[openvpn]]></category>

		<guid isPermaLink="false">http://www.tolaris.com/?p=416</guid>
		<description><![CDATA[After my recent adventure with reverse-path filtering, I didn&#8217;t expect to see it again so soon. And then I took another look at a long-standing annoyance in our OpenVPN network. I set up OpenVPN so our offices and laptops could securely access internal resources. This lets me print documents directly to another office, for instance. [...]]]></description>
			<content:encoded><![CDATA[<p>After my <a href="/2009/07/13/disabling-reverse-path-filtering-in-complex-networks/">recent adventure</a> with reverse-path filtering, I didn&#8217;t expect to see it again so soon.  And then I took another look at a long-standing annoyance in our OpenVPN network.</p>
<p>I set up <a href="http://www.openvpn.net">OpenVPN</a> so our offices and laptops could securely access internal resources.  This lets me print documents directly to another office, for instance.  Or access web-based applications that we don&#8217;t make available to the public.  Or remotely SSH into a PC and fix a problem.  <span id="more-416"></span>A month after setting it up, I realised that:</p>
<ol>
<li>I could traceroute from a host on the LAN to a host on another office LAN, via the VPN</li>
<li>I could traceroute from a host on the LAN to a host in the Internet, where the traffic never enters the VPN</li>
<li>I could <strong>not</strong> traceroute from a host on the LAN, through the VPN to the central VPN server, and from there to a server on the public Internet</li>
</ol>
<p>Why would I want to do #3?  Because I sometimes deal with ISPs and autocratic governments that filter Internet traffic.  In those circumstances, I back-haul all my traffic to the VPN server and break out there, bypassing any <a href="/proxy.emirates.net.ae/">annoying proxies</a>.</p>
<p>How I do it is a story for another day.  Suffice it to say that much complicated NAT trickery and careful routing is involved.</p>
<p>So, #1 (through the VPN to the VPN server, and again to another office) is good:</p>
<p><code>tyler@baal:~$ sudo traceroute -n -I 192.168.6.50</code></p>
<pre>traceroute to 192.168.6.50 (192.168.6.50), 30 hops max, 40 byte packets
 1  192.168.3.1  1.596 ms  2.905 ms  3.394 ms
 2  10.1.0.1  21.868 ms  26.078 ms  27.751 ms
 3  10.1.0.10  162.386 ms  166.004 ms  168.540 ms
 4  192.168.6.50  171.394 ms  175.397 ms  181.904 ms</pre>
<p>And #2 (avoiding the VPN entirely) is good:</p>
<p><code>tyler@baal:~$ sudo traceroute -n -I google.com</code></p>
<pre>traceroute to google.com (74.125.45.100), 30 hops max, 40 byte packets
 1  192.168.3.1  1.718 ms  3.435 ms  4.546 ms
 2  10.1.110.1  12.975 ms  16.903 ms  17.462 ms
 ...
16  74.125.45.100  114.961 ms  110.625 ms  112.908 ms</pre>
<p>But #3 (through the VPN to the VPN server) gives no joy.  If I change my router&#8217;s VPN setup to route all traffic through the VPN (or create a  specific route for Google), I see:</p>
<p><code>tyler@baal:~$ sudo traceroute -n -I google.com</code></p>
<pre>traceroute to google.com (74.125.45.100), 30 hops max, 40 byte packets
 1  192.168.3.1  1.618 ms  2.005 ms  3.704 ms
 2  10.1.0.1  21.889 ms  29.736 ms  30.924 ms
 3  172.16.64.17  33.234 ms  35.010 ms  37.247 ms
 4  * * *
 5  * * *
 ...
15  * * *
16  74.125.45.100  126.346 ms  114.346 ms  114.358 ms</pre>
<p>So I can ping it, and the final step in the trace shows the answer, but no routers between the VPN server and Google appear.</p>
<p>Or does it?  A little sniffing at my router showed something interesting:</p>
<p><code>root@router:~# tshark -i tun0 -f 'icmp[icmptype] = icmp-timxceed'</code></p>
<pre>0.000079 192.168.3.1 -> 192.168.3.10 ICMP Time-to-live exceeded (Time to live exceeded in transit)
0.020700 10.1.0.1 -> 192.168.3.10 ICMP Time-to-live exceeded (Time to live exceeded in transit)
...
0.076001 146.188.15.237 -> 192.168.3.10 ICMP Time-to-live exceeded (Time to live exceeded in transit)
0.107338 146.188.69.102 -> 192.168.3.10 ICMP Time-to-live exceeded (Time to live exceeded in transit)</pre>
<p>So the traffic is coming in the VPN tunnel.  But what is going out?</p>
<p><code>root@router:~# tshark -i eth1 -f 'icmp[icmptype] = icmp-timxceed'</code></p>
<pre>
0.000083 192.168.3.1 -> 192.168.3.10 ICMP Time-to-live exceeded (Time to live exceeded in transit)
0.021200 10.1.0.1 -> 192.168.3.10 ICMP Time-to-live exceeded (Time to live exceeded in transit)
0.024700 172.16.64.17 -> 192.168.3.10 ICMP Time-to-live exceeded (Time to live exceeded in transit)
...</pre>
<p>I could see the initial &#8220;TTL expired&#8221; messages from the first few hops, but none after that.  Something is stopping them between tun0 (the OpenVPN tun interface) and eth1 (the inside LAN interface).</p>
<p>Can you see where I&#8217;m going with this?  It&#8217;s our old friend, the reverse-path filter.  Disable it with sysctl or echo.</p>
<p><code>echo 0 > /proc/sys/net/ipv4/conf/all/rp_filter</code></p>
<p>For some reason, the kernel doesn&#8217;t mind most traffic moving between eth1 and tun0, but something about the ICMP &#8220;TTL expired&#8221; messages triggered rp_filter.  Disable it and traceroute works again.</p>
<p>Aside: I always use <a href="http://www.bitwizard.nl/mtr/">mtr</a> in place of regular traceroute.  What traceroute does in O(n), mtr does in O(1).  Actually O(n/5), but explaining that needs it own post.  mtr is fast.  You should use mtr.  Your distro has it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tolaris.com/2009/07/14/reverse-path-filter-part-2-openvpn/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Disabling reverse-path filtering in complex networks</title>
		<link>http://www.tolaris.com/2009/07/13/disabling-reverse-path-filtering-in-complex-networks/</link>
		<comments>http://www.tolaris.com/2009/07/13/disabling-reverse-path-filtering-in-complex-networks/#comments</comments>
		<pubDate>Mon, 13 Jul 2009 21:25:35 +0000</pubDate>
		<dc:creator>Tyler Wagner</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[kernel]]></category>
		<category><![CDATA[networking]]></category>

		<guid isPermaLink="false">http://www.tolaris.com/?p=400</guid>
		<description><![CDATA[I recently created a very complex network using routers running Ubuntu Hardy. These routers were configured with the following features: failover shared IP addresses using heartbeat routing announcements via Quagga BGPd 802.1q VLAN tagging multiple physical interfaces During debugging of this network, I encountered an odd scenario whereby traffic coming in from the external interface [...]]]></description>
			<content:encoded><![CDATA[<p>I recently created a very complex network using routers running Ubuntu Hardy.  These routers were configured with the following features:</p>
<ul>
<li>failover shared IP addresses using <a href="http://www.linux-ha.org/Heartbeat">heartbeat</a></li>
<li>routing announcements via <a href="http://www.quagga.net/">Quagga</a> BGPd</li>
<li>802.1q <a href="https://wiki.ubuntu.com/vlan">VLAN</a> tagging</li>
<li>multiple physical interfaces</li>
</ul>
<p>During debugging of this network, I encountered an odd scenario whereby traffic coming in from the external interface (eth0) could not reach the IP address of the secondary (inactive) router&#8217;s internal interface (eth1, VLAN tagged).</p>
<p><img src="http://www.tolaris.com/blog/wp-content/uploads/2009/07/dual-routers.png" alt="dual-routers" title="dual-routers" width="730" height="290" class="alignnone size-full wp-image-402" /></p>
<p><span id="more-400"></span>When router B is inactive, it is available on IP addresses on both eth0 and one VLAN of eth1.  Because it is inactive, traffic bound for an IP on router B eth1 moves in a big clock-wise circle around the above diagram.  It comes from outside to router A eth0, exits router A via eth1, moves to the internal switch, then back to router B eth1.  When active, traffic comes directly to it from outside, and instead router A behaves this way.  The problem is that when in the inactive state, the inactive router&#8217;s return traffic goes directly out eth0.  That is, it comes in eth1 and goes back out eth0.</p>
<p>When such a situation occurs (source and destination traffic to the same IP using different interfaces), the Linux kernel (by default in Debian/Ubuntu) drops the traffic as potentially spoofed.  This is called <a href="http://tldp.org/HOWTO/Adv-Routing-HOWTO/lartc.kernel.rpf.html">reverse-path filtering</a>, and it is useful for preventing obviously bad traffic from entering your network (sourced from a local IP address, multicast, etc).  However, you can safely disable it if you perform the same sanity checks in your iptables firewall (and you do, right?).</p>
<p>To disable this check, use the net.ipv4.conf.all.arp_filter sysctl variable:</p>
<p><code>root@routera:~# sysctl -a | grep \\.rp_filter</code></p>
<pre>net.ipv4.conf.lo.rp_filter = 1
net.ipv4.conf.all.rp_filter = 1
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.eth0.rp_filter = 1
net.ipv4.conf.eth1.rp_filter = 1
net.ipv4.conf.eth1/10.rp_filter = 1
net.ipv4.conf.eth1/20.rp_filter = 1</pre>
<p>In this example, my router has two physical interfaces, eth0 and eth1, and has two tagged VLANs on eth1 (VLANs 10 and 20).  All are set to perform basic reverse-path filtering.  Change them by editing /etc/sysctl.conf.  Find this section:</p>
<pre># Comment the next two lines to disable Spoof protection (reverse-path filter)
# Turn on Source Address Verification in all interfaces to
# prevent some spoofing attacks
net.ipv4.conf.default.rp_filter=1
net.ipv4.conf.all.rp_filter=1</pre>
<p>Comment-out the two lines here, and apply changes with <code>sysctl -p</code>.  If any interfaces still show rp_filter=1, reboot or set them to zero yourself:</p>
<p><code>sysctl -w net.ipv4.conf.eth0.rp_filter=0</code></p>
<p>This problem with rp_filter seems to specifically cause issues with VLAN interfaces.  I have another pair of routers doing the same thing, except they don&#8217;t use VLAN tagging on eth1.  They have no issues with rp_filter at all.</p>
<p>If you suspect your traffic is being filtered by rp_filter, you can find out with log_martians:</p>
<p><code>sysctl -w net.ipv4.conf.all.log_martians=1</code></p>
<p>Your syslog will now show dropped packets.</p>
<p>Note that the value of rp_filter is not <a href="http://lists.netfilter.org/pipermail/netfilter/2000-September/005400.html">what you may expect</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tolaris.com/2009/07/13/disabling-reverse-path-filtering-in-complex-networks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

