RTFM Josh!

One of my latest projects has been to get a VPN link up between my parent’s house and ours, so that I can help them out with computer issues without having to make the trek down to West Chester. Not that I don’t love visiting them (shamless parental plug, they do read this after all), but what with Taylor’s arrival and all we don’t get out much these days. Anyway, after thinking about how best to accomplish this I decided I should use a DD-WRT (open source alternative firmware) flashed Linksys router for the job, for a number of reasons:

  • Thanks to the generousity of a local gentlemen I know from Twitter I acquired one of these devices for free. Don’t ever say Twitter can’t get you stuff!
  • It’s low power and unobtrusive. While I love my big ol’ quad core monster, I didn’t really want to take up space at my parents house.
  • With DD-WRT, it functions great as an OpenVPN client.

Now, the setup was to look something like this:

VPN Diagram

(Please excuse the rather awful drawing, I’m afraid I’m used to Visio)

Once I had everything setup, everything appeared to work, except I couldn’t ping anything at my parent’s end of the tunnel from my home network (vice versa worked fine). Well, normally I might try and sniff the traffic at the two endpoints, but this was a little more complicated than you might think, since the router at my parents doesn’t support such an operation.

In then end, I was able to collect some data after hacking a solution (<geekery>I used an already compiled version of tcpdump and manually moved it to the router</geekry>), and figured out that for some reason the VPN router at my paren’t house was performing what’s known as “masquerading”, or “NATing”. What this means is that any traffic that passed out of it was translated such as to appear that it came directly from the router itself, and not some machine behind it. This novel concept is actually the basis for how pretty much every home router functions; but in this case it was bad, in that it made the tunnel between our networks essentially one way.

So what did I do? Well get royally annoyed of course, proceed to spend the next several hours pouring over the setup of both ends, trying various hacks, googling like crazy, and perhaps questioning my intellect (or that of the programmers of OpenVPN, DD-WRT, and Linux in general) a few times. Finally after giving up for a day, I decided I’d look at a tutorial on the OpenVPN site itself I remembered. It took awhile to find, but there was the answer, right in front of me.

Apparently OpenVPN needs a little special tweaking to allow for traffic from both the “client” (my parent’s house) and “server” (my house) networks to fully talk to each other:

<geekery>

Next, we will deal with the necessary configuration changes on the server side. If the server configuration file does not currently reference a client configuration directory, add one now:

In the above directive, ccd should be the name of a directory which has been pre-created in the default directory where the OpenVPN server daemon runs. On Linux this tends to be /etc/openvpn and on Windows it is usually \Program Files\OpenVPN\config. When a new client connects to the OpenVPN server, the daemon will check this directory for a file which matches the common name of the connecting client. If a matching file is found, it will be read and processed for additional configuration file directives to be applied to the named client.

The next step is to create a file called client2 in the ccd directory. This file should contain the line:

This will tell the OpenVPN server that the 192.168.4.0/24 subnet should be routed to client2.

Next, add the following line to the main server config file (not the ccd/client2 file):

Why the redundant route and iroute statements, you might ask? The reason is that route controls the routing from the kernel to the OpenVPN server (via the TUN interface) while iroute controls the routing from the OpenVPN server to the remote clients. Both are necessary.

Yep, you read correctly. “Both are necessary.” Long story short, I only had one of the two necessary configurations in place. Basically, while the normal

command got the packets as far as the OpenVPN tunnel, the software required that extra

configuration line to correctly send the traffic on its merry way from there. Without it, the traffic would just appear to go out the proper interface, but actually go to that awful place where packets disappear and are never seen again.

</geekery>

Hi everyone, my name is Josh, and yes, I admit it, I should have read the… oh hell you know what the rest means.

4 Comments

  1. Amazingly enough until you’ve actually run into serious problems and/or are attempting to be uber expert on something, most of the time the manual is unnecessary. From larger companies all the way down to ‘geek’ modders, most product makers realize that if their material/product is to be used and appreciated it needs to be understandable, at be least logical. There generally exists a short connection from the product at hand to the overall paradigm of the class of products it is part of (e.g. a browser is a browser is a browser). Hence by using in-kind knowledge, applying previous experiences and using relational logic we are guided through most activities (one-offs, idiot or malicious products are a different story). This is a huge benefit because not alll of use can be in on the design process.

    Further relegating product specific manuals to the recycling bin is the art of the Google . Searches provide contextual results as people pour out their stories of how they got into a mess (see above), most manuals on the other hand speak in terms of linear steps. (of course the example above was using a tuturial – a bit of a hybrid of real-world and a linear approach – not necessarily a classic manual usually referred to in RTFM)

    Going even further, a paper manual can be a handy tool of course if the almighty internet is unavailable. Additionally, the physical manifestation can have notes written in them for easy future reference. And of course when you just need to get to that article on that forum that you swore said how to fix the problem, but you just can’t remember the search terms or find that the historic article has been purged, well then reaching for that paper sometimes is not such a bad idea after all!

    Reply

  2. BTW – before attempting to do anything remote, I recommend a lab locally to prove out it works or have a geek on the other side to fix problems simultaneously.

    Reply

    1. @Michael – Whoa, that’s a nice dissertation on manuals! Thanks for the comments. I totally agree on the lab thing BTW; I had actually set up a little mini-POC for this before, but naturally, since I didn’t follow the same ruthless documentary procedures I do at work, I didn’t record how exactly I got the whole thing to work. Lesson learned.

      On that “idiot” software comment: might you be speaking from experience? đŸ™‚

      Reply

  3. Go to your local mega-bookstore and check for Linux publications in the MAGAZINE section. There are several European mags (Linux Format and Linux Magazine=Linux Pro Magazine in the US) and there are some US-specific mags as well, and they have DVDs with the mags. Problem, you need a dvd reader to use them. Linux Pro Magazine put out an Ubuntu Special Edition just this month, with DVD. Linux Format has a 6 flavor *buntu DVD this month. You might be intersted in the Xubuntu version.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

 

This site uses Akismet to reduce spam. Learn how your comment data is processed.