GVPE(5) | GNU Virtual Private Ethernet | GVPE(5) |
GNU-VPE - Overview of the GNU Virtual Private Ethernet suite.
GVPE is a suite designed to provide a virtual private network for multiple nodes over an untrusted network. This document first gives an introduction to VPNs in general and then describes the specific implementation of GVPE.
VPN is an acronym, it stands for:
Usually the emulated network is a normal IP or Ethernet, and the transport network is the Internet. However, using a VPN system like GVPE to connect nodes over other untrusted networks such as Wireless LAN is not uncommon.
In the case of GVPE, even participating nodes cannot sniff packets send to other nodes or spoof packets as if sent from other nodes, so communications between any two nodes is private to those two nodes.
GVPE provides a true multi-point network in which any number of nodes (at least a few dozen in practise, the theoretical limit is 4095 nodes) can participate.
Gvpe comes with two programs: one daemon (gvpe) and one control program (gvpectrl).
Please have a look at the gvpe.osdep(5) manpage for platform-specific information.
Gvpe hardcodes most encryption parameters. While this reduces flexibility, it makes the program much simpler and helps making buffer overflows impossible under most circumstances.
Here are a few recipes for compiling your gvpe, showing the extremes (fast, small, insecure OR slow, large, more secure), between which you should choose:
./configure --enable-hmac-length=4 --enable-rand-length=0
Minimize the header overhead of VPN packets (the above will result in only 4 bytes of overhead over the raw ethernet frame). This is a insecure configuration because a HMAC length of 4 makes collision attacks almost trivial.
./configure --enable-cipher=bf --enable-digest=md4
Use the fastest cipher and digest algorithms currently available in gvpe. MD4 has been broken and is quite insecure, though, so using another digest algorithm is recommended.
./configure --enable-hmac-length=16 --enable-rand-length=12 --enable-digest=ripemd610
This uses a 16 byte HMAC checksum to authenticate packets (I guess 8-12 would also be pretty secure ;) and will additionally prefix each packet with 12 bytes of random data.
In general, remember that AES-128 seems to be as secure but faster than AES-192 or AES-256, more randomness helps against sniffing and a longer HMAC helps against spoofing. MD4 is a fast digest, SHA1, RIPEMD160, SHA256 are consecutively better, and Blowfish is a fast cipher (and also quite secure).
In this section I will describe how to get a simple VPN consisting of three hosts up and running.
First you have to create a daemon configuration file and put it into the configuration directory. This is usually /etc/gvpe, depending on how you configured gvpe, and can be overwritten using the -c command line switch.
Put the following lines into /etc/gvpe/gvpe.conf:
udp-port = 50000 # the external port to listen on (configure your firewall) mtu = 1400 # minimum MTU of all outgoing interfaces on all hosts ifname = vpn0 # the local network device name node = first # just a nickname hostname = first.example.net # the DNS name or IP address of the host node = second hostname = 133.55.82.9 node = third hostname = third.example.net
The only other file necessary is the if-up script that initializes the virtual ethernet interface on the local host. Put the following lines into /etc/gvpe/if-up and make it executable (chmod 755 /etc/gvpe/if-up):
#!/bin/sh ip link set $IFNAME address $MAC mtu $MTU up [ $NODENAME = first ] && ip addr add 10.0.1.1 dev $IFNAME [ $NODENAME = second ] && ip addr add 10.0.2.1 dev $IFNAME [ $NODENAME = third ] && ip addr add 10.0.3.1 dev $IFNAME ip route add 10.0.0.0/16 dev $IFNAME
This script will give each node a different IP address in the 10.0/16 network. The internal network (if gvpe runs on a router) should then be set to a subset of that network, e.g. 10.0.1.0/24 on node first, 10.0.2.0/24 on node second, and so on.
By enabling routing on the gateway host that runs gvpe all nodes will be able to reach the other nodes. You can, of course, also use proxy ARP or other means of pseudo-bridging, or (best) full routing - the choice is yours.
Next you have to generate the RSA keys for the nodes. While you can set up GVPE so you can generate all keys on a single host and centrally distribute all keys, it is safer to generate the key for each node on the node, so that the secret/private key does not have to be copied over the network.
To do so, run the following command to generate a key pair:
gvpectrl -c /etc/gvpe -g nodekey
This will create two files, nodekey and nodekey.privkey. The former should be copied to /etc/gvpe/pubkey/nodename on the host where your config file is (you will have to create the pubkey directory first):
scp nodekey confighost:/etc/gvpe/pubkey/nodename
The private key nodekey.privkey should be moved to /etc/gvpe/hostkey:
mkdir -p /etc/gvpe mv nodekey.privkey /etc/gvpe/hostkey
Now distribute the config files and public keys to the other nodes.
The example uses rsync-over-ssh to copy the config file and all the public keys:
rsync -avzessh /etc/gvpe first.example.net:/etc/. --exclude hostkey rsync -avzessh /etc/gvpe 133.55.82.9:/etc/. --exclude hostkey rsync -avzessh /etc/gvpe third.example.net:/etc/. --exclude hostkey
You should now check the configuration by issuing the command gvpectrl -c /etc/gvpe -s on each node and verify it's output.
You should then start gvpe on each node by issuing a command like:
gvpe -D -l info first # first is the nodename
This will make the gvpe daemon stay in foreground. You should then see "connection established" messages. If you don't see them check your firewall and routing (use tcpdump ;).
If this works you should check your networking setup by pinging various endpoints.
To make gvpe run more permanently you can either run it as a daemon (by starting it without the -D switch), or, much better, from your inittab or equivalent. I use a line like this on all my systems:
t1:2345:respawn:/opt/gvpe/sbin/gvpe -D -L first >/dev/null 2>&1
... and play around. Sending a -HUP (gvpectrl -kHUP) to the daemon will make it try to connect to all other nodes again. If you run it from inittab gvpectrl -k (or simply killall gvpe) will kill the daemon, start it again, making it read it's configuration files again.
To run the GVPE daemon permanently from your SysV init, you can add it to your inittab, e.g.:
t1:2345:respawn:/bin/sh -c "exec nice -n-20 /path/to/gvpe -D node >/var/log/gvpe.log 2>&1"
For systems using systemd, you can use a unit file similar to this one:
[Unit] Description=gvpe After=network.target Before=remote-fs.target [Service] ExecStart=/path/to/gvpe -D node KillMode=process Restart=always [Install] WantedBy=multi-user.target
gvpe.osdep(5) for OS-dependent information, gvpe.conf(5), gvpectrl(8), and for a description of the transports, protocol, and routing algorithm, gvpe.protocol(7).
The GVPE mailing list, at <http://lists.schmorp.de/>, or gvpe@lists.schmorp.de.
Marc Lehmann <gvpe@schmorp.de>
GVPE itself is distributed under the GENERAL PUBLIC LICENSE (see the file COPYING that should be part of your distribution).
In some configurations it uses modified versions of the tinc vpn suite, which is also available under the GENERAL PUBLIC LICENSE.
2016-11-02 | 2.25 |