ClearOS is the latest incarnation of ClarkConnect, a linux-based router/network appliance distribution produced by the similarly re-branded Clear Foundation.
This post will show you how to gently abuse Gateway Mode to set up a single PPTP tunnel for use with multiple private subnets if you need to use a standalone VPN server. This does not apply if your VPN server is the gateway for your private subnets.
If you run a large network chances are you don’t want to bugger up your clients’ ability to pptp out. That means, for all practical “supported” purposes, you can’t use your ClearOS/CC gateway(s) as PPTP servers. The answer of course is to set up a “standalone” VPN server. If you’re working with a $0 budget or you pay for your rack space this might not be an attractive solution. You can always turn an existing physical server into a VPN gateway but for the purposes of this guide we’re going to assume you have a dedicated server or virtual machine.
In both cases the machine needs to have no less than two ethernet interfaces. If you’re using a VM I find that Clear fits nicely into 96 megs of ram with 20 megs room to breathe once you’ve trimmed off all the crap you don’t need (hald, messagebus, iscsid, etc – anything you won’t use on a VM unless you’re an X nut). Use
for every excess service that loads in runlevel3. If you use physical hardware you will need to ensure both NICs are plugged into a switch otherwise they won’t come up on boot (or, naturally, you can alter the networking init script).
For this example, you have three private networks at headquarters:
And your client will be on a local NATted subnet of say
Log into the webconfig of your new VPN server. Make sure Gateway Mode is selected. Set eth0 to external mode and assign a routed public address and gateway to it, this is the IP you’re going to come in on. Now for each of the private networks add an IP to a virtual interface ON ETH0. Add an IP somewhere that will never be used to eth1 thus:
By now you’re wondering why we have this dummy eth1 that does nothing. It’s very simple – we’re tricking CC into routing these subnets over the vpn by using the built in Gateway Mode. I can’t stress this enough: what we’re doing is not ideologically correct. It is, however, clean and simple.
Enable the PPTP server if you have not already done so and set the IP pools to some unobstructed address space on one of your private subnets. Make sure the ClearOS firewall is happy passing GRE (it will tell you if it’s not on the PPTP webconfig page).
Now on the client end you’re going to create a PPTP connection just like you always would except for one twist: once the connection is established add the private subnets to the client’s routing table on the ppp interface thus:
And presto! You can talk to any host on any of those networks with one IP and one tunnel thanks to a gentle abuse of Gateway Mode. I like to speed this up by adding those lines to a short shell script.
If you’re a windows user, leaving Use Remote Gateway checked in the connection preferences will get you the same effect with one small hitch – all of your traffic (web browsing, chat etc) will be routed through your VPN and any time you connect or disconnect whatever open connections you have will be reset.
Without getting too much into details you want to (at a CLI) type:
remember the hex number for your PPP connection. Type:
route add 10.0.0.0 mask 255.0.0.0 192.168.0.66 metric 2 if (hex number)
You probably don’t need the metric bit but some of the people connecting to my particular vpn server will sometimes be connecting to their own subnets and that’s bad for routing. Substitute 192.168.0.66 with the private IP your VPN server sits on in the same subnet as the PPTP IP pool.
Naturally, replace 10.0.0.0/8 with whatever private subnet you’re trying to add (you don’t need to do the subnet you’re actually put on by the PPTPd, that’s automagic). For additional subnets: Lather. Rinse. Repeat.
Everything I’ve read so far says windows will automagically detect what interface to use based on the gateway you specified but that hasn’t worked for me. If it works for you, great! Use the -p flag to save the routes to your registry. You will find however that there is nothing static about windows interface numbers particularly when dealing with on-again-off-again VPN connections.