| 1 |
|
| 2 |
==== NAME ==== |
| 3 |
|
| 4 |
vpe - Overview of the virtual private ethernet suite. |
| 5 |
|
| 6 |
|
| 7 |
==== DESCRIPTION ==== |
| 8 |
|
| 9 |
Vpe is a suite designed to provide a virtual private network for |
| 10 |
multiple nodes over an untrusted network. |
| 11 |
|
| 12 |
"Virtual" means that no physical network is created (of course), but an |
| 13 |
ethernet is emulated by creating multiple tunnels between the member |
| 14 |
nodes. "Private" means that non-participating nodes cannot decode |
| 15 |
("sniff)" nor inject ("spoof") packets. In the case of vpe, even |
| 16 |
participating nodes cannot spoof packets from other nodes. And "network" |
| 17 |
means that more than two parties - many so-called vpn solutions only |
| 18 |
create point-to-point tunnels - can participate in the network, so it's |
| 19 |
possible to connect multiple branches of a company into a single |
| 20 |
network. |
| 21 |
|
| 22 |
|
| 23 |
== DESIGN GOALS == |
| 24 |
|
| 25 |
: SIMPLE DESIGN |
| 26 |
Cipher, HMAC algorithms and other key parameters must be selected at |
| 27 |
compile time - this makes it possible to only link in algorithms you |
| 28 |
actually need. It also makes the crypto part of the source very |
| 29 |
transparent and easy to inspect. |
| 30 |
|
| 31 |
: EASY TO SETUP |
| 32 |
A few lines of config (the config file is shared unmodified between |
| 33 |
all hosts) and a single run of ``vpectrl'' to generate the keys |
| 34 |
suffices to make it work. |
| 35 |
|
| 36 |
: MAC-BASED SECURITY |
| 37 |
Since every host has it's own private key, other hosts cannot spoof |
| 38 |
traffic from this host. That makes it possible to filter packest by |
| 39 |
MAC address, e.g. to ensure that packets from a specific IP address |
| 40 |
come, in fact, from a specific host. |
| 41 |
|
| 42 |
|
| 43 |
==== PROGRAMS ==== |
| 44 |
|
| 45 |
Vpe comes with two programs: one daemon (``vped'') and one control |
| 46 |
program (``vpectrl''). |
| 47 |
|
| 48 |
: vpectrl |
| 49 |
Is used to generate the keys, check and give an overview of of the |
| 50 |
configuration and contorl the daemon (restarting etc.). |
| 51 |
|
| 52 |
: vped |
| 53 |
Is the daemon used to establish and maintain conenctions to the |
| 54 |
other network members. It should be run on the gateway machine. |
| 55 |
|
| 56 |
|
| 57 |
==== COMPILETIME CONFIGURATION ==== |
| 58 |
|
| 59 |
Here are a few recipes for compiling your vpe: |
| 60 |
|
| 61 |
|
| 62 |
== AS LOW PACKET OVERHEAD AS POSSIBLE == |
| 63 |
|
| 64 |
./configure --enable-hmac-length=4 --enable-rand-length=0 |
| 65 |
|
| 66 |
Minimize the header overhead of VPN packets (the above will result in |
| 67 |
only 4 bytes of overhead over the raw ethernet frame). |
| 68 |
|
| 69 |
|
| 70 |
== MINIMIZE CPU TIME REQUIRED == |
| 71 |
|
| 72 |
./configure --enable-cipher=bf --enable-digest=md4 |
| 73 |
|
| 74 |
Use the fastest cipher and digest algorithms currently available in vpe. |
| 75 |
|
| 76 |
|
| 77 |
== MAXIMIZE SECURITY == |
| 78 |
|
| 79 |
./configure --enable-hmac-length=16 --enable-rand-length=8 --enable-digest=sha1 |
| 80 |
|
| 81 |
This uses a 16 byte HMAC checksum to authenticate packets (I guess 8-12 |
| 82 |
would also be pretty secure ;) and will additionally prefix each packet |
| 83 |
with 8 bytes of random data. |
| 84 |
|
| 85 |
In general, remember that AES-128 seems to be more secure and faster |
| 86 |
than AES-192 or AES-256, more randomness helps against sniffing and a |
| 87 |
longer HMAC helps against spoofing. MD4 is a fast digest, SHA1 or |
| 88 |
RIPEMD160 are better, and Blowfish is a fast cipher (and also quite |
| 89 |
secure). |
| 90 |
|
| 91 |
|
| 92 |
==== HOW TO SET UP A SIMPLE VPN ==== |
| 93 |
|
| 94 |
In this section I will describe how to get a simple VPN consisting of |
| 95 |
three hosts up and running. |
| 96 |
|
| 97 |
|
| 98 |
== STEP 1: configuration == |
| 99 |
|
| 100 |
First you have to create a daemon configuation file and put it into the |
| 101 |
configuration directory. This is usually ``/etc/vpe'', depending on how |
| 102 |
you configured vpe, and can be overwritten using the ``-c'' commandline |
| 103 |
switch. |
| 104 |
|
| 105 |
Put the following lines into ``/etc/vpe/vped.conf'': |
| 106 |
|
| 107 |
udp-port = 50000 # the external port to listen on (configure your firewall) |
| 108 |
mtu = 1400 # minimum MTU of all outgoing interfaces on all hosts |
| 109 |
ifname = vpn0 # the local network device name |
| 110 |
|
| 111 |
node = first # just a nickname |
| 112 |
hostname = first.example.net # the DNS name or IP address of the host |
| 113 |
|
| 114 |
node = second |
| 115 |
hostname = 133.55.82.9 |
| 116 |
|
| 117 |
node = third |
| 118 |
hostname = third.example.net |
| 119 |
|
| 120 |
The only other file neccessary if the ``if-up'' script that initializes |
| 121 |
the local ethernet interface. Put the following lines into |
| 122 |
``/etc/vpe/if-up'' and make it execute (``chmod 755 /etc/vpe/if-up''): |
| 123 |
|
| 124 |
#!/bin/sh |
| 125 |
ip link set $IFNAME address $MAC mtu $MTU up |
| 126 |
[ $NODENAME = first ] && ip addr add 10.0.1.1 dev $IFNAME |
| 127 |
[ $NODENAME = second ] && ip addr add 10.0.2.1 dev $IFNAME |
| 128 |
[ $NODENAME = third ] && ip addr add 10.0.3.1 dev $IFNAME |
| 129 |
ip route add 10.0.0.0/16 dev $IFNAME |
| 130 |
|
| 131 |
This script will give each node a different IP address in the |
| 132 |
``10.0/16'' network. The internal network (e.g. the ``eth0'' interface) |
| 133 |
should then be set to a subset of that network, e.g. ``10.0.1.0/24'' on |
| 134 |
node ``first'', ``10.0.2.0/24'' on node ``second'', and so on. |
| 135 |
|
| 136 |
By enabling routing on the gateway host that runs ``vped'' all nodes |
| 137 |
will be able to reach the other nodes. You can, of course, also use |
| 138 |
proxy arp or other means of pseudo-bridging (or even real briding), or |
| 139 |
(best) full routing - the choice is yours. |
| 140 |
|
| 141 |
|
| 142 |
== STEP 2: create the RSA key pairs for all hosts == |
| 143 |
|
| 144 |
Run the following command to generate all key pairs (that might take a |
| 145 |
while): |
| 146 |
|
| 147 |
vpectrl -c /etc/vpe -g |
| 148 |
|
| 149 |
This command will put the public keys into |
| 150 |
``/etc/vpe/pubkeys/*nodename*'' and the private keys into |
| 151 |
``/etc/vpe/hostkeys/*nodename*''. |
| 152 |
|
| 153 |
|
| 154 |
== STEP 3: distribute the config files to all nodes == |
| 155 |
|
| 156 |
Now distribute the config files to the other nodes. This should be done |
| 157 |
in two steps, since the private keys should not be distributed. The |
| 158 |
example uses rsync-over-ssh |
| 159 |
|
| 160 |
First all the config files without the hostkeys should be distributed: |
| 161 |
|
| 162 |
rsync -avzessh /etc/vpe first.example.net:/etc/. --exclude hostkeys |
| 163 |
rsync -avzessh /etc/vpe 133.55.82.9:/etc/. --exclude hostkeys |
| 164 |
rsync -avzessh /etc/vpe third.example.net:/etc/. --exclude hostkeys |
| 165 |
|
| 166 |
Then the hostkeys should be copied: |
| 167 |
|
| 168 |
rsync -avzessh /etc/vpe/hostkeys/first first.example.net:/etc/hostkey |
| 169 |
rsync -avzessh /etc/vpe/hostkeys/second 133.55.82.9:/etc/hostkey |
| 170 |
rsync -avzessh /etc/vpe/hostkeys/third third.example.net:/etc/hostkey |
| 171 |
|
| 172 |
You should now check the configration by issuing the command ``vpectrl |
| 173 |
-c /etc/vpe -s'' on each node and verify it's output. |
| 174 |
|
| 175 |
|
| 176 |
== STEP 4: starting vped == |
| 177 |
|
| 178 |
You should then start vped on each node by issuing a command like: |
| 179 |
|
| 180 |
vped -D -linfo first # first is the nodename |
| 181 |
|
| 182 |
This will make the vped stay in foreground. You should then see |
| 183 |
"connection established" messages. If you don't see them check your |
| 184 |
firewall and routing (use tcpdump ;). |
| 185 |
|
| 186 |
If this works you should check your networking setup by pinging various |
| 187 |
endpoints. |
| 188 |
|
| 189 |
To make vped run more permanently you can either run it as a daemon (by |
| 190 |
starting it without the ``-D'' switch), or, much better, from your |
| 191 |
inittab. I use a line like this on my systems: |
| 192 |
|
| 193 |
t1:2345:respawn:/opt/vpe/sbin/vped -D -L first >/dev/null 2>&1 |
| 194 |
|
| 195 |
|
| 196 |
== STEP 5: enjoy == |
| 197 |
|
| 198 |
... and play around. Sending a -HUP (``vpectrl -kHUP'') to the daemon |
| 199 |
will make it try to connect to all other nodes again. If you run it from |
| 200 |
inittab, as is recommended, ``vpectrl -k'' (or simply ``killall vped'') |
| 201 |
will kill the daemon, start it again, making it read it's configuration |
| 202 |
files again. |
| 203 |
|
| 204 |
|
| 205 |
==== SEE ALSO ==== |
| 206 |
|
| 207 |
vpe(8), vpectrl(8), vped.conf(5). |
| 208 |
|
| 209 |
|
| 210 |
==== AUTHOR ==== |
| 211 |
|
| 212 |
Marc Lehmann <vpe@plan9.de> |
| 213 |
|