
vtund, the Virtual Tunnel daemon.*†
pppd, the PPP daemon
iptables, management software for the Linux Kernel's
netfilter (iptables) packet filter.* (Just for the Linux box at CMU)
pppd and vtund. The former
comes installed by default on MacOS X and most Linux systems; if you don't
have it, it should be easy to come by. The latter is a little more obscure.
Major Linux distributions have it as an optional package, and RPMs and
.deb files are available on the
VTUN website.
On OS X, you have to install it yourself. If you're truly hardcore, you'll
download it along with all the libraries it needs (lzo, openssl, and more)
and set it up on your own. I use
Fink instead, which delivers
creamy open source software goodness to my OS X machine with a relative
minimum of fuss. If you've already got a source-based install of Fink
going, just do fink install vtun and you're all set. (Those of you
who use a binary Fink install aren't using Jaguar at the time of writing,
but maybe vtun is available to you too through the normal means.) (If you
haven't tried Fink yet, it's a good thing, but getting it all set up might
take more time than all of this is worth.)
Now that you've installed pppd and vtun at home,
you should have no trouble doing the same thing on your Linux box
at CMU. Once you're done with that, see if iptables is
installed (look for /sbin/iptables); if not, your distribution
will have a package for you. I snagged mine off
www.rpmfind.net, thinking wistfully
of the days when I used to administrate
Debian systems. Anyway, go ahead and
install it. Everything should be ready for...
vtund.conf
files on your home and CMU computers. On my CMU box, vtund
expects to find this file in /etc, the standard place for
system-wide configuration files. On my OS X box, Fink's version of
vtund looks for it in /sw/etc, but I keep it
somewhere else entirely just to be special.
Rather than give you a nice conceptual overview of what we're going to make
vtund.conf command vtund to do, I'm going to give
you a pair of highly-annotated vtund.conf files for both ends
of the connection that do their best to indicate what's going on. You could
plunk both files onto your computers without looking at them at all, but you
ought to read the commentary. Not only is it entertaining and insightful
(and modest!), it also alerts you to things you need to change for your
system, like, for example, your secret password for the tunnel.
vtund.conf
#
# The vtund.conf file for the CMU computer.
# This file is full of options that pertain to this computer's role as the
# server, which in this case means it sits around waiting for your home
# computer to instigate a tunnel.
#
# This configuration file requires that your kernel be compiled with
# netfilter (AKA iptables) and iptables_nat available as modules.
# Facilitized machines should be OK in this regard. If you're using an
# older kernel with ipchains or (heaven forfend!) ipfwadm, you'll have
# to modify this file heavily to your needs.
#
# We start with general options. These should be right for most Linux
# installations--hopefully you shouldn't have to use this.
options {
port 5000; # Listen on this port.
syslog daemon; # Syslog facility.
ppp /usr/sbin/pppd; # Path to the PPP daemon
ifconfig /sbin/ifconfig; # Path to ifconfig (not used!)
route /sbin/route; # Path to route (not used!)
firewall /sbin/iptables; # Path to iptables
}
# These are default options for tunnel sessions. Our tunnel session
# configuration ignores these, so you should too.
default {
compress no; # Compression is off by default
speed 0; # By default maximum speed, NO shaping
}
# Here are the specific options for our license server tunnel. The name
# reflects the fact that we're using PPP in our encapsulation scheme, among
# other things.
license-servers-suck-PPP {
# Tunnel session password. YOU SHOULD CHANGE THIS! If you don't, someone
# else will be able to start a tunnel to your machine and--run MATLAB!
# Seriously, in addition to the fact that CMU probably doesn't want
# folks violating its site license (we're just "bending" it a bit),
# it also gives the intruder plenty of ways to try and subvert vtund,
# which could lead to the subversion of your entire system. So, really,
# change this.
pass IfIDontChangeThisImADork;
# OK, don't change any of the next five options. They should work on all
# machines.
type tty; # tty tunnel
proto tcp; # TCP protocol
comp lzo:9; # LZO compression level 9
encr yes; # Encryption
keepalive yes; # Keep connection alive
# This section describes what vtund should do after a tunnel has
# been established between this computer and your home computer.
up {
# The first thing to do is insert the PPP module into the kernel.
# Linux kernels portion some of their functionality into modules,
# which can be inserted and removed from the kernel depending on
# whether you need to use them. A computer sitting on an ethernet
# usually doesn't need the PPP module, so we take the precaution of
# installing it. If it's already installed, nothing happens.
program /sbin/modprobe "ppp_generic" wait;
# OK, start the PPP connection! We give ourselves the IP 10.0.0.1
# and the home computer the IP 10.0.0.2 (don't worry, your computer
# can have multiple IP addressess). All IP addresses starting with 10
# are officially designated as local addresses that you can assign
# to your own machines at whim.
ppp "10.0.0.1:10.0.0.2 proxyarp";
# Here's where we set up the firewall I was talking about earlier.
# WARNING: if your computer is already behaving as a firewall, you
# had better be really careful here! I bet this will work, but it's
# not my lab network on the line, now is it?
#
# OK, so the first thing we do is insert the relevant kernel modules.
program /sbin/modprobe "iptable_nat" wait;
# We turn on firewalling functionality (not a precise term--don't
# use to impress your friends) in the kernel by putting a '1' into
# a special file.
program /bin/sh "echo 1 > /proc/sys/net/ipv4/ip_forward" wait;
# Now we enable the firewall rule that forwards all packets out
# of the tunnel not destined for 10.0.0.1 onto the CMU network.
firewall "-t nat -A POSTROUTING -o eth0 -s 10.0.0.0/24 -j MASQUERADE";
};
# This section describes what vtund should do when the tunnel is
# terminated after a hard day of tunneling.
down {
# We simply disable the firewall rule we set up when we started
# the tunnel.
firewall "-t nat -D POSTROUTING -o eth0 -s 10.0.0.0/24 -j MASQUERADE";
# Remember that PPP connection? No reason to stop it--it
# killed itself.
# Remember all those modules we loaded? Your machine probably has
# 1 GB of RAM or something like that--they won't hurt anything by
# staying resident in memory. So we could remove them, but we
# won't.
};
}
[ Download this file ]
vtund.conf
#
# The vtund.conf file for the home computer.
# This file is full of options that pertain to this computer's role as the
# client, which in this case means it contacts the CMU computer to instigate
# a tunnel when you start it.
#
# Here, once again, are general options. These are right for OS X 10.2.2
# and should be right for most Linux installations.
options {
port 5000; # Connect to this port.
timeout 60; # General timeout
ppp /usr/sbin/pppd; # Path to the PPP daemon
ifconfig /sbin/ifconfig; # Path to ifconfig (not used!)
route /sbin/route; # Path to route
firewall /sbin/iptables; # Path to firewall configurator (not used!)
}
# The specific options for our license server tunnel.
license-servers-suck-PPP {
# You have been properly warned about changing your password. Since
# you've done that, now you should make certain that your passwords in
# both the CMU and home computer vtund.conf files are the same. See,
# I actually lied up there--things won't work if you just use these
# files without looking at them, since the passwords don't match.
pass IAmASuperDorkIfIDontChangeThis;
# OK, don't change this. I don't think it matters much.
persist yes; # Persist mode
# This section describes what vtund should do after a tunnel has
# been established between this computer and the CMU computer.
up {
# First, start the PPP connection! The PPP daemon will get its IP
# (10.0.0.2, remember?) from the CMU computer.
#
# MacOS X doesn't need a PPP module installed into its kernel, but
# Linux may. Don't forget to add a line loading the PPP module
# (just like the one in the other file) before this line if you're
# using Linux at home.
ppp "noipdefault";
# Here's the final component of the setup. We tell OS X to route
# all TCP/IP traffic to the license server (which has the IP
# 128.2.194.30, it turns out) through our new connection!
#
# This command is specific to MacOS X! For Linux, I think you
# want this instead:
# route "add -host 128.2.194.30 gw 10.0.0.1";
# I don't know for sure, though--experiment and let me know!
route "add -host 128.2.194.30 10.0.0.1";
};
# This section describes what vtund should do when the tunnel is
# terminated after a hard day of tunneling.
down {
# Here we just delete that special routing instruction we specified
# when the tunnel was established.
#
# This command is specific to MacOS X! For Linux, I think you
# want this instead:
# route "del -host 128.2.194.30 gw 10.0.0.1";
# I don't know for sure, though--experiment and let me know!
route "delete -host 128.2.194.30 10.0.0.1";
# The PPP connection just killed itself--no need to worry about it.
};
}
[ Download this file ]
Once you've finished putting these files in place, you'll probably want to
change the permissions to 600 (owner read/write only), since they have
your passwords inside. You may not have any other users on your computer,
but sometimes buggy webservers/FTP servers/etc. can allow someone to read
world-readable files on your computer from anywhere on the Internet. Best
not to risk it.
Hopefully this should take care of all of the configuration. Now you're all
set to go!
up and down parts of the vtund.conf
files, usage
is about as much like a light switch as UNIX console-based network apps get.
vtund on your CMU box, since
this computer is configured to be the server. Assuming you've stuck the
vtund.conf file in the default location (probably
etc), issue this command as root, which tells vtund
to start up as a server (-s) in the session we named
license-servers-suck-PPP.
[root@your_rad_CMU_box /]# /usr/sbin/vtund -s license-servers-suck-PPPYou'll be returned to the prompt immediately, since
vtund is
a daemon. Now you start vtund on the MacOS X side with a
command like the following. Here, you're telling it to look for the
vtund.conf file in a nonstandard location
(-f ~yourname/etc/vtund.conf), to use the
license-servers-suck-PPP session, and to connect to the
vtun server you just started up at your_rad_CMU_box.cs.cmu.edu .
We're also using sudo to get root here, since that's the MacOS X way.
[your_rad_osx_box:~] yourname% sudo vtund -f ~yourname/etc/vtund.conf license-servers-suck-PPP your_rad_CMU_box.cs.cmu.edu
vtunds several seconds to set everything up,
then just start the applications normally.
Make sure you keep the tunnel running while you use your application, since
many of them like to check with the license server again every so often to
make certain you're still using the software legitimately. Ugh. If your
network connection drops out for a minute or two occasionally, don't worry,
we've configured vtund to reestablish the connection if it
can.
kill the vtund process on
the client side, then the one on the server side after a couple seconds.
If they don't die easily, use the -9 flag.
Technically you don't have to kill vtund on the server side,
but it's good network citizenship to turn it off when you're not using it.
The more network daemons you run as root on your computer, the greater your
chances that you're running one with a bug, and thus the greater the chance an
attacker can completely subvert your machine. If your machine is subverted,
it makes it easier for the attacker to subvert other machines on the CMU
network. The moral: don't run network daemons as root unless you have to.
November 2002. Images and trademarks used without
permission and with malicious intent aforethought.
Back to my homepage