<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"><title>Louwrentius - Networking</title><link href="https://louwrentius.com/" rel="alternate"/><link href="https://louwrentius.com/feeds/networking.atom.xml" rel="self"/><id>https://louwrentius.com/</id><updated>2021-09-29T12:00:00+02:00</updated><entry><title>Raspberry Pi as a router using a single network interface</title><link href="https://louwrentius.com/raspberry-pi-as-a-router-using-a-single-network-interface.html" rel="alternate"/><published>2021-09-29T12:00:00+02:00</published><updated>2021-09-29T12:00:00+02:00</updated><author><name>Louwrentius</name></author><id>tag:louwrentius.com,2021-09-29:/raspberry-pi-as-a-router-using-a-single-network-interface.html</id><summary type="html">&lt;h2&gt;Introduction&lt;/h2&gt;
&lt;p&gt;Disclaimer: this article is intended for consumers and hobbyists.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;If you want to run your own router at home, the Raspberry Pi 4 Model B&lt;sup id="fnref:older"&gt;&lt;a class="footnote-ref" href="#fn:older"&gt;1&lt;/a&gt;&lt;/sup&gt; can be an excelent hardware choice:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;it's fairly cheap&lt;/li&gt;
&lt;li&gt;it's fast enough&lt;/li&gt;
&lt;li&gt;it can saturate it's gigabit network port&lt;/li&gt;
&lt;li&gt;it is power-efficient&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The …&lt;/p&gt;</summary><content type="html">&lt;h2&gt;Introduction&lt;/h2&gt;
&lt;p&gt;Disclaimer: this article is intended for consumers and hobbyists.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;If you want to run your own router at home, the Raspberry Pi 4 Model B&lt;sup id="fnref:older"&gt;&lt;a class="footnote-ref" href="#fn:older"&gt;1&lt;/a&gt;&lt;/sup&gt; can be an excelent hardware choice:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;it's fairly cheap&lt;/li&gt;
&lt;li&gt;it's fast enough&lt;/li&gt;
&lt;li&gt;it can saturate it's gigabit network port&lt;/li&gt;
&lt;li&gt;it is power-efficient&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The key problem it seems, is that it has only &lt;em&gt;one&lt;/em&gt;, single network interface. If you build a router, you need at least two:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;The first interface connected to your internet modem/router (ideally in bridge mode)&lt;/li&gt;
&lt;li&gt;The second interface connected to your home network (probably a switch)&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;So if you would use the Raspberry Pi, you would probably buy a gigabit USB3 NIC for around $20 and be done with it.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://louwrentius.com/static/images/pirouter/pirouter01.png"&gt;&lt;img alt="routersetup" src="https://louwrentius.com/static/images/pirouter/pirouter01s.png" /&gt;&lt;/a&gt;
&lt;em&gt;click on the image for a larger version&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Now, what if I told you that you can build exactly the same setup by using &lt;em&gt;only&lt;/em&gt; the single on-board network interface of the Raspberry Pi 4? &lt;/p&gt;
&lt;p&gt;How is that possible? &lt;/p&gt;
&lt;h2&gt;Introducing VLANs&lt;/h2&gt;
&lt;p&gt;Yes, I'm introducing the reader to a technology that &lt;a href="https://en.wikipedia.org/wiki/Virtual_LAN"&gt;exists since the '90s&lt;/a&gt;. It is widely used within businesses and other organisations. &lt;/p&gt;
&lt;p&gt;Because I have a sense that this technology is less well-known in circles outside IT operations, I think it may be an interesting topic to discuss.&lt;/p&gt;
&lt;h2&gt;Understanding VLANs&lt;/h2&gt;
&lt;p&gt;VLAN technology allows you to run different, separate networks over the same, single physical wire and on the same, single switch. This saves a lot on network cabling and the number of physical switches required if you want to operate networks that are separate from each other.&lt;/p&gt;
&lt;p&gt;If you want to run traffic from different networks over the same physical wire or switch, how can you identify those different traffic flows? &lt;/p&gt;
&lt;p&gt;With VLAN technology enabled, such network 'packets' are labeled with a &lt;em&gt;tag&lt;/em&gt;. As the VLAN technology operates at the level of Ethernet, we should not talk about 'packets' but about 'ethernet frames'. The terminology is not important to understand the concept, I think.&lt;/p&gt;
&lt;p&gt;It suffices to understand that there is a tag put in front of the ethernet frame, that tells any device that supports VLANs to which network a &lt;em&gt;frame&lt;/em&gt; and thus a packet belongs. &lt;/p&gt;
&lt;p&gt;This way, network traffic flows, can be distinguished from each other. And those tags are nothing fancy, they are called a VLAN ID and it is just a number between 1 and 4096&lt;sup id="fnref:more"&gt;&lt;a class="footnote-ref" href="#fn:more"&gt;2&lt;/a&gt;&lt;/sup&gt;.&lt;/p&gt;
&lt;h2&gt;Managed switch&lt;/h2&gt;
&lt;p&gt;Now that we understand the concept of VLANs, how do we use it? &lt;/p&gt;
&lt;p&gt;First of all, you need a &lt;em&gt;managed&lt;/em&gt; network switch that supports VLANs.&lt;/p&gt;
&lt;p&gt;The cheapest switch with VLAN support I could find is the TP-LINK TL-SG105E, for around 25 euros or dollars. This is a 5-port switch, but the 8-port version is often only a few euros/dolars more.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;Juan Pedro Paredes in the comments point out that this TP-LINK switch may not be able to handle the large number of ARP requests that may arrive at the port connected to the Internet Modem. Others are quite negative about this switch in the Hacker News discussion (linked below). I'm not sure if Netgear switches, which are near the same price, fare any better.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;A switch like this has a web-based management interface that allows you to configure VLANS on the device. &lt;/p&gt;
&lt;h2&gt;Tagged vs untagged&lt;/h2&gt;
&lt;p&gt;In the context of VLANS, a network switch port can be in two states:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Member of a particular network (VLAN)  (untagged)&lt;/li&gt;
&lt;li&gt;Transporting multiple networks (VLANs) (tagged)&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;If a port is just a member of a VLAN, it just behaves like any other switch port. In this mode, it can &lt;em&gt;obviously&lt;/em&gt; only be a member of one network/VLAN. The VLAN tags are stripped off all network traffic coming out of this port. &lt;/p&gt;
&lt;p&gt;However, a port that is assigned 'tagged' VLAN trafic, just forwarded traffic as-is, including their VLAN tag. &lt;/p&gt;
&lt;p&gt;This is the trick that we use to send network packets from different networks (VLANS) to our Raspberry Pi router over a single port/wire. &lt;/p&gt;
&lt;p&gt;&lt;a href="https://louwrentius.com/static/images/pirouter/pirouter02.png"&gt;&lt;img alt="routersetup" src="https://louwrentius.com/static/images/pirouter/pirouter02s.png" /&gt;&lt;/a&gt;
&lt;em&gt;click on the image for a larger version&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;So let's unpack this picture together, step by step.&lt;/p&gt;
&lt;p&gt;Let's imagine a (return) packet from the Internet arrives at the modem and is sent into switchport 1. &lt;/p&gt;
&lt;p&gt;The switch knows that any traffic on that switch port belongs to VLAN 10. Since this traffic needs to be send towards the Pi Router, it will put a tag on the packet and forwards the packet, including the tag towards the Pi on switch port 2.&lt;/p&gt;
&lt;p&gt;The Pi - in turn -  is configured to work with VLANs just as the switch. The tag on the packet tells the Pi to wich &lt;em&gt;virtual&lt;/em&gt; interface the packet must be send.&lt;/p&gt;
&lt;p&gt;A netplan configuration example to illustrate this setup:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;network&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="n"&gt;version&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="n"&gt;ethernets&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;enp2s0f0&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;
&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="n"&gt;dhcp4&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;no&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="n"&gt;vlans&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;enp2s0f0&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;
&lt;span class="w"&gt;       &lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;
&lt;span class="w"&gt;       &lt;/span&gt;&lt;span class="n"&gt;link&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;enp2s0f0&lt;/span&gt;
&lt;span class="w"&gt;       &lt;/span&gt;&lt;span class="n"&gt;addresses&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;
&lt;span class="w"&gt;         &lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mf"&gt;68.69&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="mf"&gt;70.71&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;24&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fake&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;internet&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;address&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="w"&gt;       &lt;/span&gt;&lt;span class="n"&gt;gateway4&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mf"&gt;68.69&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="mf"&gt;70.1&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fake&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;upstream&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;ISP&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;router&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;enp2s0f0&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;
&lt;span class="w"&gt;       &lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;
&lt;span class="w"&gt;       &lt;/span&gt;&lt;span class="n"&gt;link&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;enp2s0f0&lt;/span&gt;
&lt;span class="w"&gt;       &lt;/span&gt;&lt;span class="n"&gt;addresses&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;
&lt;span class="w"&gt;         &lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mf"&gt;192.168&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="mf"&gt;0.1&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;24&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;internal&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;network&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;address&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;acting&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;as&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;gateway&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;As you can see, the VLAN packets that arrive as tagged packets, are send (without their tags) to a virtual network interface belonging to that particular network. Those virtual network interfaces all share the same physical interface (enp2s0f0). The virtual network interfaces are just the physical interface name with ".(VLAN ID)" added. &lt;/p&gt;
&lt;p&gt;From here on out, you probably understand where this is going: those two virtual network interfaces are basically similar to a setup with two physical network interfaces. So all the routing and NAT that needs to happen, just happens on those two virtual interfaces instead. &lt;/p&gt;
&lt;h2&gt;How to work with VLANs&lt;/h2&gt;
&lt;p&gt;To work with VLANs, you need a &lt;em&gt;managed&lt;/em&gt; switch that supports VLANs. A managed switch has a management interface, often a web-based management interface.&lt;/p&gt;
&lt;p&gt;In this example, I'm using the TP-LINK TL-SG105E switch as an example. 
To get to this page, go to VLAN --&amp;gt; 802.1Q VLAN in the web interface.&lt;/p&gt;
&lt;p&gt;&lt;img alt="vlanconfig" src="https://louwrentius.com/static/images/pirouter/vlanconfig.png" /&gt;&lt;/p&gt;
&lt;p&gt;So from this table we can derive that: &lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Port 1 is an untagged member of VLAN 10&lt;/li&gt;
&lt;li&gt;Port 2 is a tagged member of VLAN 10 and VLAN 20&lt;/li&gt;
&lt;li&gt;Port 3 is an untagged member of VLAN 20&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Please note that it is also recommended to remove ports from VLANs they don't use. So I removed ports 1, 2 and 3 from the default VLAN 1.&lt;/p&gt;
&lt;p&gt;Now, if you have more devices to connect to the internal LAN on this switch, you need to configure the ports to be an untagged member of VLAN 20.&lt;/p&gt;
&lt;h2&gt;Caveats&lt;/h2&gt;
&lt;h3&gt;Bandwidth impact&lt;/h3&gt;
&lt;p&gt;Obviously, if you use a single interface, you only get to use the bandwidth of that sinle interface. In most cases, this is not an issue, as gigabit ethernet is full-duplex: there is physical exclusive wiring for upstream traffic and downstream traffic. &lt;/p&gt;
&lt;p&gt;So you might say that full-duplex gigabit ethernet has a raw throughput capacity of two gigabit/s, although we mostly don't talk about it that way.&lt;/p&gt;
&lt;p&gt;So when you download at 200 Mbit/s, that traffic is ingested over VLAN 10 over the incomming traffic path. It is then sent out over VLAN 20 towards your computer over VLAN 20 using the outgoing path. No problem there.&lt;/p&gt;
&lt;p&gt;If you would also use the Raspberry Pi as a backup server (with an attached external hard drive), the backup traffic and the internet traffic could both 'fight' for bandwidth on the same gigabit link. &lt;/p&gt;
&lt;h3&gt;Impact on gigabit internet&lt;/h3&gt;
&lt;hr&gt;
&lt;p&gt;&lt;strong&gt;Update June 2022&lt;/strong&gt; I was actually able to use full Gigabit internet speed over VLANs, at around 111 MB/s. I made some mistakes during earlier testing.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;You will never get the full gigabit internet network speed if you would build this setup. It will probably max out at ~900 Mbit. (I'm assuming here that you would use x86 hardware as the Pi would not be able to handle firewalling this traffic anyway.)&lt;/em&gt;&lt;/p&gt;
&lt;hr&gt;

&lt;p&gt;This is because most traffic is based on TCP connections and when you download, there is traffic both ways!. The download traffic is the bulk of the traffic, but there is a substantial steady stream of return packets that acknowledges to the sender that traffic has been received (if not, it would trigger a retransmission).&lt;/p&gt;
&lt;p&gt;Remember that in this single-port setup, the Pi uses the same gigabit port to send the return traffic to the internet over VLAN 10 and the download data  towards your home computer over VLAN 20. So the size of the upstream traffic will limit your maximum download performance.  &lt;/p&gt;
&lt;h2&gt;The Raspberry Pi 4 Model B as a router&lt;/h2&gt;
&lt;p&gt;The biggest limitation - which becomes an issue for more and more people - is performance. If you use IPTABLES on Linux for firewalling, in my experience, network throughput drops to a maximum of 650 Mbit/s. &lt;/p&gt;
&lt;p&gt;That's only an issue (first world problems) if you have gigabit internet or an internet speed beyond what the Pi can handle. &lt;/p&gt;
&lt;p&gt;If your internet speed doesn't even come close, this is not an issue at all. &lt;/p&gt;
&lt;p&gt;Maybe the Raspberry Pi 400 or the compute module performs better in this regard as their CPUs are clocked at higher Ghz. &lt;/p&gt;
&lt;h2&gt;Closing words&lt;/h2&gt;
&lt;p&gt;If it makes any sense for you to implement this setup, is only for you to decide. I'm running this kind of setup (using an x86 server) for 10 years as I can't run a second cable from my modem to the room where my router lives. For a more detailed picture of my home network setup, &lt;a href="https://louwrentius.com/my-home-network-setup-based-on-managed-switches-and-vlans.html"&gt;take a look here&lt;/a&gt;. &lt;/p&gt;
&lt;p&gt;Feel free to leave any questions of comments below.&lt;/p&gt;
&lt;p&gt;The hacker news discussion about this article &lt;a href="https://news.ycombinator.com/item?id=28696845"&gt;can be found here&lt;/a&gt;. &lt;/p&gt;
&lt;h2&gt;Route-on-a-stick&lt;/h2&gt;
&lt;p&gt;I learned from the hacker news discussion that a router with just one network interface is called a &lt;a href="https://en.wikipedia.org/wiki/Router_on_a_stick"&gt;router on a stick&lt;/a&gt;.&lt;/p&gt;
&lt;div class="footnote"&gt;
&lt;hr /&gt;
&lt;ol&gt;
&lt;li id="fn:older"&gt;
&lt;p&gt;Older models of the Raspberry Pi are significantly network bandwidth constrained. So much so, that they would not be suitable as Internet routers if your internet speed is above 100Mbit.&amp;#160;&lt;a class="footnote-backref" href="#fnref:older" title="Jump back to footnote 1 in the text"&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id="fn:more"&gt;
&lt;p&gt;most cheap switches can't operate more than 32 ~ 64 VLANs maximum. Only more expensive, enterprise gear can work with the full 4096 VLANS at the same time. However, this is probably not relevant for consumers.&amp;#160;&lt;a class="footnote-backref" href="#fnref:more" title="Jump back to footnote 2 in the text"&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;</content><category term="Networking"/><category term="networking"/></entry><entry><title>My home network setup based on managed switches and VLANs</title><link href="https://louwrentius.com/my-home-network-setup-based-on-managed-switches-and-vlans.html" rel="alternate"/><published>2020-04-10T12:00:00+02:00</published><updated>2020-04-10T12:00:00+02:00</updated><author><name>Louwrentius</name></author><id>tag:louwrentius.com,2020-04-10:/my-home-network-setup-based-on-managed-switches-and-vlans.html</id><summary type="html">&lt;h2&gt;My home networking setup&lt;/h2&gt;
&lt;p&gt;I live in a two story apartment, with on the top floor my utilities closet and my living room. The bottom floor contains a bedroom with all my servers and networking gear. &lt;/p&gt;
&lt;p&gt;So this is my setup (click for a bigger version):&lt;/p&gt;
&lt;p&gt;&lt;a href="https://louwrentius.com/static/images/homenetworkvlan.png"&gt;&lt;img alt="home" src="https://louwrentius.com/static/images/homenetworkvlan.png" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I like to run …&lt;/p&gt;</summary><content type="html">&lt;h2&gt;My home networking setup&lt;/h2&gt;
&lt;p&gt;I live in a two story apartment, with on the top floor my utilities closet and my living room. The bottom floor contains a bedroom with all my servers and networking gear. &lt;/p&gt;
&lt;p&gt;So this is my setup (click for a bigger version):&lt;/p&gt;
&lt;p&gt;&lt;a href="https://louwrentius.com/static/images/homenetworkvlan.png"&gt;&lt;img alt="home" src="https://louwrentius.com/static/images/homenetworkvlan.png" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I like to run my own router but my utilities closed is not the safest place in terms of security and climate. &lt;/p&gt;
&lt;p&gt;By default, most people who run their own home router will use a box with two network interfaces, one connected to the (cable) modem and the other one connected to the home network. &lt;/p&gt;
&lt;p&gt;I could have done the same thing, by running a cable from the modem to my router, and a second cable back up towards my closet (and livingroom). &lt;/p&gt;
&lt;p&gt;However, I didn't want to run multiple cables from my utilities closed to my bedroom downstairs, I saw no need for that: because I can use VLANs. &lt;/p&gt;
&lt;p&gt;The small 8-port switch in the closed is connected with a single (long) cable to the 24-port switch I have in my bedroom downstairs. This switch connects to my router and multiple servers. &lt;/p&gt;
&lt;p&gt;I've setup a trunk between these two switches where my internet traffic flows over 'VLAN 100' and my home network uses 'VLAN 200'. &lt;/p&gt;
&lt;p&gt;The router, an &lt;a href="https://n40l.fandom.com/wiki/HP_MicroServer_N40L_Wiki"&gt;HP N40L&lt;/a&gt;, has only a single network interface. I just expose the two VLANS as 'tagged' and let the router route traffic between the two VLANS. No need for a second interface (as many home setups do).&lt;/p&gt;
&lt;p&gt;So in my setup there are two trunks, one between the two switches and the other one between the bedroom switch and my router. All other devices are connected to untagged network ports, in their appropriate VLAN.&lt;/p&gt;
&lt;p&gt;The small switch in the closet is responsible for carrying my home network to the switch in my living room. &lt;/p&gt;
&lt;p&gt;The raspberry pi connects to my smart meter to collect information about my power and gas usage. &lt;/p&gt;</content><category term="Networking"/><category term="Networking"/></entry><entry><title>Setup a VPN on your iPhone with OpenVPN and Linux</title><link href="https://louwrentius.com/setup-a-vpn-on-your-iphone-with-openvpn-and-linux.html" rel="alternate"/><published>2018-06-18T04:00:00+02:00</published><updated>2018-06-18T04:00:00+02:00</updated><author><name>Louwrentius</name></author><id>tag:louwrentius.com,2018-06-18:/setup-a-vpn-on-your-iphone-with-openvpn-and-linux.html</id><summary type="html">&lt;hr&gt;

&lt;p&gt;⚠️ 🚨 Update 2024 🚨⚠️&lt;/p&gt;
&lt;p&gt;I'm not using OpenVPN anymore for my VPN needs and this article is considered unmaintained.
It's stronly recommended not to use this tutorial and find up-to-date documentation. 
I also have no plans to update this blogpost in the future.&lt;/p&gt;
&lt;hr&gt;

&lt;p&gt;&lt;strong&gt;[Update 2018]&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;This article has been substantially updated since …&lt;/p&gt;</summary><content type="html">&lt;hr&gt;

&lt;p&gt;⚠️ 🚨 Update 2024 🚨⚠️&lt;/p&gt;
&lt;p&gt;I'm not using OpenVPN anymore for my VPN needs and this article is considered unmaintained.
It's stronly recommended not to use this tutorial and find up-to-date documentation. 
I also have no plans to update this blogpost in the future.&lt;/p&gt;
&lt;hr&gt;

&lt;p&gt;&lt;strong&gt;[Update 2018]&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;This article has been substantially updated since it was published in 2013.&lt;/p&gt;
&lt;h3&gt;Introduction&lt;/h3&gt;
&lt;p&gt;In this article, I will show you how to setup a Linux-based &lt;a href="https://openvpn.net/index.php/open-source.html"&gt;OpenVPN&lt;/a&gt; server. Once this server is up and running, I'll show you how to setup your iOS devices, such as your iPhone or iPad so that they can connect with your new VPN server.&lt;/p&gt;
&lt;p&gt;The goal of this effort is to encapsulate all internet traffic through your VPN connection so no matter where you are, nobody can monitor which sites you visit and what you do. This is ideal if you have to visit the internet through untrusted internet sources like public Wi-Fi.&lt;/p&gt;
&lt;p&gt;Some typical scenarios would be: &lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;you run an OpenVPN service on your Linux-based home router directly&lt;/li&gt;
&lt;li&gt;you run an OpenVPN service on a device behind your home router using portforwarding (like a Raspberry Pi)&lt;/li&gt;
&lt;li&gt;you run an OpenVPN service on a VPS hosted by one of many cloud service providers&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Your iOS devices will be running &lt;a href="https://itunes.apple.com/us/app/openvpn-connect/id590379981"&gt;OpenVPN Connect&lt;/a&gt;, a free application found in the App store. &lt;/p&gt;
&lt;p&gt;&lt;img alt="screenshot" src="https://louwrentius.com/static/images/openvpn.png" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;A note on other platforms:&lt;/strong&gt; Although this tutorial is focussed on iOS devices, your new OpenVPN-based VPN server will support any client OS, may it be Windows, MacOS, Android or Linux. Configuration of these other clients is out-of-scope for this article.&lt;/p&gt;
&lt;p&gt;This tutorial is based on &lt;a href="https://openvpn.net/index.php/open-source.html"&gt;OpenVPN&lt;/a&gt;, an open-source product. The company behind OpenVPN also offers &lt;a href="https://www.privatetunnel.com"&gt;VPN services&lt;/a&gt; for a price per month. If you find the effort of setting up your own server too much of a hassle, you could look into &lt;a href="https://www.privatetunnel.com"&gt;their service&lt;/a&gt;. Please note that I have never used this service and cannot vouch for it.&lt;/p&gt;
&lt;p&gt;This is a brief overview of all the steps you will need to take in order to have a fully functional setup, including configuration of the clients:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Install a Linux server (out-of-scope)&lt;/li&gt;
&lt;li&gt;Install the OpenVPN software&lt;/li&gt;
&lt;li&gt;Setup the Certificate Authority&lt;/li&gt;
&lt;li&gt;Generate the server certificate&lt;/li&gt;
&lt;li&gt;Configure the OpenVPN server configuration&lt;/li&gt;
&lt;li&gt;Configure the firewall on your Linux server&lt;/li&gt;
&lt;li&gt;Generate certificates for every client (iPhone, iPad, and so on)&lt;/li&gt;
&lt;li&gt;Copy the client configuration to your devices&lt;/li&gt;
&lt;li&gt;Test your clients&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;How It Works&lt;/h3&gt;
&lt;p&gt;OpenVPN is an SSL-based VPN solution. SSL-based VPNs are very reliable because if you set it up properly, you will never be blocked by any firewall as long as TCP-port 443 is accessible. By default, OpenVPN uses UDP as a transport at port 1194, but you can switch to TCP-port 443 to increase the chance that your traffic will not be blocked at the cost of a little bit more bandwidth usage.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Authentication&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Authentication is based on public/private key cryptography. The OpenVPN server is similar to an HTTPS server. The biggest difference is that your device doesn't use a username/password combination for authentication, but a certificate. This certificate is stored within the client configuration file.&lt;/p&gt;
&lt;p&gt;So before you can configure and start your OpenVPN service, you need to setup a Certificate Authority (CA). With the CA you can create the server certificate for your OpenVPN server and after that's done, generate all client certificates.&lt;/p&gt;
&lt;h3&gt;OpenVPN installation&lt;/h3&gt;
&lt;p&gt;OpenVPN is available on most common Linux Distros by default. apt-get install openvpn for any Debian or Ubuntu version is all you need to install OpenVPN. &lt;/p&gt;
&lt;p&gt;Or take a look &lt;a href="http://openvpn.net/index.php/open-source/documentation/howto.html#install"&gt;here&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I have never tried it out, but you can try and take a look at an &lt;a href="https://github.com/Nyr/openvpn-install"&gt;OpenVPN install script&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;This script seems to automate a lot of steps, like firewall configuration, certificate generation, etc.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Tip&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;It's out-of-scope for this tutorial, but you should make sure that you keep your OpenVPN software &lt;em&gt;up-to-date&lt;/em&gt;, in case security vulnerabilities are discovered in OpenVPN in the future.&lt;/p&gt;
&lt;h3&gt;Security&lt;/h3&gt;
&lt;p&gt;I'm creating this tutorial on an older system, with less secure default configuration settings for both the Certificate Authority as the OpenVPN server itself. The settings I use in this tutorial are based on the steps in &lt;a href="https://blog.g3rt.nl/openvpn-security-tips.html"&gt;this blog&lt;/a&gt;. &lt;/p&gt;
&lt;p&gt;Notable improvements:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;AES256 for encryption&lt;/li&gt;
&lt;li&gt;2048 bit key sizes over 1024 bit keys&lt;/li&gt;
&lt;li&gt;SHA256 over sha1/md5&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Performance&lt;/h3&gt;
&lt;p&gt;I did some performance tests and got around 40-50 Mbs per iOS client.
I believe that the bottleneck lies with my old HP Microserver N40L with its relatively weak CPU.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Traffic Shaping&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;If you want to limit how much bandwidth a client is allowed to use, I recommend to use &lt;a href="https://serverfault.com/questions/777875/how-to-do-traffic-shaping-rate-limiting-with-tc-per-openvpn-client"&gt;this tutorial&lt;/a&gt;. I have tried it out and it works perfectly.&lt;/p&gt;
&lt;h3&gt;Creating a certificate authority.&lt;/h3&gt;
&lt;p&gt;&lt;em&gt;For unbuntu&lt;/em&gt;: install the package "easy-rsa" and use the 'make-cadir' command instead of the setup instructions below. &lt;/p&gt;
&lt;p&gt;I assume that you will setup your OpenVPN configuration in /etc/openvpn.
Before you can setup the server configuration, you need to create a certificate authority. I used the folder /etc/openvpn/easy-rsa as the location for my CA. &lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;mkdir /etc/openvpn/easy-rsa
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;We start with copying all these files to this new directory:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;cp -R /usr/share/doc/openvpn/examples/easy-rsa/2.0* /etc/openvpn/easy-rsa
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Please note that depending on your Linux flavour, these files may be found at some other path.&lt;/p&gt;
&lt;p&gt;Next, we cd into the destination directory. &lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;cd /etc/openvpn/easy-rsa
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Now, open the 'vars' file with your favorite text editor.
The following instructions are straight from the &lt;a href="http://openvpn.net/index.php/open-source/documentation/howto.html#pki"&gt;OpenVPN howto&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;You should change all the values to ones that apply to you (obviously).&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;export KEY_COUNTRY=&amp;quot;US&amp;quot;
export KEY_PROVINCE=&amp;quot;California&amp;quot;
export KEY_CITY=&amp;quot;San Fransisco&amp;quot;
export KEY_ORG=&amp;quot;My Company&amp;quot;
export KEY_EMAIL=&amp;quot;my@mail.com&amp;quot;
export KEY_CN=server
export KEY_NAME=server
export KEY_OU=home
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Change the KEY_SIZE parameter:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;export KEY_SIZE=2048
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;How long would you like your certificates to be valid (10 years?)&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;export CA_EXPIRE=3650
export KEY_EXPIRE=3650
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Then I had to copy openssl-1.0.0.cnf to openssl.cnf because the 'vars' script complained that it couldn't find the latter file.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;cp openssl-1.0.0.cnf openssl.cnf
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Notice&lt;/strong&gt; I went through these steps on an older Linux installation. I had to edit the file &lt;em&gt;/etc/openvpn/easy-rsa/pkitool&lt;/em&gt; and changed all occurrences of &lt;em&gt;'sha1'&lt;/em&gt; to &lt;em&gt;'sha256'&lt;/em&gt;. &lt;/p&gt;
&lt;p&gt;Now we 'source' var and run two additional commands that actually generate the certificate authority. Notice the dot before ./vars.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;. ./vars
./clean-all
./build-ca
./build-dh
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;You will have to confirm the values or change them if necessary.&lt;/p&gt;
&lt;p&gt;Now we have a certificate authority and we can create new certificates that will be signed by this authority. &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;WARNING:&lt;/strong&gt; be extremely careful with all key files, they should be kept private.&lt;/p&gt;
&lt;p&gt;I would recommend performing these commands:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;chown -R root:root /etc/openvpn 
chmod -R 700 /etc/openvpn
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;By default, OpenVPN runs as root. With these commands, only the root user will be able to access the keys. If you don't run OpenVPN as root, you must select the appropriate user for the first command. See also &lt;a href="https://community.openvpn.net/openvpn/wiki/UnprivilegedUser"&gt;this article&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;Creating the Server Certificate&lt;/h3&gt;
&lt;p&gt;We create the server certificate:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;./build-key-server server
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;It's up to you to come up with an alternative for 'server'. This is the file name under which the key files and certificates are stored. &lt;/p&gt;
&lt;p&gt;All files that are generated can be found in the '/etc/openvpn/easy-rsa/keys' directory. This is just a flat folder with both the server and client keys.&lt;/p&gt;
&lt;h3&gt;Creating the optional TLS-AUTH Certificate&lt;/h3&gt;
&lt;p&gt;This step is optional but it doesn't take much effort and it seems to add an additional security layer at no significant cost. In this step we create an additional secret key that is shared with both the server and the clients.&lt;/p&gt;
&lt;p&gt;The following steps are based on &lt;a href="https://community.openvpn.net/openvpn/wiki/Hardening"&gt;this article&lt;/a&gt; (use of -tls-auth).&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;cd /etc/openvpn/easy-rsa/keys
openvpn --genkey --secret ta.key
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;When we are going to create the server configuration, we will reference this key file.&lt;/p&gt;
&lt;h3&gt;Creating the Client Certificate&lt;/h3&gt;
&lt;p&gt;Now that we have a server certificate, we are going to create a certificate for our iPhone (or any other iOS device).&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;./build-key iphone
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Answer the questions with the defaults. Don't forget to answer these questions:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;Sign the certificate? [y/n]:y
1 out of 1 certificate requests certified, commit? [y/n]y
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;So now we have everything in place to start creating an OpenVPN configuration.
We must create a configuration for the server and the client. Those configurations are based on the examples that can be find in /usr/share/doc/openvpn/examples/.&lt;/p&gt;
&lt;h3&gt;Example Server configuration&lt;/h3&gt;
&lt;p&gt;This is my server configuration which is operational. It is stored in /etc/openvpn/openvpn.conf&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;dev tun2
tls-server
cipher AES-256-CBC
auth SHA256
remote-cert-tls client
dh easy-rsa/keys/dh2048pem
ca easy-rsa/keys/ca.crt
cert easy-rsa/keys/server.crt
key easy-rsa/keys/server.key
tls-auth easy-rsa/keys/ta.key
server 10.0.0.0 255.255.255.0
log /var/log/openvpn.log
script-security 2
route-up &amp;quot;/sbin/ifconfig tun2 up&amp;quot;
port 443
proto tcp-server
push &amp;quot;redirect-gateway def1 bypass-dhcp&amp;quot;
push &amp;quot;dhcp-option DNS 8.8.8.8&amp;quot;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;I believe you should be able to use this configuration as-is. Depending on your local IP-addresses within your own network, you may have to change the &lt;em&gt;server&lt;/em&gt; section.&lt;/p&gt;
&lt;p&gt;I use TCP-port 443 as this destination port is almost never blocked as blocking this port would break most internet connectivity. (The downside is that I can no longer host any secure web site on this IP-address). &lt;/p&gt;
&lt;p&gt;The OpenVPN service will provide your client with an IP-address within the address range configured in the 'server' section. &lt;/p&gt;
&lt;p&gt;Change any parameters if required and then start or restart the OpenVPN service:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;/etc/init.d/openvpn restart
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Make sure that the server is running properly in /var/log/openvpn.log&lt;/p&gt;
&lt;p&gt;If you want to use your VPN to browse the internet, we still need to configure a basic firewall setup. &lt;/p&gt;
&lt;p&gt;I'm assuming that you already have some kind of IPtables-based firewall running. 
Configuring a Linux firewall is out-of-scope for this article. I will only discuss the changes you may need to make for the OpenVPN service to operate properly.&lt;/p&gt;
&lt;p&gt;You will need to accept traffic to TCP port 443 on the interface connected to the internet. &lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;iptables -A INPUT -p tcp -m tcp --dport 443 -j ACCEPT
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;If your OpenVPN server is behind a router/firewall, you need to configure port-forwarding on that router/firewall. How to do so is out-of-scope for this article, as it is different for different devices.&lt;/p&gt;
&lt;p&gt;Assuming that you will - for example - use the 10.0.0.0/24 network for VPN clients such as your iPhone, you must also create a NAT rule so VPN clients can use the IP-address of the Linux server to access Internet. &lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;iptables -t nat -A POSTROUTING -s &amp;quot;10.0.0.0/24&amp;quot; -o &amp;quot;eth0&amp;quot; -j MASQUERADE
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Please note that you must change eth0 with the name of the appropriate interface that connects to the internet. Change the IP-address range according to your own situation. It should not conflict with your existing network.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;iptables -A FORWARD -p tcp -s 10.0.0.0/24 -d 0.0.0.0/0 -j ACCEPT
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Please note that I haven't tested these rules, as I have a different setup. But this should be sufficient. And make sure that forwarding is enabled like this:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;echo 1 &amp;gt; /proc/sys/net/ipv4/ip_forward
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h3&gt;Example Client configuration&lt;/h3&gt;
&lt;p&gt;Most OpenVPN clients can automatically import files with the .ovpn file extension. A typical configuration file is something like 'iphone.ovpn'. &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Warning:&lt;/strong&gt; the .ovpn files will contain the certificate used by your iPhone/iPad to authenticate against your OpenVPN server. Be very carefull where you store this file. Anyone that is able to obtain a copy of this file, will be able to connect to your VPN server.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://gist.github.com/renatolfc/f6c9e2a5bd6503005676"&gt;This is an example configuration file&lt;/a&gt;, but we are not going to create it by hand, it's too much work.&lt;/p&gt;
&lt;p&gt;What you will notice from this example is that the .ovpn file contains both the client configuration and all the required certificates:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;the CA root certificate&lt;/li&gt;
&lt;li&gt;the server certificate to validate the server&lt;/li&gt;
&lt;li&gt;the client private certificate &lt;/li&gt;
&lt;li&gt;the TLS-AUTH certificate (an optional extra security measure)&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;Create a client configuration file (.ovpn) with a script&lt;/h3&gt;
&lt;p&gt;You can create your client configuration file manually but that is a lot of work. Because you need to append all the certificates to a single file, that also contains the configuration settings. &lt;/p&gt;
&lt;p&gt;So we will use a script to setup the client configuration. &lt;/p&gt;
&lt;p&gt;First we are going to create a folder where our client configuration files will be stored.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;mkdir /etc/openvpn/clientconfig
chmod 700 /etc/openvpn/clientconfig
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Now we will download the script and the accompanying configuration template file. Notice that the links may wrap.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;cd /etc/openvpn
wget https://raw.githubusercontent.com/louwrentius/openvpntutorial/master/create-client-config.sh
wget https://raw.githubusercontent.com/louwrentius/openvpntutorial/master/client-config-template
chmod +x create-client-config.sh
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Please note that you first need to create the certificates for your devices before you can generate a configuration file. So please go back to that step if you need to.&lt;/p&gt;
&lt;p&gt;Also take note of the name you have used for your devices. You can always take a look in /etc/openvpn/easy-rsa/keys to see how your devices are called.&lt;/p&gt;
&lt;p&gt;Now, edit this client-config-template and change the appropriate values where required. You may probably only need to change the first line:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;remote &amp;lt;your server DNS address or IP address&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Now you are ready to run the script and generate the config file for your device.&lt;/p&gt;
&lt;p&gt;When you run this script, a configuration file is generated and placed in to the folder /etc/openvpn/clientconfig. &lt;/p&gt;
&lt;p&gt;The script just puts the client configuration template and all required certificates in one file. This is how you use it:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;./create-client-config.sh iPhone
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Some output you will notice when running the script:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;user@server:/etc/openvpn# ./create-client-config.sh iphone
Client&amp;#39;s cert found: /etc/openvpn/easy-rsa/keys/iphone
Client&amp;#39;s Private Key found: /etc/openvpn/easy-rsa/keys/iphone.key
CA public Key found: /etc/openvpn/easy-rsa/keys/ca.crt
tls-auth Private Key found: /etc/openvpn/easy-rsa/keys/ta.key
Done! /etc/openvpn/clientconfig/iphone.ovpn Successfully Created.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;You should now find a file called 'iphone.ovpn' in the directory /etc/openvpn/clientconfig.&lt;/p&gt;
&lt;p&gt;We are almost there. We just need to copy this file to your iOS device. &lt;/p&gt;
&lt;p&gt;You have three options:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Use iCloud Drive&lt;/li&gt;
&lt;li&gt;Use iTunes&lt;/li&gt;
&lt;li&gt;Use email (obviously insecure and not discussed)&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;Setting up your iPhone or iPad with iCloud Drive&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;First install the &lt;a href="https://itunes.apple.com/us/app/openvpn-connect/id590379981"&gt;OpenVPN Connect&lt;/a&gt; application if you haven't done so.&lt;/li&gt;
&lt;li&gt;Copy the .ovpn file from your OpenVPN server to your iCloud Drive.&lt;/li&gt;
&lt;li&gt;Take your device and use the 'files' browser to navigate within your iCloud drive to the .ovpn file you just copied.&lt;/li&gt;
&lt;li&gt;Tap on the file to download and open it.&lt;/li&gt;
&lt;li&gt;Now comes the tricky part: press the share symbol&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;img alt="step 1" src="https://louwrentius.com/static/images/openvpnstep1.png" /&gt;&lt;/p&gt;
&lt;p&gt;Open the file with the OpenVPN application on your iOS device:&lt;/p&gt;
&lt;p&gt;&lt;img alt="step 2" src="https://louwrentius.com/static/images/openvpnstep2.png" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt="step 3" src="https://louwrentius.com/static/images/openvpnstep3.png" /&gt;&lt;/p&gt;
&lt;p&gt;When you get the question "OpenVPN would like to Add VPN Configurations", choose 'Allow'. &lt;/p&gt;
&lt;p&gt;Continue with the step 'Test your iOS device'.&lt;/p&gt;
&lt;p&gt;If the OpenVPN Connect client doesn't import the file, remove the application from the device and re-install it. (This is what I had to do on my iPad).&lt;/p&gt;
&lt;h3&gt;Setting up your iPhone or iPad with iTunes&lt;/h3&gt;
&lt;p&gt;You can skip this step if you used iCloud Drive to copy the .ovpn profile to your device. &lt;/p&gt;
&lt;p&gt;You need to get the following files on your iOS device:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;iphone.ovpn
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Copy this file from your OpenVPN server to the computer running iTunes.
Then connect your device to iTunes with a cable.  &lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Open iTunes&lt;/li&gt;
&lt;li&gt;Select your device at the top right&lt;/li&gt;
&lt;li&gt;Go to the Apps tab&lt;/li&gt;
&lt;li&gt;Scroll to the file sharing section&lt;/li&gt;
&lt;li&gt;Select the OpenVPN application&lt;/li&gt;
&lt;li&gt;Add the iphone.ovpn &lt;/li&gt;
&lt;li&gt;Sync your device&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;Test your iOS device&lt;/h3&gt;
&lt;p&gt;Open the OpenVPN client. You will see a notice that a new configuration has been
imported and you need to accept this configuration. &lt;/p&gt;
&lt;p&gt;As it might not work straight away, you need to monitor /var/log/openvpn.log on the server to watch for any errors. &lt;/p&gt;
&lt;p&gt;Now try to connect and enjoy.&lt;/p&gt;
&lt;h3&gt;Conclusion&lt;/h3&gt;
&lt;p&gt;You should be able to keep your VPN enabled at all times because battery usage overhead should be minimal. If you are unable to connect to your VPN when you are at home behind your own firewall, you need to check your firewall settings.&lt;/p&gt;
&lt;p&gt;Updated 20130123 with keepalive option.
Updated 20130801 with extra server push options for traffic redirection and DNS configuration
Updated 20180618 as substantial rewrite of the original outdated article.&lt;/p&gt;</content><category term="Networking"/></entry><entry><title>Using InfiniBand for cheap and fast point-to-point Networking</title><link href="https://louwrentius.com/using-infiniband-for-cheap-and-fast-point-to-point-networking.html" rel="alternate"/><published>2017-03-25T12:00:00+01:00</published><updated>2017-03-25T12:00:00+01:00</updated><author><name>Louwrentius</name></author><id>tag:louwrentius.com,2017-03-25:/using-infiniband-for-cheap-and-fast-point-to-point-networking.html</id><summary type="html">&lt;p&gt;InfiniBand networking is quite awesome. It's mainly used for two reasons:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;low latency&lt;/li&gt;
&lt;li&gt;high bandwidth&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;As a &lt;em&gt;home user&lt;/em&gt;, I'm mainly interested in setting up a high bandwidth link between two servers. &lt;/p&gt;
&lt;p&gt;I was using quad-port network cards with &lt;a href="https://louwrentius.com/achieving-450-mbs-network-file-transfers-using-linux-bonding.html"&gt;Linux Bonding&lt;/a&gt;, but this solution has some downsides:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;you can only …&lt;/li&gt;&lt;/ol&gt;</summary><content type="html">&lt;p&gt;InfiniBand networking is quite awesome. It's mainly used for two reasons:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;low latency&lt;/li&gt;
&lt;li&gt;high bandwidth&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;As a &lt;em&gt;home user&lt;/em&gt;, I'm mainly interested in setting up a high bandwidth link between two servers. &lt;/p&gt;
&lt;p&gt;I was using quad-port network cards with &lt;a href="https://louwrentius.com/achieving-450-mbs-network-file-transfers-using-linux-bonding.html"&gt;Linux Bonding&lt;/a&gt;, but this solution has some downsides:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;you can only go to 4 Gbit with Linux bonding (or you need more ports)&lt;/li&gt;
&lt;li&gt;you need a lot of cabling&lt;/li&gt;
&lt;li&gt;it is similar in price as InfiniBand&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;So I've decided to take a gamble on some InfiniBand gear. You only need InfiniBand PCIe network cards and a cable. &lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;1 x SFF-8470 CX4 cable                                              $16
2 x MELLANOX DUAL-PORT INFINIBAND HOST CHANNEL ADAPTER MHGA28-XTC   $25
                                                            Total:  $66
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;img alt="view of installed infiniband card and cable" src="https://louwrentius.com/images/nano/backside.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;I find $66 quite cheap for &lt;strong&gt;20 Gbit&lt;/strong&gt; networking. Regular 10Gbit Ethernet networking is often still more expensive that using older InfiniBand cards.&lt;/p&gt;
&lt;p&gt;InfiniBand is similar to Ethernet, you can run your own protocol over it (for lower latency) but you can use IP over InfiniBand. The InfiniBand card will just show up as a regular network device (one per port). &lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;ib0 Link encap:UNSPEC HWaddr 80-00-04-04-FE-80-00-00-00-00-00-00-00-00-00-00  
      inet addr:10.0.2.3  Bcast:10.0.2.255  Mask:255.255.255.0
      inet6 addr: fe80::202:c902:29:8e01/64 Scope:Link
      UP BROADCAST RUNNING MULTICAST  MTU:65520  Metric:1
      RX packets:7988691 errors:0 dropped:0 overruns:0 frame:0
      TX packets:17853128 errors:0 dropped:10 overruns:0 carrier:0
      collisions:0 txqueuelen:256 
      RX bytes:590717840 (563.3 MiB)  TX bytes:1074521257501 (1000.7 GiB)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h2&gt;Configuration&lt;/h2&gt;
&lt;p&gt;I've followed &lt;a href="https://pkg-ofed.alioth.debian.org/howto/infiniband-howto-4.html"&gt;these&lt;/a&gt; instructions to get IP over InfiniBand working.&lt;/p&gt;
&lt;h3&gt;Modules&lt;/h3&gt;
&lt;p&gt;First, you need to assure the following modules are loaded at a minimum:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;ib_mthca
ib_ipoib
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;I only had to add the ib_ipoib module to /etc/modules. As soon as this module is loaded, you will notice you have some ibX interfaces available which can be configured like regular ethernet cards&lt;/p&gt;
&lt;h3&gt;Subnet manager&lt;/h3&gt;
&lt;p&gt;In addition to loading the modules, you also need a &lt;em&gt;subnet manager&lt;/em&gt;. You just need to install it like this:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;apt-get install opensm
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;This service needs to run on just one of the endpoints.&lt;/p&gt;
&lt;h3&gt;Link status&lt;/h3&gt;
&lt;p&gt;if you want you can check the link status of your InfiniBand connection like this:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;# ibstat
CA &amp;#39;mthca0&amp;#39;
    CA type: MT25208
    Number of ports: 2
    Firmware version: 5.3.0
    Hardware version: 20
    Node GUID: 0x0002c90200298e00
    System image GUID: 0x0002c90200298e03
    Port 1:
        State: Active
        Physical state: LinkUp
        Rate: 20
        Base lid: 1
        LMC: 0
        SM lid: 2
        Capability mask: 0x02510a68
        Port GUID: 0x0002c90200298e01
        Link layer: InfiniBand
    Port 2:
        State: Down
        Physical state: Polling
        Rate: 10
        Base lid: 0
        LMC: 0
        SM lid: 0
        Capability mask: 0x02510a68
        Port GUID: 0x0002c90200298e02
        Link layer: InfiniBand
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h3&gt;Set mode and MTU&lt;/h3&gt;
&lt;p&gt;Since my systems run Debian Linux, I've configured /etc/network/interfaces like this:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;auto ib0
iface ib0 inet static
    address 10.0.2.2
    netmask 255.255.255.0
    mtu 65520
    pre-up echo connected &amp;gt; /sys/class/net/ib0/mode
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Please take note of the 'mode' setting. The 'datagram' mode gave abysmal network performance (&amp;lt; Gigabit). The 'connected' mode made everything perform acceptable. &lt;/p&gt;
&lt;p&gt;The MTU setting of 65520 improved performance by another 30 percent.&lt;/p&gt;
&lt;h2&gt;Performance&lt;/h2&gt;
&lt;p&gt;I've tested the card on two systems based on the Supermicro X9SCM-F motherboard.
Using these systems, I was able to achieve file transfer speeds up to 750 MB (Megabytes) per second or about 6.5 Gbit as measured with iperf.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;~# iperf -c 10.0.2.2
------------------------------------------------------------
Client connecting to 10.0.2.2, TCP port 5001
TCP window size: 2.50 MByte (default)
------------------------------------------------------------
[  3] local 10.0.2.3 port 40098 connected with 10.0.2.2 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-10.0 sec  7.49 GBytes  6.43 Gbits/sec
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Similar test with netcat and dd:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;~# dd if=/dev/zero bs=1M count=100000 | nc 10.0.2.2 1234
100000+0 records in
100000+0 records out
104857600000 bytes (105 GB) copied, 128.882 s, 814 MB/s
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Testing was done on Debian Jessie. &lt;/p&gt;
&lt;p&gt;During earlier testing, I've also used these cards in HP Micro Proliant G8 servers. On those servers, I was running Ubuntu 16.04 LTS. &lt;/p&gt;
&lt;p&gt;As tested on Ubuntu with the HP Microserver:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;------------------------------------------------------------
Client connecting to 10.0.4.3, TCP port 5001
TCP window size: 4.00 MByte (default)
------------------------------------------------------------
[  5] local 10.0.4.1 port 52572 connected with 10.0.4.3 port 5001
[  4] local 10.0.4.1 port 5001 connected with 10.0.4.3 port 44124
[ ID] Interval       Transfer     Bandwidth
[  5]  0.0-60.0 sec  71.9 GBytes  10.3 Gbits/sec
[  4]  0.0-60.0 sec  72.2 GBytes  10.3 Gbits/sec
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Using these systems, I was able eventually able to achieve 15 Gbit as measured with iperf, although I have no 'console screenshot' from it. &lt;/p&gt;
&lt;h2&gt;Closing words&lt;/h2&gt;
&lt;p&gt;IP over InfiniBand seems to be a nice way to get high-performance networking on the cheap. The main downside is that when using IP over IB, CPU usage will be high. &lt;/p&gt;
&lt;p&gt;Another thing I have not researched, but could be of interest is running NFS or other protocols directly over InfiniBand using RDMA, so you would bypass the overhead of IP.&lt;/p&gt;</content><category term="Networking"/></entry><entry><title>Creating configuration backups of HP procurve switches</title><link href="https://louwrentius.com/creating-configuration-backups-of-hp-procurve-switches.html" rel="alternate"/><published>2015-01-12T12:00:00+01:00</published><updated>2015-01-12T12:00:00+01:00</updated><author><name>Louwrentius</name></author><id>tag:louwrentius.com,2015-01-12:/creating-configuration-backups-of-hp-procurve-switches.html</id><summary type="html">&lt;p&gt;I've created a tool called &lt;a href="https://github.com/louwrentius/procurve-watch"&gt;procurve-watch&lt;/a&gt;. It creates a backup of the running switch configuration through secure shell (using scp). &lt;/p&gt;
&lt;p&gt;It also diffs backed up configurations against older versions, in order to keep track of changes. If you run the script from cron every hour or so, you will be …&lt;/p&gt;</summary><content type="html">&lt;p&gt;I've created a tool called &lt;a href="https://github.com/louwrentius/procurve-watch"&gt;procurve-watch&lt;/a&gt;. It creates a backup of the running switch configuration through secure shell (using scp). &lt;/p&gt;
&lt;p&gt;It also diffs backed up configurations against older versions, in order to keep track of changes. If you run the script from cron every hour or so, you will be notified by email of any (running) configuration changes.&lt;/p&gt;
&lt;p&gt;The tool can backup hundreds of switches in seconds as it is running the configuration copy in parallel. &lt;/p&gt;
&lt;p&gt;A tool like &lt;a href="http://www.shrubbery.net/rancid/"&gt;Rancid&lt;/a&gt; may actually be the best choice for this task, but it didn't work. The latest version of Rancid doesn't support HP Procurve switches (yet) and older versions created backups containing garbled characters.&lt;/p&gt;
&lt;p&gt;I've &lt;a href="https://github.com/louwrentius/procurve-watch"&gt;released it on github&lt;/a&gt;, check it out and let me know if it works for you and you have suggestions to improve it further.&lt;/p&gt;</content><category term="Networking"/><category term="Networking"/></entry><entry><title>Configuring, attacking and securing VRRP on Linux</title><link href="https://louwrentius.com/configuring-attacking-and-securing-vrrp-on-linux.html" rel="alternate"/><published>2015-01-02T12:00:00+01:00</published><updated>2015-01-02T12:00:00+01:00</updated><author><name>Louwrentius</name></author><id>tag:louwrentius.com,2015-01-02:/configuring-attacking-and-securing-vrrp-on-linux.html</id><summary type="html">&lt;p&gt;The VRRP or Virtual Router Redundancy Protocol helps you create a reliable network by using multiple routers in an active/passive configuration. If the primary router fails, the backup router takes over almost seamlessly. &lt;/p&gt;
&lt;p&gt;This is how VRRP works:&lt;/p&gt;
&lt;p&gt;&lt;img alt="vrrp" src="https://louwrentius.com/static/images/vrrp.png" /&gt;&lt;/p&gt;
&lt;p&gt;Clients connect to a virtual IP-address. It is called virtual because …&lt;/p&gt;</summary><content type="html">&lt;p&gt;The VRRP or Virtual Router Redundancy Protocol helps you create a reliable network by using multiple routers in an active/passive configuration. If the primary router fails, the backup router takes over almost seamlessly. &lt;/p&gt;
&lt;p&gt;This is how VRRP works:&lt;/p&gt;
&lt;p&gt;&lt;img alt="vrrp" src="https://louwrentius.com/static/images/vrrp.png" /&gt;&lt;/p&gt;
&lt;p&gt;Clients connect to a virtual IP-address. It is called virtual because the IP-address is not hard-coded to a particular interface on any of the routers. &lt;/p&gt;
&lt;p&gt;If a client asks for the MAC-address that is tied to the virtual IP, the master will respond with its MAC-address. If the master dies, the backup router will notice and start responding to ARP-requests.&lt;/p&gt;
&lt;p&gt;Let's take a look at the ARP table on the client to illustrate what is happening.&lt;/p&gt;
&lt;p&gt;Master is active:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;(10.0.1.140) at 0:c:29:a7:7d:f2 on en0 ifscope [ethernet]
(10.0.1.141) at 0:c:29:a7:7d:f2 on en0 ifscope [ethernet]
(10.0.1.142) at 0:c:29:b2:5b:7c on en0 ifscope [ethernet]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Master has failed and backup has taken over:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;(10.0.1.140) at 0:c:29:b2:5b:7c on en0 ifscope [ethernet]
(10.0.1.141) at 0:c:29:a7:7d:f2 on en0 ifscope [ethernet]
(10.0.1.142) at 0:c:29:b2:5b:7c on en0 ifscope [ethernet]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Notice how the MAC-address of the virtual IP (.140) is now that of the backup router.&lt;/p&gt;
&lt;h3&gt;Configuring VRRP on Linux&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;configure static IP-addresses on the primary and backup router. Do not configure the virtual IP on any of the interfaces. In my test environment, I used 10.0.1.141 for the master and 10.0.1.142 for the backup router.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Because the virtual IP-address is not configured on any of the interfaces, Linux will not reply to any packets destined for this IP. This behaviour needs to be changed or VRRP will not work. Edit /etc/sysctl.conf and add this line:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;net.ipv4.ip_nonlocal_bind=1
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Run this command to active this setting:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;sysctl -p
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Install Keepalived&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;apt-get install keepalived
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Sample configuration of /etc/keepalived/keepalived.conf for MASTER&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;vrrp_instance VI_1 {
    interface eth0
    state MASTER
    virtual_router_id 51
    priority 101

    authentication {
        auth_type AH
        auth_pass monkey
    }

    virtual_ipaddress {
        10.0.1.140
    }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Sample configuration of /etc/keepalived/keepalived.conf for SLAVE&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;vrrp_instance VI_1 {
    interface eth0
    state BACKUP
    virtual_router_id 51
    priority 100

    authentication {
        auth_type AH
        auth_pass monkey
    }

    virtual_ipaddress {
        10.0.1.140
    }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Start keepalived:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;service keepalived start
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The only configuration difference regarding keepalived between the master and the standby router is the 'priority' setting. The master server should have a higher priority than the backup router (101 vs. 100).&lt;/p&gt;
&lt;p&gt;As there can be multiple VRRP configurations active within the same subnet, it is important that you make sure that you set a unique virtual_router_id. &lt;/p&gt;
&lt;p&gt;&lt;em&gt;Please do not forget to set your own password in case you enable authentication.&lt;/em&gt;&lt;/p&gt;
&lt;h3&gt;VRRP failover example&lt;/h3&gt;
&lt;p&gt;This is what happens if the master is shutdown:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;64 bytes from 10.0.1.140: icmp_seq=148 ttl=64 time=0.583 ms
64 bytes from 10.0.1.140: icmp_seq=149 ttl=64 time=0.469 ms
64 bytes from 10.0.1.140: icmp_seq=150 ttl=64 time=0.267 ms
Request timeout for icmp_seq 151
Request timeout for icmp_seq 152
Request timeout for icmp_seq 153
Request timeout for icmp_seq 154
64 bytes from 10.0.1.140: icmp_seq=155 ttl=64 time=0.668 ms
64 bytes from 10.0.1.140: icmp_seq=156 ttl=64 time=0.444 ms
64 bytes from 10.0.1.140: icmp_seq=157 ttl=64 time=0.510 ms
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;After about five seconds (default) the standby router takes over and starts responding to the virtual IP. &lt;/p&gt;
&lt;h3&gt;Security&lt;/h3&gt;
&lt;p&gt;A host within the same subnet could just spoof VRRP packets and disrupt service. &lt;/p&gt;
&lt;p&gt;An attack on VRRP is not just theoretical. A tool called &lt;a href="https://www.youtube.com/watch?v=Eq91ETxeJeQ"&gt;Loki&lt;/a&gt; allows you to take over the virtual IP-address and become the master router. This will allow you to create a DoS or sniff all traffic.  &lt;/p&gt;
&lt;p&gt;VRRP security is also discussed in &lt;a href="https://media.blackhat.com/bh-us-10/whitepapers/Rey_Mende/BlackHat-USA-2010-Mende-Graf-Rey-loki_v09-wp.pdf"&gt;this document&lt;/a&gt; from the Loki developers.&lt;/p&gt;
&lt;p&gt;According to &lt;a href="https://tools.ietf.org/html/rfc3768"&gt;rfc3768&lt;/a&gt; authentication and security has been deliberately omitted (see section 10 Security Considerations) from newer versions of the VRRP protocol RFC. &lt;/p&gt;
&lt;p&gt;The main argument is that any malicious device in a layer 2 network can stage similar attacks focussing on ARP-spoofing and ARP-poisoning so as the fundament is already insecure, why care about VRRP? &lt;/p&gt;
&lt;p&gt;I understand the reasoning but I disagree. If you do have a secure Layer 2 environment, VRRP becomes the weakest link. Either you really need to filter out VRRP traffic originating from untrusted ports/devices, or implement security on VRRP itself.&lt;/p&gt;
&lt;h3&gt;Attacking VRRP with Loki&lt;/h3&gt;
&lt;p&gt;&lt;em&gt;I have actually used Loki on VRRP and I can confirm it works (at least) as a Denial-of-Service tool.&lt;/em&gt; &lt;/p&gt;
&lt;p&gt;I used Kali (Formerly known as Back-Track) and installed Loki according to &lt;a href="https://forums.kali.org/showthread.php?4768-Installing-loki-on-kali-linux-amd64"&gt;these instructions&lt;/a&gt;. Please note the bottom of the page.&lt;/p&gt;
&lt;p&gt;What I did on Kali Linux: &lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;apt-get install python-dpkt python-dumbnet
wget http://c0decafe.de/svn/codename_loki/packages/kali-1/pylibpcap_0.6.2-1_amd64.deb
wget http://c0decafe.de/svn/codename_loki/packages/kali-1/loki_0.2.7-1_amd64.deb
dpkg -i pylibpcap_0.6.2-1_amd64.deb
dpkg -i loki_0.2.7-1_amd64.deb
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Then just run:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;loki.py
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;img alt="vrrp attack" src="https://louwrentius.com/static/images/vrrp-attack.png" /&gt;&lt;/p&gt;
&lt;p&gt;This is only an issue if you already protected yourself against ARP- and IP-spoofing attacks.&lt;/p&gt;
&lt;h3&gt;Protecting VRRP against attacks&lt;/h3&gt;
&lt;p&gt;Keepalived offers two authentication types regarding VRRP: &lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;PASS (plain-text password)&lt;/li&gt;
&lt;li&gt;AH (IPSEC-AH (authentication header))&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The PASS option is totally useless from a security perspective.&lt;/p&gt;
&lt;p&gt;&lt;img alt="pass authentication" src="https://louwrentius.com/static/images/vrrp-auth-pass.png" /&gt;&lt;/p&gt;
&lt;p&gt;As you can see, the password 'monkey' is visible and easily obtained from the VRRP multicast advertisements. So to me, it does not make sense to use this option. Loki just replayed the packets and could still create a DoS.&lt;/p&gt;
&lt;p&gt;So we are left with IPSEC-AH, wich is more promising as it actually does some cryptography using the IPSEC protocol, so there is no clear-text password to be captured. I'm not a crypto expert, so I'm not sure how secure this implementation is. Here is &lt;a href="http://www.keepalived.org/draft-ietf-vrrp-ipsecah-spec-00.txt"&gt;some more info on IPSEC-AH&lt;/a&gt; as implemented in Keepalived.&lt;/p&gt;
&lt;p&gt;&lt;img alt="AH authentication" src="https://louwrentius.com/static/images/vrrp-auth-ah.png" /&gt;&lt;/p&gt;
&lt;p&gt;If I configure AH authentication, the Loki tool does not recognise the VRRP trafic anymore and it's no longer possible to use this simple script-kiddie-friendly tool to attack your VRRP setup.&lt;/p&gt;
&lt;p&gt;IPSEC-AH actually introduces an IPSEC-AH header between the IP section and the VRRP section of a packet, so it changes the packet format, which probably makes it unrecognisable for Loki.&lt;/p&gt;
&lt;h3&gt;Running VRRP multicast traffic on different network segments&lt;/h3&gt;
&lt;p&gt;It has been &lt;a href="http://www.reddit.com/r/sysadmin/comments/2r1qho/configuring_attacking_and_securing_vrrp_on_linux/"&gt;pointed out to me by XANi_&lt;/a&gt; that it is possible with Keepalived to keep the virtual IP-address and the VRRP multicast traffic in different networks. Clients will therefore not be able to attack the VRRP traffic. &lt;/p&gt;
&lt;p&gt;In this case, security on the VRRP traffic is not relevant anymore and you don't really need to worry about authentication, assuming that untrusted devices don't have access to that 'VRRP' VLAN. &lt;/p&gt;
&lt;p&gt;Th first step is that both routers should have their physical interface in the same (untagged) VLAN. The trick is then to specify the virtual IP-addresses in the appropriate VLANs like this example:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;virtual_ipaddress {

    10.0.1.1/24 dev eth0.100
    10.0.2.1/24 dev eth0.200
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;In this example, virtual IP 10.0.1.1 is tied to VLAN 100 and 10.0.2.1 is tied to VLAN 200. &lt;/p&gt;
&lt;p&gt;If the physical router interfaces are present in the untagged VLAN 50 (example), the VRRP multicast traffic will only be observed in this VLAN.&lt;/p&gt;
&lt;p&gt;Some &lt;a href="http://comments.gmane.org/gmane.linux.keepalived.devel/3001"&gt;background information&lt;/a&gt; on working with VLANs and Keepalived.&lt;/p&gt;
&lt;h3&gt;Firewall configuration&lt;/h3&gt;
&lt;p&gt;&lt;em&gt;Update August 2018&lt;/em&gt;:&lt;/p&gt;
&lt;p&gt;I had problems running VRRP on Red Hat / CentOS. Since I use AH authentication, the protocol is not seen as VRRP but (as TCPDUMP shows) "AH". This is why you need to create a service for Firewalld and enable it for the appropriate zone.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Create a file called "VRRP.xml" in /etc/firewalld/services&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="cp"&gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot;?&amp;gt;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;&amp;lt;service&amp;gt;&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="nt"&gt;&amp;lt;short&amp;gt;&lt;/span&gt;VRRP&lt;span class="nt"&gt;&amp;lt;/short&amp;gt;&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="nt"&gt;&amp;lt;description&amp;gt;&lt;/span&gt;Virtual&lt;span class="w"&gt; &lt;/span&gt;Router&lt;span class="w"&gt; &lt;/span&gt;Redundancy&lt;span class="w"&gt; &lt;/span&gt;Protocol&lt;span class="nt"&gt;&amp;lt;/description&amp;gt;&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="nt"&gt;&amp;lt;port&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="na"&gt;protocol=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;ah&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="na"&gt;port=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;&amp;lt;/service&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;ol&gt;
&lt;li&gt;Enable VRRP (select the appropriate zone for your interface):&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;    sudo firewall-cmd --zone=public --permanent --add-service=VRRP
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;ol&gt;
&lt;li&gt;Reload the configuration&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;    sudo firewall-cmd --reload
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;ol&gt;
&lt;li&gt;check that the service is active with:&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;    sudo firewall-cmd --zone=public --list-services
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h3&gt;Closing words&lt;/h3&gt;
&lt;p&gt;VRRP can provide a very simple solution to setup a high-availability router configuration. Security can be a real issue if untrusted devices reside in the same layer 2 network so implementing security with IPSEC-AH or network segmentation is recommended.  &lt;/p&gt;</content><category term="Networking"/><category term="VRRP"/></entry><entry><title>Getting the Sitecom AC600 Wi-Fi adapter running on Linux</title><link href="https://louwrentius.com/getting-the-sitecom-ac600-wi-fi-adapter-running-on-linux.html" rel="alternate"/><published>2014-11-01T12:00:00+01:00</published><updated>2014-11-01T12:00:00+01:00</updated><author><name>Louwrentius</name></author><id>tag:louwrentius.com,2014-11-01:/getting-the-sitecom-ac600-wi-fi-adapter-running-on-linux.html</id><summary type="html">&lt;p&gt;&lt;strong&gt;TL;DR Yes it works with some modifications of the driver source.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;A USB Wi-Fi adapter I used with a Raspberry Pi broke as I dropped it on the floor, so I had to replace it. I just went to a local shop and bought the &lt;a href="https://www.sitecom.com/en/wi-fi-usb-adapter-ac600/wla-3100/p/1635"&gt;Sitecom AC600&lt;/a&gt; adapter as …&lt;/p&gt;</summary><content type="html">&lt;p&gt;&lt;strong&gt;TL;DR Yes it works with some modifications of the driver source.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;A USB Wi-Fi adapter I used with a Raspberry Pi broke as I dropped it on the floor, so I had to replace it. I just went to a local shop and bought the &lt;a href="https://www.sitecom.com/en/wi-fi-usb-adapter-ac600/wla-3100/p/1635"&gt;Sitecom AC600&lt;/a&gt; adapter as that's what they had available (with support for 5Ghz networking). &lt;/p&gt;
&lt;p&gt;I had some hope that I would just plug it in and it would 'just work™'. But no. Linux. In the end, the device cost me 30 euro's including taxes, but the time spend to get it to work may have made this a &lt;em&gt;very&lt;/em&gt; expensive USB Wi-Fi dongle. And it's funny to think about the fact that the Wi-Fi dongle is almost the same price as the Raspberry Pi board itself.&lt;/p&gt;
&lt;p&gt;But I did get it working and I'd like to show you how.&lt;/p&gt;
&lt;p&gt;It started with a google for 'sitecom ac600 linux' which landed me on &lt;a href="https://wikidevi.com/wiki/Sitecom_WLA-3100"&gt;this page&lt;/a&gt;. This page told me the device uses a MediaTek chipset (MT7610U). &lt;/p&gt;
&lt;p&gt;So you need to download the &lt;a href="http://www.mediatek.com/en/downloads/"&gt;driver from MediaTek&lt;/a&gt;. Here is a &lt;a href="http://s3.amazonaws.com/mtk.cfs/Downloads/linux/mt7610u_wifi_sta_v3002_dpo_20130916.tar.bz2"&gt;direct link&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;So you may do something like this:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;cd /usr/src
wget http://s3.amazonaws.com/mtk.cfs/Downloads/linux/mt7610u_wifi_sta_v3002_dpo_20130916.tar.bz2
tar xjf mt7610u_wifi_sta_v3002_dpo_20130916.tar.bz2
cd mt7610u_wifi_sta_v3002_dpo_20130916
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Now you would hope that it's just like this:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;make
make install
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;And we're happy right? Linux FTW! Well, NO! We're using Linux so we have to work for stuff that works right out of the box on Windows and Mac OS.&lt;/p&gt;
&lt;p&gt;So we first start with editing "include/os/rt_linux.h" and go to line ~279. There we make sure that we edit the struct like this: &lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;    typedef struct _OS_FS_INFO_
 {
    kuid_t              fsuid;
    kgid_t              fsgid;
    mm_segment_t    fs;
 } OS_FS_INFO;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Basically, the words int are replaced by kuid_t and kgid_t, or else, compilation will abort with an error. &lt;/p&gt;
&lt;p&gt;Ofcourse, the Sitecom AC600 has an USB identifier that is unknown to the driver, so after compilation, it still doesn't work. &lt;/p&gt;
&lt;p&gt;lsusb output: &lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;Bus 001 Device 004: ID 0df6:0075 Sitecom Europe B.V.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;So google landed me on &lt;a href="http://ubuntuforums.org/showthread.php?t=2228244&amp;amp;page=2&amp;amp;p=13100663#post13100663"&gt;this&lt;/a&gt; nice thread by 'praseodym' that explained the remaining steps. I stole the info below from this thread.&lt;/p&gt;
&lt;p&gt;So while we are in the source directory of the module, we are going to edit "common/rtusb_dev_id.c" and add &lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;{USB_DEVICE(0x0DF6,0x0075)}, /* MT7610U */
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;So this will make the AC600 gets recognised by the driver. Now we also need to edit "os/linux/confik.mk" and change these lines like this:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;HAS_WPA_SUPPLICANT=y
HAS_NATIVE_WPA_SUPPLICANT_SUPPORT=y
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;So no, we are still not ready yet. I'm not 100 percent sure that this is required anymore, but I found &lt;a href="http://superuser.com/questions/738096/how-to-install-mediatek-mt7610u-rt2860-driver"&gt;this nice thread in Italian&lt;/a&gt; and a very small comment by 'shoe rat' tucked away at the end that may make the difference between a working device or not.&lt;/p&gt;
&lt;p&gt;We need to edit the file "os/linux/config.mk" and go to line ~663. Then, around that line, change&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;CHIPSET_DAT = 2860
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;to:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;CHIPSET_DAT = 2870
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Yes. Finally! Now you can do:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;make
make install
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Imagine that such a 'make' takes about 20 minutes on a Raspbery Pi. No joke.&lt;/p&gt;
&lt;p&gt;Now you can either do this:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;modprobe mt7650u_sta
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;You should see something like this:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;root@raspberrypi:/usr/src# lsmod
Module                  Size  Used by
snd_bcm2835            16181  0 
snd_pcm                63684  1 snd_bcm2835
snd_page_alloc          3604  1 snd_pcm
snd_seq                43926  0 
snd_seq_device          4981  1 snd_seq
snd_timer              15936  2 snd_pcm,snd_seq
snd                    44915  5 snd_bcm2835,snd_timer,snd_pcm,snd_seq,snd_seq_device
soundcore               4827  1 snd
mt7650u_sta           895786  1 
pl2303                  7951  0 
usbserial              19536  1 pl2303
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;You should be able to see a 'ra0' device when entering ifconfig -a or iwconfig and just configure it like any wireless device (out-of-scope). &lt;/p&gt;
&lt;p&gt;So once up-and-running, the Sitecom AC600 works fine under Linux and even sees and connects to 5 GHz networks. But not without a caveat of-course. I needed to configure a 5 GHz channel below 100 (I chose 48) on my  Apple Airport Extreme, or the Wi-Fi dongle would not see the 5GHz network and would not be able to connect to it.&lt;/p&gt;
&lt;p&gt;So I hope somebody else is helped by this information.&lt;/p&gt;</content><category term="Networking"/><category term="Wi-Fi"/></entry><entry><title>How traffic shaping can dramatically improve internet responsiveness</title><link href="https://louwrentius.com/how-traffic-shaping-can-dramatically-improve-internet-responsiveness.html" rel="alternate"/><published>2014-03-08T12:00:00+01:00</published><updated>2014-03-08T12:00:00+01:00</updated><author><name>Louwrentius</name></author><id>tag:louwrentius.com,2014-03-08:/how-traffic-shaping-can-dramatically-improve-internet-responsiveness.html</id><summary type="html">&lt;p&gt;At work, access to the internet is provided by a 10 Mbit down / 1 Mbit up ADSL-connection. As we are a mid-size company, bandwidth is clearly a severe constraint. But it was not our biggest problem. Even simple web-browsing was very slow.&lt;/p&gt;
&lt;p&gt;As I was setting up a monitoring environment …&lt;/p&gt;</summary><content type="html">&lt;p&gt;At work, access to the internet is provided by a 10 Mbit down / 1 Mbit up ADSL-connection. As we are a mid-size company, bandwidth is clearly a severe constraint. But it was not our biggest problem. Even simple web-browsing was very slow.&lt;/p&gt;
&lt;p&gt;As I was setting up a monitoring environment based on Nagios and pnp4nagios, I started to graph the &lt;em&gt;latency&lt;/em&gt; of our internet connection, just to prove that we have a problem.&lt;/p&gt;
&lt;p&gt;Boy did we get that proof:&lt;/p&gt;
&lt;p&gt;&lt;img alt="bad latency" src="https://louwrentius.com/static/images/internetbadlatency.png" /&gt;&lt;/p&gt;
&lt;p&gt;Just look at the y-axis, which scale is in milliseconds. For most of the day, the average latency is 175 ms, with some high spikes. Just browsing the web was a pain during times of high-latency, which was clearly almost all of the time.&lt;/p&gt;
&lt;p&gt;I became so fed up with our slow internet access that I decided to take matters in my own hands and resolve the low latency issue. The solution? Traffic shaping. &lt;/p&gt;
&lt;p&gt;I learned that as ADSL-connections are saturated, especially their upload capacity, you will experience high latency and packet loss. So the trick is to &lt;em&gt;never&lt;/em&gt; saturate the connection. &lt;/p&gt;
&lt;p&gt;I grabbed a Linux box with two network interfaces and placed it between our internet router and our firewall in bridge mode. &lt;/p&gt;
&lt;p&gt;For actual traffic shaping I used &lt;a href="http://lartc.org/wondershaper/"&gt;wondershaper&lt;/a&gt; which is part of Debian or Ubuntu.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;apt-get install wondershaper
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;The wondershaper script is extremely simple, it's specifically build to resolve the problem we face with our ADSL connection. It not only prioritises traffic, it allows you to limit bandwidth usage and thus prevent you from saturating the connection.&lt;/p&gt;
&lt;p&gt;This simple example limits bandwidth a bit below full capacity, which dramatically improved latency. &lt;/p&gt;
&lt;p&gt;Syntax:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;wondershaper &amp;lt;interface&amp;gt; &amp;lt;rx&amp;gt; &amp;lt;tx&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Example:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;wondershaper eth1 9500 700
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;As you can see, latency improved dramatically:&lt;/p&gt;
&lt;p&gt;&lt;img alt="good latency" src="https://louwrentius.com/static/images/internetgoodlatency.png" /&gt;&lt;/p&gt;
&lt;p&gt;Again, look at the y-axis. We went from an average latency of 175 ms to an average of 35 ms. That's quite an improvement. &lt;/p&gt;
&lt;p&gt;Can you spot on which day I implemented traffic shaping?&lt;/p&gt;
&lt;p&gt;&lt;img alt="week latency" src="https://louwrentius.com/static/images/internetweeklatency.png" /&gt;&lt;/p&gt;
&lt;p&gt;At the time of writing this blog post, the company is working on fiber internet access, resolving our internet woes, but it will take quite some time before that will be installed, so this is a nice intermediate solution.&lt;/p&gt;</content><category term="Networking"/><category term="traffic shaping"/></entry><entry><title>Achieving 450 MB/s network file transfers using Linux Bonding</title><link href="https://louwrentius.com/achieving-450-mbs-network-file-transfers-using-linux-bonding.html" rel="alternate"/><published>2014-01-07T01:00:00+01:00</published><updated>2014-01-07T01:00:00+01:00</updated><author><name>Louwrentius</name></author><id>tag:louwrentius.com,2014-01-07:/achieving-450-mbs-network-file-transfers-using-linux-bonding.html</id><summary type="html">&lt;h3&gt;Linux Bonding&lt;/h3&gt;
&lt;p&gt;In this article I'd like to show the results of using regular 1 Gigabit network connections to achieve 450 MB/s file transfers over NFS. &lt;/p&gt;
&lt;p&gt;I'm &lt;a href="https://louwrentius.com/linux-network-interface-bonding-trunking-or-how-to-get-beyond-1-gbs.html"&gt;again using Linux interface bonding&lt;/a&gt; for this purpose. &lt;/p&gt;
&lt;p&gt;Linux interface bonding can be used to create a virtual network interface with the …&lt;/p&gt;</summary><content type="html">&lt;h3&gt;Linux Bonding&lt;/h3&gt;
&lt;p&gt;In this article I'd like to show the results of using regular 1 Gigabit network connections to achieve 450 MB/s file transfers over NFS. &lt;/p&gt;
&lt;p&gt;I'm &lt;a href="https://louwrentius.com/linux-network-interface-bonding-trunking-or-how-to-get-beyond-1-gbs.html"&gt;again using Linux interface bonding&lt;/a&gt; for this purpose. &lt;/p&gt;
&lt;p&gt;Linux interface bonding can be used to create a virtual network interface with the aggregate bandwidth of all the interfaces added to the bond. Two gigabit network interfaces will give you - guess what - two gigabit or ~220 MB/s of bandwidth. &lt;/p&gt;
&lt;p&gt;This bandwidth can be used by a single TCP-connection.&lt;/p&gt;
&lt;p&gt;So how is this achieved? The Linux bonding kernel module has special bonding mode: mode 0 or round-robin bonding. In this mode, the kernel will stripe packets across the interfaces in the 'bond' like RAID 0 with hard drives. As with RAID 0, you get additional performance with each device you add. &lt;/p&gt;
&lt;p&gt;So I've added HP NC364T quad-port network cards to my servers. Thus each server has a theoretical bandwidth of 4 Gigabit. These HP network cards cost just 145 Euro and I even found the card for 105 Dollar on &lt;a href="http://www.amazon.com/s/ref=nb_sb_noss?url=search-alias%3Delectronics&amp;amp;field-keywords=NC364T&amp;amp;rh=n%3A172282%2Ck%3ANC364T"&gt;Amazon&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img alt="hp quad port nic" src="https://louwrentius.com/static/images/hpnic.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;With two servers, you just need four UTP cable's to connect the two network interfaces and you're done. This would cost you ~300 Euro or ~200 dollar in total. &lt;/p&gt;
&lt;p&gt;If you want to connect additional servers, you need a managed gigabit switch with VLAN-support and sufficient ports. Each additional server will use 4 ports on the switch, excluding interfaces for remote access and other purposes. &lt;/p&gt;
&lt;p&gt;Managed gigabit switches are quite inexpensive these days. I bought a 24 port switch: &lt;a href="http://www8.hp.com/ca/en/products/networking-switches/product-detail.html?oid=5304944"&gt;HP 1810-24G v2 (J9803A)&lt;/a&gt; for about 180 euros (209 Dollars on Newegg) and it can even be rack-mounted. &lt;/p&gt;
&lt;p&gt;&lt;img alt="switch" src="https://louwrentius.com/static/images/hpswitch.png" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Using VLANS&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;So you can't just use a gigabit switch and connect all these quad-port network cards to a single VLAN. I tested this scenario first and only got a maximum transfer speed of 270 MB/s while copying a file between servers over NFS.&lt;/p&gt;
&lt;p&gt;The trick is to create a &lt;em&gt;separate VLAN for every network port&lt;/em&gt;. So if you use a quad-port network card, you need four VLANs. Also, you must make sure that every port on every network card is in the same VLAN. For example, port 1 on every card needs to be in VLAN 21, port 2 in VLAN 22, and so on. You also must add the appropriate switch port to the correct VLAN. Last, you must add the network interfaces to the bond in the right order. &lt;/p&gt;
&lt;p&gt;&lt;img alt="bondingschema" src="https://louwrentius.com/static/images/bondingschema.png" /&gt;&lt;/p&gt;
&lt;p&gt;So why do you need to use VLANs? The reason is quite simple. Bonding works by spoofing the same hardware or MAC-address on all interfaces. So the switch sees the same hardware address on four ports, and thus gets confused. To which port should the packet be sent?&lt;/p&gt;
&lt;p&gt;If you put each port in it's own VLAN, the 'spoofed' MAC-address is seen only once in each VLAN. So the switch won't be confused. What you are in fact doing by creating VLANs is creating four separate switches. So if you have - for example - four cheap 8-port unmanaged gigabit switches, this would work too.&lt;/p&gt;
&lt;p&gt;So assuming that you have four ethernet interfaces, this is an example of how you can create the bond:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;ifenslave bond0 eth1 eth2 eth3 eth4
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Next, you just assign an IP-address to the bond0 interface, like you would with a regular eth(x) interface. &lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;ifconfig bond0 192.168.2.10 netmask 255.255.255.0
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Up to this point, I only achieved about 350 MB/s. I needed to enable &lt;em&gt;jumbo frames&lt;/em&gt; on all interfaces and the switch to achieve 450 MB/s. &lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;ifconfig bond0 mtu 9000 up
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Next, you can just mount any NFS share over the interface and start copying files. That's all.&lt;/p&gt;
&lt;p&gt;Once I added each interface to the appropriate VLAN, I got about 450 MB/s for a single file copy with 'cp' over NFS.&lt;/p&gt;
&lt;p&gt;&lt;img alt="450 MB/s" src="https://louwrentius.com/static/images/450MB.png" /&gt;&lt;/p&gt;
&lt;p&gt;I did not perform a 'cp' but a 'dd' because I don't have a disk array fast enough (yet) that can write at 450 MB/s. &lt;/p&gt;
&lt;p&gt;So for three servers, this solution will cost me 600 Euro or 520 Dollar.     &lt;/p&gt;
&lt;h3&gt;What about LAGs and LACP?&lt;/h3&gt;
&lt;p&gt;Don't configure your clients or switches for LACP, it doesn't give you the speed benefit and it's not required.     &lt;/p&gt;
&lt;h3&gt;10 Gigabit ethernet?&lt;/h3&gt;
&lt;p&gt;Frankly, it's quite expensive if you need to connect more than two servers. An entry-level 10Gbe NIC like the &lt;a href="http://ark.intel.com/products/58953/Intel-Ethernet-Converged-Network-Adapter-X540-T1"&gt;Intel X540-T1&lt;/a&gt; does about 300 Euros or 450 Dollar. This card allows you to use Cat 6e UTP Cabling. (Pricing from Dutch Webshops in Euros and Newegg in Dollars).&lt;/p&gt;
&lt;p&gt;With two of those, you can have 10Gbit ethernet between two servers for 600 Euro or 700 Dollar. If you need to connect more servers, you would need a switch. The problem is that 10Gbit switches are not cheap. An 8-port unmanaged switch from Netgear (ProSAFE Plus XS708E) does about 720 Euro's or 900 Dollar. &lt;/p&gt;
&lt;p&gt;If you want to connect three servers, you need three network cards and a switch. So three network cards and a switch will cost you  900 Euro (1050 Dollar) for the network cards and 720 Euro (900 Dollar) for the switch, totalling 1800 euro or 1950 Dollar. &lt;/p&gt;
&lt;p&gt;You will get higher transfer speeds, but at a significantly higher price.&lt;/p&gt;
&lt;p&gt;For many business purposes this higher price can be easily justified and I would select 10 Gb over 1 Gb bonding in a heart-beat. Less cables, higher performance, lower latency. &lt;/p&gt;
&lt;p&gt;However, bonding gigabit interfaces allows you to use off-the-shelf equipment and maybe a nice compromis between cost, usability and performance. &lt;/p&gt;
&lt;h3&gt;Operating System Support&lt;/h3&gt;
&lt;p&gt;As far as I'm aware, round-robin bonding is only supported on Linux. Other operating systems do not support it.&lt;/p&gt;</content><category term="Networking"/></entry><entry><title>Eztables: simple yet powerful firewall configuration for Linux</title><link href="https://louwrentius.com/eztables-simple-yet-powerful-firewall-configuration-for-linux.html" rel="alternate"/><published>2013-11-16T12:00:00+01:00</published><updated>2013-11-16T12:00:00+01:00</updated><author><name>Louwrentius</name></author><id>tag:louwrentius.com,2013-11-16:/eztables-simple-yet-powerful-firewall-configuration-for-linux.html</id><summary type="html">&lt;p&gt;I've created and released &lt;a href="http://eztables.net"&gt;Eztables&lt;/a&gt; on Github. Anyone who ever has a need to setup a firewall on Linux may be interested in this project. &lt;/p&gt;
&lt;p&gt;It doesn't matter if you need to protect a laptop, server or want to setup a network firewall. Eztables supports it all.&lt;/p&gt;
&lt;p&gt;If you're not …&lt;/p&gt;</summary><content type="html">&lt;p&gt;I've created and released &lt;a href="http://eztables.net"&gt;Eztables&lt;/a&gt; on Github. Anyone who ever has a need to setup a firewall on Linux may be interested in this project. &lt;/p&gt;
&lt;p&gt;It doesn't matter if you need to protect a laptop, server or want to setup a network firewall. Eztables supports it all.&lt;/p&gt;
&lt;p&gt;If you're not afraid to touch the command line and edit a text file, you may be quite pleased with Eztables. &lt;/p&gt;
&lt;p&gt;&lt;a href="http://eztables.net"&gt;Go check it out!&lt;/a&gt;&lt;/p&gt;</content><category term="Networking"/><category term="Firewall"/><category term="Networking"/><category term="iptables"/><category term="Security"/></entry><entry><title>Linux: script that creates table of network interface properties</title><link href="https://louwrentius.com/linux-script-that-creates-table-of-network-interface-properties.html" rel="alternate"/><published>2013-08-15T00:00:00+02:00</published><updated>2013-08-15T00:00:00+02:00</updated><author><name>Louwrentius</name></author><id>tag:louwrentius.com,2013-08-15:/linux-script-that-creates-table-of-network-interface-properties.html</id><summary type="html">&lt;p&gt;My server has 5 network interfaces and I wanted a quick overview of some properties. There may be an existing linux command for this but I couldn't find it so I quickly wrote my 
own script &lt;a href="/static/files/showinterfaces"&gt;(download)&lt;/a&gt;. &lt;/p&gt;
&lt;p&gt;This is the output:&lt;/p&gt;
&lt;p&gt;&lt;img alt="showinterfacesimage" src="/static/images/showinterfaces01.png" /&gt;&lt;/p&gt;
&lt;p&gt;The only requirement for this script is that you …&lt;/p&gt;</summary><content type="html">&lt;p&gt;My server has 5 network interfaces and I wanted a quick overview of some properties. There may be an existing linux command for this but I couldn't find it so I quickly wrote my 
own script &lt;a href="/static/files/showinterfaces"&gt;(download)&lt;/a&gt;. &lt;/p&gt;
&lt;p&gt;This is the output:&lt;/p&gt;
&lt;p&gt;&lt;img alt="showinterfacesimage" src="/static/images/showinterfaces01.png" /&gt;&lt;/p&gt;
&lt;p&gt;The only requirement for this script is that you have 'ethtool' installed. &lt;/p&gt;
&lt;p&gt;&lt;em&gt;Update 2013-08-17&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;I recreated the script in python &lt;a href="/static/files/showifs"&gt;(download)&lt;/a&gt; so I can just dynamically format the table and not use
ugly hacks I used in the bash script.&lt;/p&gt;</content><category term="Networking"/><category term="Linux"/><category term="Networking"/></entry><entry><title>How to compile HAProxy from source and setup a basic configuration</title><link href="https://louwrentius.com/how-to-compile-haproxy-from-source-and-setup-a-basic-configuration.html" rel="alternate"/><published>2013-08-14T01:00:00+02:00</published><updated>2013-08-14T01:00:00+02:00</updated><author><name>Louwrentius</name></author><id>tag:louwrentius.com,2013-08-14:/how-to-compile-haproxy-from-source-and-setup-a-basic-configuration.html</id><summary type="html">&lt;p&gt;To learn more about HAProxy I decided to compile it from source and use it to load-balance traffic to louwrentius.com across two different web servers.&lt;/p&gt;
&lt;p&gt;I run HAProxy on a VPS based on Ubuntu 12.04 LTS. Let's dive right in.&lt;/p&gt;
&lt;p&gt;First, we need to download the source. Don't …&lt;/p&gt;</summary><content type="html">&lt;p&gt;To learn more about HAProxy I decided to compile it from source and use it to load-balance traffic to louwrentius.com across two different web servers.&lt;/p&gt;
&lt;p&gt;I run HAProxy on a VPS based on Ubuntu 12.04 LTS. Let's dive right in.&lt;/p&gt;
&lt;p&gt;First, we need to download the source. Don't copy/pased the exact code, you should download the latest version of HAProxy. &lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;cd /usr/src
wget &amp;quot;http://haproxy.1wt.eu/download/1.4/src/haproxy-1.4.24.tar.gz&amp;quot;
tar xzf haproxy-1.4.24.tar.gz
cd haproxy-1.4.24
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Before you can compile software, you must make sure you have a working build-environment. With Ubuntu or Debian, you should run:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;apt-get install build-essential
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;If you open the README file in the root directory, you will find some detailed instructions on how to compile HAProxy, which is really straight-forward. &lt;/p&gt;
&lt;h3&gt;Compiling HAProxy&lt;/h3&gt;
&lt;h2&gt;Best CPU performance&lt;/h2&gt;
&lt;p&gt;The manual states that by default, it will compile HAProxy with no CPU-specific optimisations. To enable CPU-specific optimisations, you need to use the 'native' option.&lt;/p&gt;
&lt;p&gt;The extra argument we are supplying to 'make' wil be:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;CPU=native
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h2&gt;Libpcre support&lt;/h2&gt;
&lt;p&gt;It recommends to compile HAproxy with libpcre as it provides way better performance than other libc PCRE implementations. You need to install libpcre like this:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;apt-get install libpcre3-dev
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;The extra argument we are supplying to 'make' wil be:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;USE_PCRE=1
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h2&gt;Splicing support&lt;/h2&gt;
&lt;p&gt;A Linux-specific feature is support for the splice() system call. This system call allows data to be moved between file descriptors within kernel space, not touching user space. It entirely depends on your setup if this feature will be of any use to you. As splicing can be disabled within the configuration file of HAProxy, I would recommend compiling HAProxy with support for splicing. &lt;/p&gt;
&lt;p&gt;The extra argument we are supplying to 'make' wil be:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;USE_LINUX_SPLICE=1
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h2&gt;Transparent mode support&lt;/h2&gt;
&lt;p&gt;I &lt;a href="http://blog.loadbalancer.org/configure-haproxy-with-tproxy-kernel-for-full-transparent-proxy/"&gt;learned&lt;/a&gt; that HAProxy also supports a transparent mode where it seems to 'spoof' the client IP-address to the backend servers. This way, the backend servers see the actual client IP-address, not the IP-address of the HAProxy load-balancer(s).&lt;/p&gt;
&lt;p&gt;For this setup to work, you need additional firewall rules and meet some routing requirements. I'm not sure why this would be important and the linked article also mentions a work-around where an additional HTTP-header is used: x-forwarded-for.&lt;/p&gt;
&lt;p&gt;I found &lt;a href="http://www.cyberciti.biz/faq/nginx-extract-the-clients-real-ip-from-x-forwarded-for-header/"&gt;this&lt;/a&gt; article about how to configure lighttpd to log the x-forwarded-for header. &lt;a href="http://wiki.nginx.org/HttpRealipModule"&gt;Here&lt;/a&gt; are some instructions for Ngnix.&lt;/p&gt;
&lt;p&gt;The extra argument we are supplying to 'make' wil be:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;USE_LINUX_TPROXY=1
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h2&gt;Encrypted password support&lt;/h2&gt;
&lt;p&gt;It's possible to limit access to HAProxy features (like statistics) to specific users and their passwords. These passwords can be stored in plain-text or as a (more secure) hash of the password, &lt;a href="http://code.google.com/p/haproxy-docs/wiki/Userlists"&gt;using crypt&lt;/a&gt;. &lt;/p&gt;
&lt;p&gt;The extra argument we are supplying to 'make' wil be:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;USE_LIBCRYPT=1
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h2&gt;Compiling HAproxy&lt;/h2&gt;
&lt;p&gt;If we would use all discussed options, our Make command would look like this:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;make TARGET=custom CPU=native USE_PCRE=1 USE_LIBCRYPT=1 USE_LINUX_SPLICE=1 USE_LINUX_TPROXY=1
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h2&gt;Installing HAproxy&lt;/h2&gt;
&lt;p&gt;By default, HAProxy is installed in /usr/local/haproxy with the following command:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;make install
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;If you want to start HAProxy at boot time, you need a startup script. HAProxy does provide a startup script for Redhat-based distro's, but not for Debian-based distros. &lt;/p&gt;
&lt;p&gt;HAProxy is also available pre-compiled as an Ubuntu or Debian package. These packages also contain a startup script. I used such a script and modified it to work with the HAProxy version I compiled from source. Basically, I only altered some paths, but you can find it &lt;a href="https://louwrentius.com/files/haproxy"&gt;here&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;Configuration&lt;/h3&gt;
&lt;p&gt;HAProxy is very versatile and the actual configuration will entirely depend on your specific needs. I will document some basic scenario's with some examples. &lt;/p&gt;
&lt;p&gt;HAProxy has many configuration options, but don't worry, those are often &lt;a href="http://cbonte.github.io/haproxy-dconv/configuration-1.4.html"&gt;well-documented&lt;/a&gt;. &lt;/p&gt;
&lt;h2&gt;Scenario 1: Load-balancing&lt;/h2&gt;
&lt;p&gt;In this scenario, we have one load balancer based on HAProxy and it's goal is to load-balance traffic across two backend HTTP-servers.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;global
    daemon
    user haproxy
    group haproxy
    chroot /home/haproxy
    maxconn 256

defaults
    mode http
    timeout connect 5000ms
    timeout client 50000ms
    timeout server 50000ms

frontend http-in
    bind *:80
    default_backend servers

backend servers
    balance roundrobin  
    server ws01 1.1.1.1:80 
    server ws02 1.1.1.2:80
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Reading the global section, we learn that HAProxy should run as a daemon, that it should run as a specific system user and thus drop all privileges after startup. It also should chroot to /home/haproxy, a directory which should be empty and not writable by the HAProxy user or group. HAProxy will permit at most 256 simultaneous connections. &lt;/p&gt;
&lt;p&gt;The defaults section learns us that we are running in HTTP mode. HAProxy can load-balance any TCP-traffic. In HTTP mode, it can understand and read HTTP header information and apply different actions, allowing for more control. &lt;/p&gt;
&lt;p&gt;Now we encounter the interesting part. The default_backend keyword shows that all traffic entering on TCP-port 80 should be directed to the backend 'servers'. The 'backend' section contains the actual backend servers that will be able to handle traffic. The load-balancing algorithm used is round-robin: every web server is used in turn. Visitor 1 hits webserver 1. Visitor 2 hits webserver 2. Visitor 3 hits webserver 1, and so on.&lt;/p&gt;
&lt;h2&gt;Scenario 2: Fail-over&lt;/h2&gt;
&lt;p&gt;In scenario 1, we only discussed load-balancing. However, if one of the servers becomes unavailable, users will be facing error-messages generated by HAProxy. This is often undesired, we want HAProxy to check the status of the backend servers and direct traffic only to servers that are available. HAProxy should not forward clients to backend servers that are not responsive.&lt;/p&gt;
&lt;p&gt;This desired behaviour requires a few extra options within the 'backend' section. &lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;backend servers
    balance roundrobin
    option httpchk
    server ws01 1.1.1.1:80 check inter 4000
    server ws02 1.1.1.2:80 check inter 4000
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;This configration makes HAProxy check both backend webservers for every 4000ms (4 seconds) for availability. By default, HAProxy only tests if it's possible to make a TCP-connection with the webserver. Ofcourse, this will not always tell you if a webserver is properly operational. This is why 'option httpchk' is added to the configuration. HAProxy will then connect to the backend webserver and issue an HTTP OPTIONS-request, which will be a better gauge to determine if the web server service is active. With additional options you can make HAProxy request specific URIs. &lt;/p&gt;
&lt;h3&gt;Additional configuration options&lt;/h3&gt;
&lt;h2&gt;Logging&lt;/h2&gt;
&lt;p&gt;HAProxy supports logging to Syslog. You can configure it to log to the local syslog daemon, or to a centralised log server. &lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;global
    log 127.0.0.1 local0 debug
    log-tag haproxy
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;All log messages are prefixed with 'haproxy'. They are sent to localhost and the verbosity is 'debug'. &lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;defaults
    log global

frontend http-in
    log global
    option httplog clf
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Option httplog clf makes HAProxy log in a similar log format as Apache. A tool like AWstats can then easily parse the log and generate some statistics. &lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;backend servers
    log global
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;The 'backend' section will only log messages related to the availability of backend servers. Actual request-logging is performed through the 'frontent' section.&lt;/p&gt;
&lt;h2&gt;Prioritising backend servers&lt;/h2&gt;
&lt;p&gt;Some backend servers may have more performance and bandwidth available then others. Using the 'weight' parameter, you can make sure that certain services get more traffic then others. &lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;backend servers
    balance roundrobin
    option httpchk
    server ws01 1.1.1.1:80 check inter 4000 weight 10
    server ws02 1.1.1.2:80 check inter 4000 weight 20
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;In this example, webserver ws02 will receive twice as many request as webserver ws01. But the load will still be balanced across both webservers.&lt;/p&gt;
&lt;h2&gt;Enabling statistics&lt;/h2&gt;
&lt;p&gt;HAProxy has a build-in webpage that shows performance metrics and the status of backend hosts. This webpage is not enabled by default. &lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;defaults
    stats enable
    stats auth username:password
    stats uri /mystatspage
    stats refresh 5s
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Please note that with this configuration, the statistics page may be accessible from the internet. As the page may provide some information about your environment that could be of benefit to attackers, it's wise to configure strong passwords and to configure a uri that is not easy to predict/guess. Beware that the password is transmitted in clear-text!&lt;/p&gt;
&lt;p&gt;For security reasons I would recommend to have the statistics page only accessible from within your own network and not accessible directly from the internet in any way. &lt;/p&gt;
&lt;p&gt;In this next scenario I assume that the load balancer has two network interfaces and is connected to both the internet and an internal 'backend' network that uses IP-addresses in the 10.x.x.x range.&lt;/p&gt;
&lt;p&gt;For security reasons, I would bind the statistics web page to the 'backend' interface, so it will never be accessible through the internet.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;listen HAProxy-stats 10.0.10.10:81
    stats enable
    stats auth user:pass
    stats uri /stats
    stats refresh 5s
    stats show-legends
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h3&gt;Final words&lt;/h3&gt;
&lt;p&gt;This basic tutorial should leave you with an up-and-running HAProxy. There are some topics I did not discuss, like handling of SSL-traffic. HAProxy 1.4 does not support SSL but version 1.5 will have native SSL-support. In the mean time, you will need to use Ngnix or 'stud' for SSL-offloading.  &lt;/p&gt;</content><category term="Networking"/><category term="load-balancing"/><category term="HAProxy"/><category term="high-availability"/></entry><entry><title>overview of open-source load balancers</title><link href="https://louwrentius.com/overview-of-open-source-load-balancers.html" rel="alternate"/><published>2013-08-07T12:00:00+02:00</published><updated>2013-08-07T12:00:00+02:00</updated><author><name>Louwrentius</name></author><id>tag:louwrentius.com,2013-08-07:/overview-of-open-source-load-balancers.html</id><summary type="html">&lt;p&gt;I was looking at open-source load balancing software and it seems that there isn't a nice overview except from &lt;a href="http://www.inlab.de/articles/free-and-open-source-load-balancing-software-and-projects.html"&gt;this website&lt;/a&gt;, although many of the listed projects seem dead. &lt;/p&gt;
&lt;p&gt;I've made a selection of products that seem to be relevant. The biggest problem with open-source software is that projects are …&lt;/p&gt;</summary><content type="html">&lt;p&gt;I was looking at open-source load balancing software and it seems that there isn't a nice overview except from &lt;a href="http://www.inlab.de/articles/free-and-open-source-load-balancing-software-and-projects.html"&gt;this website&lt;/a&gt;, although many of the listed projects seem dead. &lt;/p&gt;
&lt;p&gt;I've made a selection of products that seem to be relevant. The biggest problem with open-source software is that projects are abandoned or unmaintained.
So I created this table and added a column 'last product update' which gives you a feel for how active the project is.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Product&lt;/th&gt;
&lt;th&gt;Last product update&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="http://nginx.org/"&gt;ngnix&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;2013 July&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="http://www.lighttpd.net"&gt;Lighttpd&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;November 2012&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="http://haproxy.1wt.eu/"&gt;HAproxy&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;2013 June&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="http://www.apsis.ch/pound/"&gt;Pound&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;2011 December&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="http://www.varnish-cache.org/"&gt;Varnish&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;2013 June&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="http://www.zenloadbalancer.com"&gt;Zen Load Balancer&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;2013 February&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="http://httpd.apache.org/docs/2.2/mod/mod_proxy_balancer.html"&gt;Apache&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;2013 July&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="http://www.linuxvirtualserver.org/software/ktcpvs/ktcpvs.html"&gt;Linux Virtual Server&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Unmaintained?&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="http://sourceforge.net/projects/xlb/"&gt;XLB HTTP Load Balancer&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;2009 February&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="http://sourceforge.net/apps/mediawiki/octopuslb/index.php?title=Main_Page"&gt;Octopus Load Balancer&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;2011 November&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="http://wiki.squid-cache.org/SquidFaq/ReverseProxy"&gt;Squid&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;2013 July&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;Date of measurement: August 2013&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;I currently don't have hands-on experience with these products. Some of those products are briefly discussed at &lt;a href="http://erikwebb.net/blog/open-source-software-load-balancers"&gt;this blog&lt;/a&gt; - worth a visit.&lt;/p&gt;
&lt;p&gt;There are many more products but most seem to be abandoned years ago. If you feel there are more products that are noteworthy but not in this list, feel free to contact me or comment about it.&lt;/p&gt;
&lt;p&gt;It seems that the top-3 web servers like ngnix, Apache and Lighttpd all have support for load balancing. It depends on your needs, time and knowledge if you want to invest in other products or stick with the web server software you know.&lt;/p&gt;
&lt;p&gt;At this &lt;a href="http://www.gossamer-threads.com/lists/nanog/users/140879"&gt;location&lt;/a&gt; some people are talking about the pro's and con's of commercial off-the-shelve products vs. home-grown open-source solutions. &lt;/p&gt;</content><category term="Networking"/><category term="load-balancing"/></entry><entry><title>Statistics showing relevance of caching proxy</title><link href="https://louwrentius.com/statistics-showing-relevance-of-caching-proxy.html" rel="alternate"/><published>2012-12-18T01:00:00+01:00</published><updated>2012-12-18T01:00:00+01:00</updated><author><name>Louwrentius</name></author><id>tag:louwrentius.com,2012-12-18:/statistics-showing-relevance-of-caching-proxy.html</id><summary type="html">&lt;p&gt;In this day and age of dynamic web content, how relevant can a caching proxy server be? I believe that the answer could be: quite!&lt;/p&gt;
&lt;p&gt;I have installed a caching proxy server based on Squid, which is now used within my company. It also does content scanning using &lt;a href="http://squidclamav.darold.net"&gt;squidclamav&lt;/a&gt; and …&lt;/p&gt;</summary><content type="html">&lt;p&gt;In this day and age of dynamic web content, how relevant can a caching proxy server be? I believe that the answer could be: quite!&lt;/p&gt;
&lt;p&gt;I have installed a caching proxy server based on Squid, which is now used within my company. It also does content scanning using &lt;a href="http://squidclamav.darold.net"&gt;squidclamav&lt;/a&gt; and Clamav. I wrote an &lt;a href="https://louwrentius.com/blog/2012/08/setting-up-a-squid-proxy-with-clamav-anti-virus-using-c-icap/"&gt;article&lt;/a&gt; about how to setup such a content scanning proxy.&lt;/p&gt;
&lt;p&gt;The thing is that I didn't much care for the actual caching functionality of Squid, I deemed the content-scanning part more interesting. But I'm quite pleased with the actual caching hit ratio. &lt;/p&gt;
&lt;p&gt;&lt;img alt="proxy stats" src="https://louwrentius.com/static/images/proxyisrelevant.gif" /&gt;&lt;/p&gt;
&lt;p&gt;It seems that we have a hit ratio between 20% to 25% and that is more than I expected. Most content is dynamic in nature, so I would expect that most content
is not cached but it seems that there is still quite some data that can be cached. This must also improve the end-user surfing experience as latency for downloading content should be reduced. &lt;/p&gt;
&lt;p&gt;Of course, this is just a sample for the last hour. However, multiple measurements at different moments yield similar results. &lt;/p&gt;
&lt;p&gt;I think this result proves that a caching proxy server is still relevant, especially if you don't have a fast internet connection. If you do, you can still improve the overall browsing experience due to the fact that data is cached. &lt;/p&gt;
&lt;p&gt;There is a caveat: the proxy server itself also introduces latency. I haven't performed a side-by-side comparison and measured actual responsiveness of browsing with or without a proxy. &lt;/p&gt;</content><category term="Networking"/></entry><entry><title>Example of a home networking setup with VLANs</title><link href="https://louwrentius.com/example-of-a-home-networking-setup-with-vlans.html" rel="alternate"/><published>2012-02-05T09:00:00+01:00</published><updated>2012-02-05T09:00:00+01:00</updated><author><name>Louwrentius</name></author><id>tag:louwrentius.com,2012-02-05:/example-of-a-home-networking-setup-with-vlans.html</id><summary type="html">&lt;p&gt;Updated October 24, 2012, see below.&lt;/p&gt;
&lt;p&gt;This post is a description of my home network setup based on gigabit ethernet. I did a non-standard trick with VLANs that may also be of interest to other people. I'm going to start with a diagram of the network. Just take a look …&lt;/p&gt;</summary><content type="html">&lt;p&gt;Updated October 24, 2012, see below.&lt;/p&gt;
&lt;p&gt;This post is a description of my home network setup based on gigabit ethernet. I did a non-standard trick with VLANs that may also be of interest to other people. I'm going to start with a diagram of the network. Just take a look (click to enlarge).&lt;/p&gt;
&lt;p&gt;&lt;a href="https://louwrentius.com/static/images/home-network.png"&gt;&lt;img alt="home network" src="https://louwrentius.com/static/images/home-network-small.png" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I now have replaced my Mac Mini with a HP N40L router based on Ubuntu 12.04 LTS. This server is now placed in the basement. The managed netgear switch is swapped with the Airport extreme.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://louwrentius.com/static/images/homenetwork.png"&gt;&lt;img alt="home network" src="https://louwrentius.com/static/images/homenetwork-small.png" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;Design&lt;/h3&gt;
&lt;p&gt;I have a Mac mini running Linux that acts as my internet router. The closet that houses the cable modem is not a friendly environment for such a device and there is not a good location for it. The closet is also outside of my house, behind a door not too well protected. So this is why I keep my router inside my house. &lt;/p&gt;
&lt;p&gt;From this closet, one UTP cable terminates in the living room, the other in the basement. This configuration has a very big problem. How do I run two different networks over one wire?&lt;/p&gt;
&lt;p&gt;I have to connect my iMac to my 'internal' home network. However, the Mac mini must be connected to both the internet network segment (connected to the cable modem) and the home network. All through a single UTP cable. &lt;/p&gt;
&lt;p&gt;Therefore I use VLANs. I transport both the internet network and the local home network though one cable. VLAN 10 is for internet, VLAN 20 for my local home network. For this all to work you need managed switches that support 802.1q.&lt;/p&gt;
&lt;h3&gt;How traffic flows&lt;/h3&gt;
&lt;p&gt;So let's say that the server is accessing the internet to obtain the latest Linux security updates. How does this network traffic flow through the infrastructure (click to enlarge)?&lt;/p&gt;
&lt;p&gt;&lt;a href="https://louwrentius.com/static/images/home-network-traffic.png"&gt;&lt;img alt="network flow" src="https://louwrentius.com/static/images/home-network-traffic-small.png" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;All internet traffic must flow through the router. Thus, even if the traffic from the basement travels through the switch next to the cable modem, it must first travel to the router in the living room. There the router decides if the traffic is permitted to go out to the internet and thus enter the internet VLAN. &lt;/p&gt;
&lt;h3&gt;Pros and cons&lt;/h3&gt;
&lt;p&gt;Pros: &lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Just a single cable to the living room&lt;/li&gt;
&lt;li&gt;no extra USB-based ethernet adapters required for the Mac mini&lt;/li&gt;
&lt;li&gt;Mac mini resides in save and computer friendly environment&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Cons:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Managed switches supporting VLANs are relatively expensive&lt;/li&gt;
&lt;/ul&gt;</content><category term="Networking"/></entry><entry><title>Linux Iptables Firewall Script released on Google code</title><link href="https://louwrentius.com/linux-iptables-firewall-script-released-on-google-code.html" rel="alternate"/><published>2012-01-08T20:00:00+01:00</published><updated>2012-01-08T20:00:00+01:00</updated><author><name>Louwrentius</name></author><id>tag:louwrentius.com,2012-01-08:/linux-iptables-firewall-script-released-on-google-code.html</id><summary type="html">&lt;p&gt;I have released &lt;a href="http://code.google.com/p/lifs/"&gt;LIFS, the Linux Iptables Firewall Script&lt;/a&gt;. This script allows you to setup a firewall within minutes. It is easy to use, yet very powerful. It uses Iptables and even improves upon some limitations of Iptables.&lt;/p&gt;
&lt;p&gt;Every person who has to maintain some kind of Iptables-based firewall should …&lt;/p&gt;</summary><content type="html">&lt;p&gt;I have released &lt;a href="http://code.google.com/p/lifs/"&gt;LIFS, the Linux Iptables Firewall Script&lt;/a&gt;. This script allows you to setup a firewall within minutes. It is easy to use, yet very powerful. It uses Iptables and even improves upon some limitations of Iptables.&lt;/p&gt;
&lt;p&gt;Every person who has to maintain some kind of Iptables-based firewall should really look into LIFS. It will make managing your firewall much more convenient.&lt;/p&gt;
&lt;p&gt;For more advanced purposes. LFS allows you to create object groups. These are groups of individual hosts, networks or services (tcp/udp). &lt;/p&gt;
&lt;p&gt;Look at this example of object groups in action. Read and understand.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;HTTP_SERVICES=&amp;quot;
    80/tcp
   443/tcp
&amp;quot;

WEB_SERVER_1=192.168.0.10
WEB_SERVER_2=192.168.0.11

WEB_SERVERS=&amp;quot;
    $WEB_SERVER_1
    $WEB_SERVER_2
&amp;quot;

allow_in any &amp;quot;$WEB_SRVERS&amp;quot; any &amp;quot;$HTTP_SERVICES&amp;quot;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;As you can see, a single firewall rule in fact creates 4 rules, one for each host and port. This functionality can be found in commercial based firewalls but it is not build-in into Iptables. LIFS fixes this.&lt;/p&gt;
&lt;p&gt;LIFS is a continuation of &lt;a href="http://code.google.com/p/lfs/downloads/list"&gt;LFS&lt;/a&gt;, which has been discontinued.&lt;/p&gt;</content><category term="Networking"/></entry><entry><title>Achieving 220 MB/s network file transfers using Linux Bonding</title><link href="https://louwrentius.com/achieving-220-mbs-network-file-transfers-using-linux-bonding.html" rel="alternate"/><published>2011-07-29T01:00:00+02:00</published><updated>2011-07-29T01:00:00+02:00</updated><author><name>Louwrentius</name></author><id>tag:louwrentius.com,2011-07-29:/achieving-220-mbs-network-file-transfers-using-linux-bonding.html</id><summary type="html">&lt;p&gt;I wrote an &lt;a href="https://louwrentius.com/blog/2010/11/linux-network-interface-bonding-trunking-or-how-to-get-beyond-1-gbs/"&gt;article&lt;/a&gt; about the subject of getting beyond the limits of gigabit network file transfers. My solution is to use multiple gigabit network cards and use Linux interface bonding to create virtual 2 gigabit network interfaces. The solution is to use mode 0 or round robin bonding. I …&lt;/p&gt;</summary><content type="html">&lt;p&gt;I wrote an &lt;a href="https://louwrentius.com/blog/2010/11/linux-network-interface-bonding-trunking-or-how-to-get-beyond-1-gbs/"&gt;article&lt;/a&gt; about the subject of getting beyond the limits of gigabit network file transfers. My solution is to use multiple gigabit network cards and use Linux interface bonding to create virtual 2 gigabit network interfaces. The solution is to use mode 0 or round robin bonding. I do not use a switch although this also works fine. Instead, I just connected two cabled between the two machines.&lt;/p&gt;
&lt;p&gt;In my original article, I couldn't get pas 150 MB/s file transfer speeds so the results weren't that great. However, these poor results were due to hardware compatibility issues. Although the on board network card worked fine, the intel e1000e card in the PCIe slot didn't perform well. I replaced it with a HP Broadcom card and everything is working smooth now.&lt;/p&gt;
&lt;p&gt;With two gigabit network cards bonded together I can achieve 220 MB/s through a single file transfer over NFS. &lt;/p&gt;
&lt;p&gt;It would be interesting if a quad port server adapter would be able to achieve 440 MB/s network speeds, but I don't have the equipment to test this.  &lt;/p&gt;</content><category term="Networking"/></entry><entry><title>The downside of 120 Mbit broadband internet</title><link href="https://louwrentius.com/the-downside-of-120-mbit-broadband-internet.html" rel="alternate"/><published>2011-01-30T20:00:00+01:00</published><updated>2011-01-30T20:00:00+01:00</updated><author><name>Louwrentius</name></author><id>tag:louwrentius.com,2011-01-30:/the-downside-of-120-mbit-broadband-internet.html</id><summary type="html">&lt;p&gt;My Dutch ISP Ziggo provides internet access through DOCSIS cable modems. They are now capable of providging 120 Mbit downstream and 10 Mbit upstream, for an affordable price. &lt;/p&gt;
&lt;p&gt;In a way this is mind boggling. Most people have 100 Mbit home networks that are not capable of handling full capacity …&lt;/p&gt;</summary><content type="html">&lt;p&gt;My Dutch ISP Ziggo provides internet access through DOCSIS cable modems. They are now capable of providging 120 Mbit downstream and 10 Mbit upstream, for an affordable price. &lt;/p&gt;
&lt;p&gt;In a way this is mind boggling. Most people have 100 Mbit home networks that are not capable of handling full capacity. You need at least gigabit gitabit network connectivity on your router and internal network.  &lt;/p&gt;
&lt;p&gt;But there is a problem with all this bandwidth mayhem: &lt;/p&gt;
&lt;p&gt;It is useless. &lt;/p&gt;
&lt;p&gt;The only time I see the full 120 mbit in use is when I do a speed test, or when my mac is downloading system updates. Regular downloading (ISO's, big files from web pages), usenet, bittorrent, they cannot provide content with at the speed my connection is capable of.&lt;/p&gt;
&lt;p&gt;The bottleneck is no longer the connection to the home. The whole internet is now the bottle neck. The content providers are the bottle neck. They cannot seem to cope with this use increase in client side bandwith capacity. They often seem to cap users at a specific download rate, that is way below full capacity. Although the connectivity is relatively cheap, if you can't use it, why pay for it? So downgrading to let's say 50 mbit until content providers are able to handle higher speeds seems the smartest thing to do. &lt;/p&gt;
&lt;p&gt;I must say that I think that content providers are the weakest link. But I cannot be sure. It may be possible that the ISP network, especially their transit links, are the limiting factor. If anyone knows more about this, I'm interested. &lt;/p&gt;</content><category term="Networking"/></entry><entry><title>Linux network interface bonding / trunking or how to get beyond 1 Gb/s</title><link href="https://louwrentius.com/linux-network-interface-bonding-trunking-or-how-to-get-beyond-1-gbs.html" rel="alternate"/><published>2010-11-11T22:40:00+01:00</published><updated>2010-11-11T22:40:00+01:00</updated><author><name>Louwrentius</name></author><id>tag:louwrentius.com,2010-11-11:/linux-network-interface-bonding-trunking-or-how-to-get-beyond-1-gbs.html</id><summary type="html">&lt;p&gt;This article discusses Linux bonding and how to achieve 2 Gb/s transfer speeds
with a single TCP/UDP connection.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;UPDATE July 2011&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Due to hardware problems, I was not able to achieve transfer speeds&lt;/em&gt; 
&lt;em&gt;beyond 150 MB/s. By replacing a network card with one from another&lt;/em&gt;
&lt;em&gt;vendor (HP …&lt;/em&gt;&lt;/p&gt;</summary><content type="html">&lt;p&gt;This article discusses Linux bonding and how to achieve 2 Gb/s transfer speeds
with a single TCP/UDP connection.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;UPDATE July 2011&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Due to hardware problems, I was not able to achieve transfer speeds&lt;/em&gt; 
&lt;em&gt;beyond 150 MB/s. By replacing a network card with one from another&lt;/em&gt;
&lt;em&gt;vendor (HP Broadcom) I managed to obtain 220 MB/s which is about 110 MB/s&lt;/em&gt; 
&lt;em&gt;per network interface.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;So I am now able to copy a single file with the 'cp' command over an NFS share&lt;/em&gt; 
&lt;em&gt;with 220 MB/s.&lt;/em&gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;&lt;strong&gt;Update January 2014&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;See &lt;a href="https://louwrentius.com/achieving-340-mbs-network-file-transfers-using-linux-bonding.html"&gt;this new article&lt;/a&gt; on how I got 340 MB/s transfer speeds.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;I had problems with a intel e1000e PCIe card in an intel DH67BL. I tested with
different e1000e PCIe models but to no avial. RX was 110 MB/s. TX was always no 
faster than 80 MB/s. A HP Broadcom gave no problems and also provided 110 MB/s
for RX traffic. LSCPI output:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;Broadcom Corporation NetXtreme BCM5721 Gigabit Ethernet PCI Express&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;The on-board e1000e NIC performed normal, all PCIe e1000e cards with different
chipsets never got above 80 MB/s.&lt;/p&gt;
&lt;p&gt;A gigabit network card provides about 110 MB/s (megabytes) of bandwidth. If
you want to go faster, the options are:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;buy infiniband stuff: I have no experience with it, may be smart thing to
do but seems expensive.&lt;/li&gt;
&lt;li&gt;buy 10Gigabit network cards: very very expensive compared to other
solutions.&lt;/li&gt;
&lt;li&gt;strap multiple network interfaces together to get 2 Gb/s or more with
more cards.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;This article is discussing the third option. Teaming or bonding two network
cards to a single virtual card that provides twice the bandwidth will provide
you with that extra performance that you where looking for. But the 64000 
dollar question is:&lt;/p&gt;
&lt;p&gt;&lt;em&gt;How to obtain 2 Gb/s with a &lt;strong&gt;single &lt;/strong&gt;transfer? Thus with a single TCP
connection?&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Answer:&lt;/em&gt; The trick is to use Linux network bonding.&lt;/p&gt;
&lt;p&gt;Most bonding options only provide an accumulated performance of 2 Gb/s, by
balancing different network connections over different interfaces. Individual
transfers will never reach beyond 1 Gbit/s but it is possible to have two 1
Gb/s transfers going on at the same time.&lt;/p&gt;
&lt;p&gt;That is not what I was looking for. I want to copy a file using NFS and just
get more than just 120 MB/s.&lt;/p&gt;
&lt;p&gt;The only bonding mode that supports single TCP or UDP connections to go beyond
1 Gb/s is mode 0: Round Robin. This bonding mode is kinda like RAID 0 over two
or more network interfaces.&lt;/p&gt;
&lt;p&gt;However, you cannot use Round Robin with a standard switch. You need an
advanced switch that is capable of creating "trunks". A trunk is a virtual
network interface, that consists of individual ports that are grouped
together". So you cannot use Round Robin mode with an average unmanaged
switch. The only other option is to use direct cables between two hosts,
although I didn't tested this.&lt;/p&gt;
&lt;h3&gt;Results&lt;/h3&gt;
&lt;p&gt;&lt;em&gt;UPDATE July 2011&lt;/em&gt; : 
Read the update at the top.&lt;/p&gt;
&lt;p&gt;Now the results: I was able to obtain a transferspeed (read) of 155 MB/s with
a file copy using NFS. Normal transfers capped at 109 MB/s. To be honest: I
had hoped to achieve way more, like 180MB/s. However, the actual transfer
speeds that will be obtained will depend on the hardware used. I recommend
using Intel or Broadcom hardware for this purpose.&lt;/p&gt;
&lt;p&gt;Also, I was not able to obtain write speed that surpasses the 1 Gb/s. Since I
used a fast RAID array to write the data to, the underlying storage subsystem
was not the bottleneck.&lt;/p&gt;
&lt;p&gt;So the bottom line is that it is possible to get more than 1 Gb/s but the
performance gain is not as high as you may want to.&lt;/p&gt;
&lt;h3&gt;Configuration:&lt;/h3&gt;
&lt;p&gt;&lt;em&gt;Client:&lt;/em&gt;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;modprobe bonding mode=0
ifconfig bond0 up
ifenslave bond0 eth0 eth1
ifconfig bond0 10.0.0.1 netmask 255.255.255.0
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;em&gt;Server:&lt;/em&gt;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;modprobe bonding mode=4 lacp_rate=0 xmit_hash_policy=layer3+4
ifconfig bond0 up
ifenslave bond0 eth0 eth1
ifconfig bond0 10.0.0.2 netmask 255.255.255.0
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Bonding status:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="nx"&gt;cat&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;proc&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;net&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;bonding&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;bond0&lt;/span&gt;

&lt;span class="nx"&gt;Ethernet&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;Channel&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;Bonding&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;Driver&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;v3&lt;/span&gt;&lt;span class="m m-Double"&gt;.3.0&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;June&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;2008&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nx"&gt;Bonding&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;Mode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;IEEE&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m m-Double"&gt;802.3&lt;/span&gt;&lt;span class="nx"&gt;ad&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;Dynamic&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;link&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;aggregation&lt;/span&gt;
&lt;span class="nx"&gt;Transmit&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;Hash&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;Policy&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;layer3&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nx"&gt;MII&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;Status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;up&lt;/span&gt;
&lt;span class="nx"&gt;MII&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;Polling&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;Interval&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;ms&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;
&lt;span class="nx"&gt;Up&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;Delay&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;ms&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;
&lt;span class="nx"&gt;Down&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;Delay&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;ms&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;

&lt;span class="m m-Double"&gt;802.3&lt;/span&gt;&lt;span class="nx"&gt;ad&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;info&lt;/span&gt;
&lt;span class="nx"&gt;LACP&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;rate&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;slow&lt;/span&gt;
&lt;span class="nx"&gt;Active&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;Aggregator&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;Info&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="nx"&gt;Aggregator&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;ID&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;
&lt;span class="nx"&gt;Number&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;of&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;ports&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;
&lt;span class="nx"&gt;Actor&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;Key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;9&lt;/span&gt;
&lt;span class="nx"&gt;Partner&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;Key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;26&lt;/span&gt;
&lt;span class="nx"&gt;Partner&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;Mac&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;Address&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;00&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nx"&gt;de&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nx"&gt;ad&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nx"&gt;be&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nx"&gt;ef&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;90&lt;/span&gt;

&lt;span class="nx"&gt;Slave&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;Interface&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;eth0&lt;/span&gt;
&lt;span class="nx"&gt;MII&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;Status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;up&lt;/span&gt;
&lt;span class="nx"&gt;Link&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;Failure&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;Count&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;
&lt;span class="nx"&gt;Permanent&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;HW&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kd"&gt;addr&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;00&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nx"&gt;co&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nx"&gt;ff&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nx"&gt;ee&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nx"&gt;aa&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;00&lt;/span&gt;
&lt;span class="nx"&gt;Aggregator&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;ID&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;

&lt;span class="nx"&gt;Slave&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;Interface&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;eth1&lt;/span&gt;
&lt;span class="nx"&gt;MII&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;Status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;up&lt;/span&gt;
&lt;span class="nx"&gt;Link&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;Failure&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;Count&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;
&lt;span class="nx"&gt;Permanent&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;HW&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kd"&gt;addr&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;00&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nx"&gt;de&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nx"&gt;ca&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nx"&gt;fe&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nx"&gt;b1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="nx"&gt;d&lt;/span&gt;
&lt;span class="nx"&gt;Aggregator&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;ID&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</content><category term="Networking"/><category term="linux"/><category term="bonding"/><category term="trunking"/><category term="gigabit"/><category term="2gb"/></entry><entry><title>'Tool of the month: iftop - advanced bandwidth monitoring'</title><link href="https://louwrentius.com/tool-of-the-month-iftop-advanced-bandwidth-monitoring.html" rel="alternate"/><published>2010-04-20T20:56:00+02:00</published><updated>2010-04-20T20:56:00+02:00</updated><author><name>Louwrentius</name></author><id>tag:louwrentius.com,2010-04-20:/tool-of-the-month-iftop-advanced-bandwidth-monitoring.html</id><summary type="html">&lt;p&gt;The utility &lt;a href="http://www.ex-parrot.com/pdw/iftop/"&gt;iftop&lt;/a&gt; allows you to monitor bandwidth usage. It is in some
sense similar to tools like iptraf, dstat and bwm-ng. Iftop is more special
than those. Because iftop lets you monitor the speed of individual TCP / UDP
connections. Basically, you will be able to determine how much traffic …&lt;/p&gt;</summary><content type="html">&lt;p&gt;The utility &lt;a href="http://www.ex-parrot.com/pdw/iftop/"&gt;iftop&lt;/a&gt; allows you to monitor bandwidth usage. It is in some
sense similar to tools like iptraf, dstat and bwm-ng. Iftop is more special
than those. Because iftop lets you monitor the speed of individual TCP / UDP
connections. Basically, you will be able to determine how much traffic is
flowing between two hosts.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.ex-parrot.com/pdw/iftop/"&gt;It is definitely worth a try.&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt="iftop" src="https://louwrentius.com/static/images/iftop_normal.png" /&gt;&lt;/p&gt;</content><category term="Networking"/><category term="Uncategorized"/></entry><entry><title>WFS - WAN Failover Script now available</title><link href="https://louwrentius.com/wfs-wan-failover-script-now-available.html" rel="alternate"/><published>2010-04-10T18:05:00+02:00</published><updated>2010-04-10T18:05:00+02:00</updated><author><name>Louwrentius</name></author><id>tag:louwrentius.com,2010-04-10:/wfs-wan-failover-script-now-available.html</id><summary type="html">&lt;p&gt;Since I could not find a WAN failover script for Linux to my likening, I wrote
one myself. If you have any use for it: I put it on a Google code project.&lt;/p&gt;
&lt;p&gt;WFS tests the availability of your primary WAN connection and switches to your
secondary / backup connection when …&lt;/p&gt;</summary><content type="html">&lt;p&gt;Since I could not find a WAN failover script for Linux to my likening, I wrote
one myself. If you have any use for it: I put it on a Google code project.&lt;/p&gt;
&lt;p&gt;WFS tests the availability of your primary WAN connection and switches to your
secondary / backup connection when a failure is detected. When in failover
mode, WFS continues to monitor the availability of the primary WAN connection
and once it becomes available again, it switches back.&lt;/p&gt;
&lt;p&gt;For more information and a download, please take a look at the project:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://code.google.com/p/wanfailoverscript/"&gt;http://code.google.com/p/wanfailoverscript/&lt;/a&gt;&lt;/p&gt;</content><category term="Networking"/><category term="Uncategorized"/></entry><entry><title>HP Procurve "auto DoS" feature causing network problems</title><link href="https://louwrentius.com/hp-procurve-auto-dos-feature-causing-network-problems.html" rel="alternate"/><published>2010-04-07T18:51:00+02:00</published><updated>2010-04-07T18:51:00+02:00</updated><author><name>Louwrentius</name></author><id>tag:louwrentius.com,2010-04-07:/hp-procurve-auto-dos-feature-causing-network-problems.html</id><summary type="html">&lt;p&gt;A feature on more recent HP Procurve models (18xx series, such as 1810G etc.)
is called "Auto DoS". You can find it in the section "Security" and then
"Advanced security".&lt;/p&gt;
&lt;p&gt;If you enable the Auto DoS feature, traffic is blocked based on one of these
conditions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;the source port (TCP …&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;</summary><content type="html">&lt;p&gt;A feature on more recent HP Procurve models (18xx series, such as 1810G etc.)
is called "Auto DoS". You can find it in the section "Security" and then
"Advanced security".&lt;/p&gt;
&lt;p&gt;If you enable the Auto DoS feature, traffic is blocked based on one of these
conditions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;the source port (TCP / UDP) is identical to the destination port (NTP,
SYSLOG, etc)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;the source port (TCP / UDP) is 'privileged' thus in the range of 1 -1023.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This will cause all kinds of problems, but first this: "Why on earth is a
Layer 2 device filtering on Layer 3?". This is just insane.&lt;/p&gt;
&lt;p&gt;NTP does not work any more. Syslog traffic will not arive. VPN traffic may not
arrive.&lt;/p&gt;
&lt;p&gt;This issue cost me a lot of time to solve. I first blamed our Firewall, but
the actual traffic arrived on the tagged trunk port on the affected switch.
The traffic somehow was not sent to the switch port on which the destination
device was connected.&lt;/p&gt;
&lt;p&gt;Affected products:&lt;/p&gt;
&lt;p&gt;HP ProCurve 1810G - J9449A ( 8 ports ) and J9450A ( 24 ports )&lt;/p&gt;</content><category term="Networking"/><category term="Uncategorized"/></entry><entry><title>Laptop or netbook as router?</title><link href="https://louwrentius.com/laptop-or-netbook-as-router.html" rel="alternate"/><published>2009-09-20T11:19:00+02:00</published><updated>2009-09-20T11:19:00+02:00</updated><author><name>Louwrentius</name></author><id>tag:louwrentius.com,2009-09-20:/laptop-or-netbook-as-router.html</id><summary type="html">&lt;p&gt;If you want a router for distribution of internet to your computers at home,
there are several options.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;buy some embedded device from Linksys, Draytek, Asus, 3com, ZyXtel or
netgear&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This type of hardware is cheap, economical, and gets you up and running in a
few minutes. The downside is …&lt;/p&gt;</summary><content type="html">&lt;p&gt;If you want a router for distribution of internet to your computers at home,
there are several options.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;buy some embedded device from Linksys, Draytek, Asus, 3com, ZyXtel or
netgear&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This type of hardware is cheap, economical, and gets you up and running in a
few minutes. The downside is that you can't do much else with these things.
Yes, there are many custom firmwares, which allow you more freedom, but the
hardware is often the limiting factor.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;convert a regular PC into a router&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If you want more than just routing, building your own router using a(n) (old)
PC is the preferred course of action. The downside is that a PC often uses
more 'juice' than an embedded device.&lt;/p&gt;
&lt;p&gt;However, those new Atom-based PC's may be a very nice option. Just add a
second network card, though an USB-port or a low profile PCI card
and you have something far more flexible than an embedded router.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;convert a laptop into a router&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;It sounds a bit strange and silly at first to use a laptop as a router, but it
makes sense when you think of it.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;It is economical in terms of power usage&lt;/li&gt;
&lt;li&gt;It has a build-in UPS called a 'battery'&lt;/li&gt;
&lt;li&gt;It has a build-in screen and keyboard&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;All these things are an advantage regarding option 2.&lt;/p&gt;
&lt;p&gt;Nowadays you can have a netbook for only 300 euros. It is more expensive than
an embedded device, but almost as economical and provides much more
performance and flexibility.&lt;/p&gt;
&lt;p&gt;I've been running an old laptop as a router for 6 months without problems.
Unfortunately, the disk died due to old age, but that can happen to any
computer. I'm now running an old mac mini intel machine as a router. &lt;/p&gt;</content><category term="Networking"/><category term="laptop"/><category term="netbook"/><category term="router"/><category term="battery"/><category term="screen"/><category term="keyboard"/><category term="ion"/><category term="atom"/></entry></feed>