ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/gvpe/doc/gvpe.texi
Revision: 1.4
Committed: Mon Sep 1 05:31:28 2008 UTC (15 years, 8 months ago) by pcg
Content type: application/x-texinfo
Branch: MAIN
CVS Tags: rel-2_2, rel-2_21, rel-2_22
Changes since 1.3: +1 -1 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 pcg 1.1 \input texinfo @c -*-texinfo-*-
2     @c GENERATED FILE, gvpe.texi.pod is the source, not gvpe.texi!
3     @c GENERATED FILE, gvpe.texi.pod is the source, not gvpe.texi!
4     @c GENERATED FILE, gvpe.texi.pod is the source, not gvpe.texi!
5     @c GENERATED FILE, gvpe.texi.pod is the source, not gvpe.texi!
6     @c GENERATED FILE, gvpe.texi.pod is the source, not gvpe.texi!
7     @c GENERATED FILE, gvpe.texi.pod is the source, not gvpe.texi!
8     @c %**start of header
9     @finalout
10     @setfilename gvpe.info
11     @settitle GNU Virtual Private Ethernet Manual
12     @setchapternewpage odd
13     @c %**end of header
14    
15     @ifinfo
16     @dircategory Networking tools
17     @direntry
18     * gvpe: (gvpe). The GNU VPE Manual.
19     @end direntry
20    
21     This is the info manual for vpe, the Virtual Private Ethernet daemon.
22    
23 pcg 1.3 Copyright @copyright{} 2003-2008 Marc Lehmann <gvpe@@schmorp.de>.
24 pcg 1.1
25     Permission is granted to make and distribute verbatim copies of this
26     manual provided the copyright notice and this permission notice are
27     preserved on all copies.
28    
29     Permission is granted to copy and distribute modified versions of this
30     manual under the conditions for verbatim copying, provided that the
31     entire resulting derived work is distributed under the terms of a
32     permission notice identical to this one.
33    
34     @end ifinfo
35    
36     @titlepage
37     @title gvpe Manual
38 pcg 1.4 @author Marc Lehmann
39 pcg 1.1
40     @page
41     @vskip 0pt plus 1filll
42     @cindex copyright
43    
44 pcg 1.3 Copyright @copyright{} 2003-2008 Marc Lehmann <gvpe@@schmorp.de>.
45 pcg 1.1
46     Permission is granted to make and distribute verbatim copies of this
47     manual provided the copyright notice and this permission notice are
48     preserved on all copies.
49    
50     Permission is granted to copy and distribute modified versions of this
51     manual under the conditions for verbatim copying, provided that the
52     entire resulting derived work is distributed under the terms of a
53     permission notice identical to this one.
54    
55     @end titlepage
56    
57     @contents
58    
59     @node Top,Overview,,(dir)
60    
61     @chapter Introduction
62     This is the documentation for the GNU Virtual Private Ethernet suite.
63     @refill
64     The GNU Virtual Private Ethernet suite implements a virtual (uses udp, tcp, rawip and other protocols for tunneling), private (encrypted, authenticated) ethernet (mac-based, broadcast-based network) that is shared among multiple nodes, in effect implementing an ethernet bus over public networks.
65     @refill
66    
67     @menu
68     * Overview:: Introduction to and Tutorial for GVPE (gvpe(5))
69     * OS Dependencies:: OS-Dependent Installation and Configuration Notes (gvpe.osdep(5))
70     * gvpe.conf:: The main configuration file (gvpe.conf(5))
71     * gvpectrl:: Configuration/Control Program Reference (gvpectrl(8))
72     * gvpe:: The GVPE Daemon (gvpe(8))
73     * gvpe.protocol:: The GVPE Transport and VPN Protocols (gvpe.protocol(7))
74     * Simple Example:: A simple yet realistic Example
75     * Complex Example:: A non-trivial Example
76     * Index:: Keyword and Concept index
77     @end menu
78    
79    
80     @node Overview,OS Dependencies,Top,Top
81    
82     @chapter Overview
83    
84     @section NAME
85     GNU-VPE - Overview of the GNU Virtual Private Ethernet suite.
86     @refill
87    
88    
89     @section DESCRIPTION
90     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.
91     @refill
92    
93    
94     @subsection WHAT IS A VPN?
95     VPN is an acronym, it stands for:
96     @refill
97    
98    
99     @itemize
100    
101    
102     @item
103 pcg 1.3
104 pcg 1.1 @cindex Virtual
105 pcg 1.3 Virtual
106 pcg 1.1
107     Virtual means that no physical network is created (of course), but a network is @emph{emulated} by creating multiple tunnels between the member nodes by encapsulating and sending data over another transport network.
108     @refill
109     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.
110     @refill
111    
112    
113     @item
114 pcg 1.3
115 pcg 1.1 @cindex Private
116 pcg 1.3 Private
117 pcg 1.1
118     Private means that non-participating nodes cannot decode ("sniff)" nor inject ("spoof") packets. This means that nodes can be connected over untrusted networks such as the public Internet without fear of being eavesdropped while at the same time being able to trust data sent by other nodes.
119     @refill
120     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.
121     @refill
122    
123    
124     @item
125 pcg 1.3
126 pcg 1.1 @cindex Network
127 pcg 1.3 Network
128 pcg 1.1
129     Network means that more than two parties can participate in the network, so for instance it's possible to connect multiple branches of a company into a single network. Many so-called "vpn" solutions only create point-to-point tunnels, which in turn can be used to build larger networks.
130     @refill
131     GVPE provides a true multi-point network in wich any number of nodes (at least a few dozen in practise, the theoretical limit is 4095 nodes) can participate.
132     @refill
133     @end itemize
134    
135    
136    
137     @subsection GVPE DESIGN GOALS
138    
139    
140     @itemize
141    
142    
143     @item
144 pcg 1.3 SIMPLE DESIGN
145 pcg 1.1
146     Cipher, HMAC algorithms and other key parameters must be selected at compile time - this makes it possible to only link in algorithms you actually need. It also makes the crypto part of the source very transparent and easy to inspect, and last not least this makes it possible to hardcode the layout of all packets into the binary. GVPE goes a step further and internally reserves blocks of the same length for all packets, which virtually removes all possibilities of buffer overflows, as there is only a single type of buffer and it's always of fixed length.
147     @refill
148    
149    
150     @item
151 pcg 1.3 EASY TO SETUP
152 pcg 1.1
153     A few lines of config (the config file is shared unmodified between all hosts) and a single run of @t{gvpectrl} to generate the keys suffices to make it work.
154     @refill
155    
156    
157     @item
158 pcg 1.3 MAC-BASED SECURITY
159 pcg 1.1
160     Since every host has it's own private key, other hosts cannot spoof traffic from this host. That makes it possible to filter packet by MAC address, e.g. to ensure that packets from a specific IP address come, in fact, from a specific host that is associated with that IP and not from another host.
161     @refill
162     @end itemize
163    
164    
165    
166     @section PROGRAMS
167     Vpe comes with two programs: one daemon (@t{gvpe}) and one control program (@t{gvpectrl}).
168     @refill
169    
170    
171     @itemize
172    
173    
174     @item
175 pcg 1.3 gvpectrl
176 pcg 1.1
177     Is used to generate the keys, check and give an overview of of the configuration and contorl the daemon (restarting etc.).
178     @refill
179    
180    
181     @item
182 pcg 1.3 gvpe
183 pcg 1.1
184     Is the daemon used to establish and maintain connections to the other network members. It should be run on the gateway machine.
185     @refill
186     @end itemize
187    
188    
189    
190     @section COMPILETIME CONFIGURATION
191     Please have a look at the @t{gvpe.osdep(5)} manpage for platform-specific information.
192     @refill
193     Here are a few recipes for compiling your gvpe, showing the extremes (fast, small, insecure OR slow, large, more secure), between you should choose:
194     @refill
195    
196    
197     @subsection AS LOW PACKET OVERHEAD AS POSSIBLE
198    
199    
200     @example
201     ./configure --enable-hmac-length=4 --enable-rand-length=0
202     @end example
203    
204     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 based on the birthday paradox easy, though.
205     @refill
206    
207    
208     @subsection MINIMIZE CPU TIME REQUIRED
209    
210    
211     @example
212     ./configure --enable-cipher=bf --enable-digest=md4
213     @end example
214    
215     Use the fastest cipher and digest algorithms currently available in gvpe. MD4 has been broken and is quite insecure, though.
216     @refill
217    
218    
219     @subsection MAXIMIZE SECURITY
220    
221    
222     @example
223     ./configure --enable-hmac-length=16 --enable-rand-length=8 --enable-digest=sha1
224     @end example
225    
226     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 8 bytes of random data. In the long run, people should move to SHA-224 and beyond, but support in openssl is missing as of writing this document.
227     @refill
228     In general, remember that AES-128 seems to be more secure and 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 or RIPEMD160 are better, and Blowfish is a fast cipher (and also quite secure).
229     @refill
230    
231    
232     @section HOW TO SET UP A SIMPLE VPN
233     In this section I will describe how to get a simple VPN consisting of three hosts up and running.
234     @refill
235    
236    
237     @subsection STEP 1: configuration
238     First you have to create a daemon configuation file and put it into the configuration directory. This is usually @t{/etc/gvpe}, depending on how you configured gvpe, and can be overwritten using the @t{-c} commandline switch.
239     @refill
240     Put the following lines into @t{/etc/gvpe/gvpe.conf}:
241     @refill
242    
243    
244     @example
245     udp-port = 50000 # the external port to listen on (configure your firewall)
246     mtu = 1400 # minimum MTU of all outgoing interfaces on all hosts
247     ifname = vpn0 # the local network device name
248     @end example
249    
250    
251    
252     @example
253     node = first # just a nickname
254     hostname = first.example.net # the DNS name or IP address of the host
255     @end example
256    
257    
258    
259     @example
260     node = second
261     hostname = 133.55.82.9
262     @end example
263    
264    
265    
266     @example
267     node = third
268     hostname = third.example.net
269     @end example
270    
271     The only other file neccessary if the @t{if-up} script that initializes the local ethernet interface. Put the following lines into @t{/etc/gvpe/if-up} and make it execute (@t{chmod 755 /etc/gvpe/if-up}):
272     @refill
273    
274    
275     @example
276     #!/bin/sh
277     ip link set $IFNAME address $MAC mtu $MTU up
278     [ $NODENAME = first ] && ip addr add 10.0.1.1 dev $IFNAME
279     [ $NODENAME = second ] && ip addr add 10.0.2.1 dev $IFNAME
280     [ $NODENAME = third ] && ip addr add 10.0.3.1 dev $IFNAME
281     ip route add 10.0.0.0/16 dev $IFNAME
282     @end example
283    
284     This script will give each node a different IP address in the @t{10.0/16} network. The internal network (e.g. the @t{eth0} interface) should then be set to a subset of that network, e.g. @t{10.0.1.0/24} on node @t{first}, @t{10.0.2.0/24} on node @t{second}, and so on.
285     @refill
286     By enabling routing on the gateway host that runs @t{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 even real briding), or (best) full routing - the choice is yours.
287     @refill
288    
289    
290     @subsection STEP 2: create the RSA key pairs for all hosts
291     Run the following command to generate all key pairs (that might take a while):
292     @refill
293    
294    
295     @example
296     gvpectrl -c /etc/gvpe -g
297     @end example
298    
299     This command will put the public keys into @t{/etc/gvpe/pubkeys/@emph{nodename}} and the private keys into @t{/etc/gvpe/hostkeys/@emph{nodename}}.
300     @refill
301    
302    
303     @subsection STEP 3: distribute the config files to all nodes
304     Now distribute the config files to the other nodes. This should be done in two steps, since the private keys should not be distributed. The example uses rsync-over-ssh
305     @refill
306     First all the config files without the hostkeys should be distributed:
307     @refill
308    
309    
310     @example
311     rsync -avzessh /etc/gvpe first.example.net:/etc/. --exclude hostkeys
312     rsync -avzessh /etc/gvpe 133.55.82.9:/etc/. --exclude hostkeys
313     rsync -avzessh /etc/gvpe third.example.net:/etc/. --exclude hostkeys
314     @end example
315    
316     Then the hostkeys should be copied:
317     @refill
318    
319    
320     @example
321     rsync -avzessh /etc/gvpe/hostkeys/first first.example.net:/etc/hostkey
322     rsync -avzessh /etc/gvpe/hostkeys/second 133.55.82.9:/etc/hostkey
323     rsync -avzessh /etc/gvpe/hostkeys/third third.example.net:/etc/hostkey
324     @end example
325    
326     You should now check the configration by issuing the command @t{gvpectrl -c /etc/gvpe -s} on each node and verify it's output.
327     @refill
328    
329    
330     @subsection STEP 4: starting gvpe
331     You should then start gvpe on each node by issuing a command like:
332     @refill
333    
334    
335     @example
336     gvpe -D -linfo first # first is the nodename
337     @end example
338    
339     This will make the gvpe stay in foreground. You should then see "connection established" messages. If you don't see them check your firewall and routing (use tcpdump ;).
340     @refill
341     If this works you should check your networking setup by pinging various endpoints.
342     @refill
343     To make gvpe run more permanently you can either run it as a daemon (by starting it without the @t{-D} switch), or, much better, from your inittab. I use a line like this on my systems:
344     @refill
345    
346    
347     @example
348     t1:2345:respawn:/opt/gvpe/sbin/gvpe -D -L first >/dev/null 2>&1
349     @end example
350    
351    
352    
353     @subsection STEP 5: enjoy
354     ... and play around. Sending a -HUP (@t{gvpectrl -kHUP}) to the daemon will make it try to connect to all other nodes again. If you run it from inittab, as is recommended, @t{gvpectrl -k} (or simply @t{killall gvpe}) will kill the daemon, start it again, making it read it's configuration files again.
355     @refill
356    
357    
358     @section COPYRIGHTS AND LICENSES
359     GVPE itself is distributed under the GENERAL PUBLIC LICENSE (see the file COPYING that should be part of your distribution).
360     @refill
361     In some configurations it uses modified versions of the tinc vpn suite, which is also available under the GENERAL PUBLIC LICENSE.
362     @refill
363    
364    
365    
366     @node OS Dependencies,gvpe.conf,Overview,Top
367    
368     @chapter OS Dependencies
369    
370     @section NAME
371     gvpe.osdep - os dependent information
372     @refill
373    
374    
375     @section DESCRIPTION
376     This file tries to capture OS-dependent configuration or build issues, quirks and platform limitations, as known.
377     @refill
378    
379    
380     @section TUN vs. TAP interface
381     Most operating systems nowadays support something called a @emph{tunnel}-device, which makes it possible to divert IPv4 (and often other protocols, too) into a userspace daemon like @t{gvpe}. This is being referred to as a TUN-device.
382     @refill
383     This is fine for point-to-point tunnels, but for a virtual ethernet, an additional ethernet header is needed. This functionality (called a TAP device here) is only provided by a subset of the configurations.
384     @refill
385     On platforms only supporting a TUN-device, gvpe will invoke it's magical ethernet emulation package, which currently only handles ARP requests for the IPv4 protocol (but more could be added, bu the tincd network drivers might need to be modified for this to work). This means that on those platforms, only IPv4 will be supported.
386     @refill
387     Also, since there is no way (currently) to tell gvpe which IP subnets are found on a specific host, you will either need to hardwire the MAC address for TUN-style hosts on all networks (and avoid ARP altogether, which is possible), or you need to send a packet from these hosts into the vpn network to tell gvpe the local interface address.
388     @refill
389    
390    
391     @section Interface Initialisation
392     Unless otherwise notes, the network interface will be initialized with the expected MAC address and correct MTU value. With most interface drivers, this is done by running @t{/sbin/ifconfig}, so make sure that this command exists.
393     @refill
394    
395    
396     @section Interface Types
397    
398    
399     @subsection native/linux
400     TAP-device; already part of the kernel (only 2.4+ supported, but see tincd/linux). This is the configuration tested best, as gvpe is being developed on this platform.
401     @refill
402     @t{ifname} should be set to the name of the network device.
403     @refill
404     To hardwire ARP addresses, use iproute2 (@t{arp} can do it, too):
405     @refill
406    
407    
408     @example
409     MAC=fe:fd:80:00:00:$(printf "%02x" $NODEID)
410     ip neighbour add 10.11.12.13 lladdr $MAC nud permanent dev $IFNAME
411     @end example
412    
413    
414    
415     @subsection tincd/linux
416     TAP-device; already part of the kernel (2.2 only). See @t{native/linux} for more info.
417     @refill
418     @t{ifname} should be set to the path of a tap device, e.g. @t{/dev/tap0}. The interface will be named accordingly.
419     @refill
420    
421    
422     @subsection native/cygwin
423     TAP-device; The TAP device to be used must either be the CIPE driver (@t{http://cipe-win32.sourceforge.net/}), or (highly recommended) the newer TAP-Win32 driver bundled with openvpn (http://openvpn.sf.net/). Just download and run the openvpn installer. The only option you need to select is the TAP driver.
424     @refill
425     @t{ifname} should be set to the name of the device, found in the registry at (no kidding :):
426     @refill
427    
428    
429     @example
430     HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Network\@{4D36E972-E325-11CE-BFC1-08002BE10318@}\<adapterid>\Connection\Name
431     @end example
432    
433     The MAC address is dynamically being patched into packets and ARP-requests, so only IPv4 works with ARP on this platform.
434     @refill
435    
436    
437     @subsection tincd/bsd
438     TAP-device, maybe; migth work for many bsd variants.
439     @refill
440     This driver is a newer version of the @t{tincd/*bsd} drivers. It @emph{might} provide a TAP device, or might not work at all. You might try this interface type first, and, if it doesn't work, try one of the OS-specific drivers.
441     @refill
442    
443    
444     @subsection tincd/freebsd
445     TAP-device; part of the kernel (since 4.x, maybe earlier).
446     @refill
447     @t{ifname} should be set to the path of a tap device, e.g. @t{/dev/tap0}. The interface will be named accordingly.
448     @refill
449     These commands might be helpful examples:
450     @refill
451    
452    
453     @example
454     ifconfig $IFNAME 10.0.0.$NODEID
455     route add -net 10.0.0.0 -netmask 255.255.255.0 -interface $IFNAME 10.0.0.$NODEID
456     @end example
457    
458    
459    
460     @subsection tincd/netbsd
461     TUN-device; The interface is a point-to-point device. To initialize it, you currently need to configure it as a point-to-point device, giving it an address on your vpn (the exact address doesn't matter), like this:
462     @refill
463    
464    
465     @example
466     ifconfig $IFNAME mtu $MTU up
467     ifconfig $IFNAME 10.11.12.13 10.55.66.77
468     route add -net 10.0.0.0 10.55.66.77 255.0.0.0
469     ping -c1 10.55.66.77 # ping once to tell gvpe your gw ip
470     @end example
471    
472     The ping is required to tell the ARP emulator inside GVPE the local IP address.
473     @refill
474     @t{ifname} should be set to the path of a tun device, e.g. @t{/dev/tun0}. The interface will be named accordingly.
475     @refill
476    
477    
478     @subsection tincd/openbsd
479     TUN-device; already part of the kernel. See @t{tincd/netbsd} for more information.
480     @refill
481    
482    
483     @subsection native/darwin
484     TAP-device;
485     @refill
486     The necessary kernel extension can be found here:
487     @refill
488    
489    
490     @example
491     http://www-user.rhrk.uni-kl.de/~nissler/tuntap/
492     @end example
493    
494     There are two drivers, the one to use is the "tap" driver. It driver must be loaded before use, read the docs on how to install it as a startup item.
495     @refill
496     @t{ifname} should be set to the path of a tap device, e.g. @t{/dev/tap0}. The interface will be named accordingly.
497     @refill
498     These commands might be helpful examples:
499     @refill
500    
501    
502     @example
503     ifconfig $IFNAME 10.0.0.$NODEID
504     route add -net 10.0.0.0 -interface $IFNAME 255.255.255.0
505     @end example
506    
507    
508    
509     @subsection tincd/darwin
510     TUN-device; See @t{tincd/netbsd} for more information. @t{native/darwin} is preferable.
511     @refill
512     The necessary kernel extension can be found here:
513     @refill
514    
515    
516     @example
517     http://chrisp.de/en/projects/tunnel.html
518     @end example
519    
520     @t{ifname} should be set to the path of a tun device, e.g. @t{/dev/tun0}. The interface will be named accordingly.
521     @refill
522     The driver must be loaded before use:
523     @refill
524    
525    
526     @example
527     kmodload tunnel
528     @end example
529    
530    
531    
532     @subsection tincd/solaris
533     TUN-device; already part of the kernel(?), or available here:
534     @refill
535    
536    
537     @example
538     http://vtun.sourceforge.net/tun/
539     @end example
540    
541     Some precompiled tun drivers might be available here:
542     @refill
543    
544    
545     @example
546     http://www.monkey.org/~dugsong/fragroute/
547     @end example
548    
549     The interface MAC and MTU are @emph{NOT} set up for you. Please try it out and send me an @t{ifconfig} command invocation that does that.
550     @refill
551     See @t{tincd/netbsd} for more information.
552     @refill
553     Completely unstested so far.
554     @refill
555    
556    
557     @subsection tincd/mingw
558     TAP-device; see @t{native/cygwin} for more information.
559     @refill
560     The setup is likely to be similar to @t{native/cygwin}.
561     @refill
562     Completely untested so far.
563     @refill
564    
565    
566     @subsection tincd/raw_socket
567     TAP-device; purpose unknown and untested, probably binds itself on an existing ethernet device (given by @t{ifname}). It must be down prior to running the command, and GVPE will try to set it's MAC address and MTU to the "correct" values.
568     @refill
569     Completely untested so far.
570     @refill
571    
572    
573     @subsection tincd/uml_socket
574     TAP-device; purpose unknown and untested, probably creates a unix datagram socket (path given by @t{ifname}) and reads and writes raw packets, so might be useful in other than UML contexts.
575     @refill
576     No network interface is created, and the MAC and MTU must be set as approriate on the other side of the socket. GVPE will exit if the MAC address doesn't match what it expects.
577     @refill
578     Completely untested so far.
579     @refill
580    
581    
582     @subsection tincd/cygwin
583     Known to be broken, use @t{native/cygwin} instead.
584     @refill
585    
586    
587    
588     @node gvpe.conf,gvpectrl,OS Dependencies,Top
589    
590     @chapter gvpe.conf
591    
592     @section NAME
593     gvpe.conf - configuration file for the GNU VPE daemon
594     @refill
595    
596    
597     @section SYNOPSIS
598    
599    
600     @example
601     udp-port = 407
602     mtu = 1492
603     ifname = vpn0
604     @end example
605    
606    
607    
608     @example
609     node = branch1
610     hostname = 1.2.3.4
611     @end example
612    
613    
614    
615     @example
616     node = branch2
617     hostname = www.example.net
618     udp-port = 500 # this host uses a different udp-port
619     @end example
620    
621    
622    
623     @example
624     node = branch3
625     connect = ondemand
626     @end example
627    
628    
629    
630     @section DESCRIPTION
631     The gvpe config file consists of a series of lines that contain @t{variable = value} pairs. Empty lines are ignored. Comments start with a @t{#} and extend to the end of the line. They can be used on their own lines, or after any directives. Whitespace is allowed around the @t{=} sign or after values, but not within the variable names or values themselves.
632     @refill
633     The only exception to the above is the "on" directive that can prefix any @t{name = value} setting and will only "execute" it on the named node, or (if the nodename starts with "!") on all nodes except the named one.
634     @refill
635    
636    
637     @example
638     name = value
639     on branch1 loglevel = noise
640     on !branch2 connect = ondemand
641     @end example
642    
643     All settings are executed "in order", that is, later settings of the same variable overwrite earlier ones.
644     @refill
645    
646    
647     @section ANATOMY OF A CONFIG FILE
648     Usually, a config file starts with global settings (like the udp port to listen on), followed by node-specific sections that begin with a @t{node = nickname} line.
649     @refill
650 pcg 1.3 Every node that is part of the network must have a section that starts with @t{node = nickname}. The number and order of the nodes is important and must be the same on all nodes. It is not uncommon for node sections to be completely empty - if the default values are right.
651 pcg 1.1 @refill
652     Node-specific settings can be used at any time. If used before the first node section they will set the default values for all following nodes.
653     @refill
654    
655    
656     @section CONFIG VARIABLES
657    
658    
659     @subsection GLOBAL SETTINGS
660     Global settings will affect the behaviour of the running gvpe daemon, that is, they are in some sense node-specific (config files can set different values on different nodes using @t{on}), but will affect the behaviour of the gvpe daemon and all connections it creates.
661     @refill
662    
663    
664     @itemize
665    
666    
667     @item
668 pcg 1.3 dns-forw-host = hostname/ip
669 pcg 1.1
670     @cindex dns-forw-host
671     The dns server to forward dns requests to for the DNS tunnel protocol (default: @t{127.0.0.1}, changing it is highly recommended).
672     @refill
673    
674    
675     @item
676 pcg 1.3 dns-forw-port = port-number
677 pcg 1.1
678     @cindex dns-forw-port
679     The port where the @t{dns-forw-host} is to be contacted (default: @t{53}, which is fine in most cases).
680     @refill
681    
682    
683     @item
684 pcg 1.3 dns-max-outstanding = integer-number-of-requests
685 pcg 1.1
686     @cindex dns-max-outstanding
687     The maximum number of outstanding DNS transport requests (default: @t{100}). GVPE will never issue more requests then the given limit without receiving replies. In heavily overloaded situations it might help to set this to a low number (e.g. @t{3} or even @t{1}) to limit the number of parallel requests.
688     @refill
689     The default should be working ok for most links.
690     @refill
691    
692    
693     @item
694 pcg 1.3 dns-overlap-factor = float
695 pcg 1.1
696     @cindex dns-overlap-factor
697     The DNS transport uses the minimum request latency (@strong{min_latency}) seen during a connection as it's timing base. This factor (default: @t{0.5}, must be > 0) is multiplied by @strong{min_latency} to get the maximum sending rate (= minimum send interval), i.e. a factor of @t{1} means that a new request might be generated every @strong{min_latency} seconds, which means on average there should only ever be one outstanding request. A factor of @t{0.5} means that GVPE will send requests twice as often as the minimum latency measured.
698     @refill
699     For congested or picky dns forwarders you could use a value nearer to or exceeding @t{1}.
700     @refill
701     The default should be working ok for most links.
702     @refill
703    
704    
705     @item
706 pcg 1.3 dns-send-interval = send-interval-in-seconds
707 pcg 1.1
708     @cindex dns-send-interval
709     The minimum send interval (= maximum rate) that the DNS transport will use to send new DNS requests. GVPE will not exceed this rate even when the latency is very low. The default is @t{0.01}, which means GVPE will not send more than 100 DNS requests per connection per second. For high-bandwidth links you could go lower, e.g. to @t{0.001} or so. For congested or rate-limited links, you might want to go higher, say @t{0.1}, @t{0.2} or even higher.
710     @refill
711     The default should be working ok for most links.
712     @refill
713    
714    
715     @item
716 pcg 1.3 dns-timeout-factor = float
717 pcg 1.1
718     @cindex dns-timeout-factor
719     Factor to multiply the @t{min_latency} (see @t{dns-overlap-factor}) by to get request timeouts. The default of @t{8} means that the DNS transport will resend the request when no reply has been received for longer than eight times the minimum (= expected) latency, assuming the request or reply has been lost.
720     @refill
721     For congested links a higher value might be necessary (e.g. @t{30}). If the link is very stable lower values (e.g. @t{2}) might work nicely. Values near or below @t{1} makes no sense whatsoever.
722     @refill
723 pcg 1.2 The default should be working ok for most links but will result in low throughput if packet loss is high.
724 pcg 1.1 @refill
725    
726    
727     @item
728 pcg 1.3 if-up = relative-or-absolute-path
729 pcg 1.1
730     @cindex if-up
731     Sets the path of a script that should be called immediately after the network interface is initialized (but not neccessarily up). The following environment variables are passed to it (the values are just examples).
732     @refill
733     Variables that have the same value on all nodes:
734     @refill
735    
736    
737     @itemize
738    
739    
740     @item
741 pcg 1.3 CONFBASE=/etc/gvpe
742 pcg 1.1
743     @cindex CONFBASE
744     The configuration base directory.
745     @refill
746    
747    
748     @item
749 pcg 1.3 IFNAME=vpn0
750 pcg 1.1
751     @cindex IFNAME
752     The network interface to initialize.
753     @refill
754    
755    
756     @item
757 pcg 1.3 IFTYPE=native # or tincd
758 pcg 1.1
759     @cindex IFTYPE
760    
761    
762     @item
763 pcg 1.3 IFSUBTYPE=linux # or freebsd, darwin etc..
764 pcg 1.1
765     @cindex IFSUBTYPE
766     The interface type (@t{native} or @t{tincd}) and the subtype (usually the OS name in lowercase) that this GVPE was configured for. Can be used to select the correct syntax to use for network-related commands.
767     @refill
768    
769    
770     @item
771 pcg 1.3 MTU=1436
772 pcg 1.1
773     @cindex MTU
774 pcg 1.3 The MTU to set the interface to. You can use lower values (if done consistently on all nodes), but this is usually either inefficient or simply ineffective.
775 pcg 1.1 @refill
776    
777    
778     @item
779 pcg 1.3 NODES=5
780 pcg 1.1
781     @cindex NODES
782     The number of nodes in this GVPE network.
783     @refill
784     @end itemize
785    
786     Variables that are node-specific and with values pertaining to the node running this GVPE:
787     @refill
788    
789    
790     @itemize
791    
792    
793     @item
794 pcg 1.3 IFUPDATA=string
795 pcg 1.1
796     @cindex IFUPDATA
797     The value of the configuration directive @t{if-up-data}.
798     @refill
799    
800    
801     @item
802 pcg 1.3 MAC=fe:fd:80:00:00:01
803 pcg 1.1
804     @cindex MAC
805     The MAC address the network interface has to use.
806     @refill
807     Might be used to initialize interfaces on platforms where GVPE does not do this automatically. Please see the @t{gvpe.osdep(5)} manpage for platform-specific information.
808     @refill
809    
810    
811     @item
812 pcg 1.3 NODENAME=branch1
813 pcg 1.1
814     @cindex NODENAME
815     The nickname of the node.
816     @refill
817    
818    
819     @item
820 pcg 1.3 NODEID=1
821 pcg 1.1
822     @cindex NODEID
823     The numerical node ID of the node running this instance of GVPE. The first node mentioned in the config file gets ID 1, the second ID 2 and so on.
824     @refill
825     @end itemize
826    
827     In addition, all node-specific variables (except @t{NODEID}) will be available with a postfix of @t{_nodeid}, which contains the value for that node, e.g. the @t{MAC_1} variable contains the MAC address of node #1, while the @t{NODENAME_22} variable contains the name of node #22.
828     @refill
829     Here is a simple if-up script:
830     @refill
831    
832    
833     @example
834     #!/bin/sh
835     ip link set $IFNAME up
836     [ $NODENAME = branch1 ] && ip addr add 10.0.0.1 dev $IFNAME
837     [ $NODENAME = branch2 ] && ip addr add 10.1.0.1 dev $IFNAME
838     ip route add 10.0.0.0/8 dev $IFNAME
839     @end example
840    
841     More complicated examples (using routing to reduce arp traffic) can be found in the etc/ subdirectory of the distribution.
842     @refill
843    
844    
845     @item
846 pcg 1.3 ifname = devname
847 pcg 1.1
848     @cindex ifname
849     Sets the tun interface name to the given name. The default is OS-specific and most probably something like @t{tun0}.
850     @refill
851    
852    
853     @item
854 pcg 1.3 ifpersist = yes|true|on | no|false|off
855 pcg 1.1
856     @cindex ifpersist
857     Should the tun/tap device be made persistent, that is, should the device stay up even when gvpe exits? Some versions of the tunnel device have problems sending packets when gvpe is restarted in persistent mode, so if the connections can be established but you cannot send packets from the local node, try to set this to @t{off} and do an ifconfig down on the device.
858     @refill
859    
860    
861     @item
862 pcg 1.3 ip-proto = numerical-ip-protocol
863 pcg 1.1
864     @cindex ip-proto
865 pcg 1.3 Sets the protocol number to be used for the rawip protocol. This is a global option because all nodes must use the same protocol, and since there are no port numbers, you cannot easily run more than one gvpe instance using the same protocol, nor can you share the protocol with other programs.
866 pcg 1.1 @refill
867     The default is 47 (GRE), which has a good chance of tunneling through firewalls (but note that the rawip protocol is not GRE compatible). Other common choices are 50 (IPSEC, ESP), 51 (IPSEC, AH), 4 (IPIP tunnels) or 98 (ENCAP, rfc1241)
868     @refill
869    
870    
871     @item
872 pcg 1.3 http-proxy-host = hostname/ip
873 pcg 1.1
874     @cindex http-proxy-host
875     The @t{http-proxy-*} family of options are only available if gvpe was compiled with the @t{--enable-http-proxy} option and enable tunneling of tcp connections through a http proxy server.
876     @refill
877     @t{http-proxy-host} and @t{http-proxy-port} should specify the hostname and port number of the proxy server. See @t{http-proxy-loginpw} if your proxy requires authentication.
878     @refill
879     Please note that gvpe will still try to resolve all hostnames in the configuration file, so if you are behind a proxy without access to a dns server better use numerical IP addresses.
880     @refill
881 pcg 1.3 To make best use of this option disable all protocols except tcp in your config file and make sure your routers (or all other nodes) are listening on a port that the proxy allows (443, https, is a common choice).
882 pcg 1.1 @refill
883 pcg 1.3 If you have a router, connecting to it will suffice. Otherwise tcp must be enabled on all nodes.
884 pcg 1.1 @refill
885     Example:
886     @refill
887    
888    
889     @example
890     http-proxy-host = proxy.example.com
891     http-proxy-port = 3128 # 8080 is another common choice
892     http-proxy-auth = schmorp:grumbeere
893     @end example
894    
895    
896    
897     @item
898 pcg 1.3 http-proxy-port = proxy-tcp-port
899 pcg 1.1
900     @cindex http-proxy-port
901     The port where your proxy server listens.
902     @refill
903    
904    
905     @item
906 pcg 1.3 http-proxy-auth = login:password
907 pcg 1.1
908     @cindex http-proxy-auth
909     The optional login and password used to authenticate to the proxy server, seperated by a literal colon (@t{:}). Only basic authentication is currently supported.
910     @refill
911    
912    
913     @item
914 pcg 1.3 keepalive = seconds
915 pcg 1.1
916     @cindex keepalive
917     Sets the keepalive probe interval in seconds (default: @t{60}). After this many seconds of inactivity the daemon will start to send keepalive probe every 5 seconds until it receives a reply from the other end. If no reply is received within 30 seconds, the peer is considered unreachable and the connection is closed.
918     @refill
919    
920    
921     @item
922 pcg 1.3 loglevel = noise|trace|debug|info|notice|warn|error|critical
923 pcg 1.1
924     @cindex loglevel
925     Set the logging level. Connection established messages are logged at level @t{info}, notable errors are logged with @t{error}. Default is @t{info}.
926     @refill
927    
928    
929     @item
930 pcg 1.3 mtu = bytes
931 pcg 1.1
932     @cindex mtu
933     Sets the maximum MTU that should be used on outgoing packets (basically the MTU of the outgoing interface) The daemon will automatically calculate maximum overhead (e.g. udp header size, encryption blocksize...) and pass this information to the @t{if-up} script.
934     @refill
935     Recommended values are 1500 (ethernet), 1492 (pppoe), 1472 (pptp).
936     @refill
937 pcg 1.3 This value must be the minimum of the mtu values of all nodes.
938 pcg 1.1 @refill
939    
940    
941     @item
942 pcg 1.3 node = nickname
943 pcg 1.1
944     @cindex node
945     Not really a config setting but introduces a node section. The nickname is used to select the right configuration section and must be passed as an argument to the gvpe daemon.
946     @refill
947    
948    
949     @item
950 pcg 1.3 node-up = relative-or-absolute-path
951 pcg 1.1
952     @cindex node-up
953 pcg 1.3 Sets a command (default: none) that should be called whenever a connection is established (even on rekeying operations). Note that node-up/down scripts will be run asynchronously, but execution is serialised, so there will only ever be one such script running.
954     @refill
955     In addition to all the variables passed to @t{if-up} scripts, the following environment variables will be set:
956 pcg 1.1 @refill
957    
958    
959     @itemize
960    
961    
962     @item
963 pcg 1.3 DESTNODE=branch2
964 pcg 1.1
965     @cindex DESTNODE
966     The name of the remote node.
967     @refill
968    
969    
970     @item
971 pcg 1.3 DESTID=2
972 pcg 1.1
973     @cindex DESTID
974     The node id of the remote node.
975     @refill
976    
977    
978     @item
979 pcg 1.3 DESTIP=188.13.66.8
980 pcg 1.1
981     @cindex DESTIP
982 pcg 1.3 The numerical IP address of the remote node (gvpe accepts connections from everywhere, as long as the other node can authenticate itself).
983 pcg 1.1 @refill
984    
985    
986     @item
987 pcg 1.3 DESTPORT=655 # deprecated
988 pcg 1.1
989     @cindex DESTPORT
990     The UDP port used by the other side.
991     @refill
992    
993    
994     @item
995 pcg 1.3 STATE=UP
996 pcg 1.1
997     @cindex STATE
998     Node-up scripts get called with STATE=UP, node-down scripts get called with STATE=DOWN.
999     @refill
1000     @end itemize
1001    
1002     Here is a nontrivial example that uses nsupdate to update the name => ip mapping in some dns zone:
1003     @refill
1004    
1005    
1006     @example
1007     #!/bin/sh
1008     @{
1009     echo update delete $DESTNODE.lowttl.example.net. a
1010     echo update add $DESTNODE.lowttl.example.net. 1 in a $DESTIP
1011     echo
1012     @} | nsupdate -d -k $CONFBASE:key.example.net.
1013     @end example
1014    
1015    
1016    
1017     @item
1018 pcg 1.3 node-down = relative-or-absolute-path
1019 pcg 1.1
1020     @cindex node-down
1021     Same as @t{node-up}, but gets called whenever a connection is lost.
1022     @refill
1023    
1024    
1025     @item
1026 pcg 1.3 pid-file = path
1027 pcg 1.1
1028     @cindex pid-file
1029     The path to the pid file to check and create (default: @t{LOCALSTATEDIR/run/gvpe.pid}).
1030     @refill
1031    
1032    
1033     @item
1034 pcg 1.3 private-key = relative-path-to-key
1035 pcg 1.1
1036     @cindex private-key
1037     Sets the path (relative to the config directory) to the private key (default: @t{hostkey}). This is a printf format string so every @t{%} must be doubled. A single @t{%s} is replaced by the hostname, so you could use paths like @t{hostkeys/%s} to fetch the files at the location where @t{gvpectrl} puts them.
1038     @refill
1039 pcg 1.3 Since only the private key file of the current node is used and the private key file should be kept secret per-node to avoid spoofings, it is not recommended to use this feature.
1040 pcg 1.1 @refill
1041    
1042    
1043     @item
1044 pcg 1.3 rekey = seconds
1045 pcg 1.1
1046     @cindex rekey
1047     Sets the rekeying interval in seconds (default: @t{3600}). Connections are reestablished every @t{rekey} seconds.
1048     @refill
1049     @end itemize
1050    
1051    
1052    
1053     @subsection NODE SPECIFIC SETTINGS
1054     The following settings are node-specific, that is, every node can have different settings, even within the same gvpe instance. Settings that are set before the first node section set the defaults, settings that are set within a node section only apply to the given node.
1055     @refill
1056    
1057    
1058     @itemize
1059    
1060    
1061     @item
1062 pcg 1.3 allow-direct = nodename
1063 pcg 1.1
1064     @cindex allow-direct
1065     Allow direct connections to this node. See @t{deny-direct} for more info.
1066     @refill
1067    
1068    
1069     @item
1070 pcg 1.3 compress = yes|true|on | no|false|off
1071 pcg 1.1
1072     @cindex compress
1073 pcg 1.3 Wether to compress data packets sent to this node (default: @t{yes}). Compression is really cheap even on slow computers and has no size overhead at all, so enabling this is a good idea.
1074 pcg 1.1 @refill
1075    
1076    
1077     @item
1078 pcg 1.3 connect = ondemand | never | always | disabled
1079 pcg 1.1
1080     @cindex connect
1081 pcg 1.3 Sets the connect mode (default: @t{always}). It can be @t{always} (always try to establish and keep a connection to the given node), @t{never} (never initiate a connection to the given host, but accept connections), @t{ondemand} (try to establish a connection when there are outstanding packets in the queue and take it down after the keepalive interval) or @t{disabled} (node is bad, don't talk to it).
1082     @refill
1083     Routers will automatically be forced to @t{always} unless they are @t{disabled}, to ensure all nodes can talk to each other.
1084 pcg 1.1 @refill
1085    
1086    
1087     @item
1088 pcg 1.3 deny-direct = nodename | *
1089 pcg 1.1
1090     @cindex deny-direct
1091     Deny direct connections to the specified node (or all nodes when @t{*} is given). Only one node can be specified, but you can use multiple @t{allow-direct} and @t{deny-direct} statements. This only makes sense in networks with routers, as routers are required for indirect connections.
1092     @refill
1093     Sometimes, a node cannot reach some other nodes for reasons of network connectivity. For example, a node behind a firewall that only allows conenctions to/from a single other node in the network. In this case one should specify @t{deny-direct = *} and @t{allow-direct = othernodename} (the other node @emph{must} be a router for this to work).
1094     @refill
1095     The algorithm to check wether a connection may be direct is as follows:
1096     @refill
1097     1. Other node mentioned in a @t{allow-direct}? If yes, allow the connection.
1098     @refill
1099     2. Other node mentioned in a @t{deny-direct}? If yes, deny direct connections.
1100     @refill
1101     3. Allow the connection.
1102     @refill
1103 pcg 1.2 That is, @t{allow-direct} takes precedence over @t{deny-direct}.
1104 pcg 1.1 @refill
1105     The check is done in both directions, i.e. both nodes must allow a direct connection before one is attempted, so you only need to specify connect limitations on one node.
1106     @refill
1107    
1108    
1109     @item
1110 pcg 1.3 dns-domain = domain-suffix
1111 pcg 1.1
1112     @cindex dns-domain
1113     The DNS domain suffix that points to the DNS tunnel server for this node.
1114     @refill
1115     The domain must point to a NS record that points to the @emph{dns-hostname}, i.e.
1116     @refill
1117    
1118    
1119     @example
1120     dns-domainname = tunnel.example.net
1121     dns-hostname = tunnel-server.example.net
1122     @end example
1123    
1124     Corresponds to the following DNS entries in the @t{example.net} domain:
1125     @refill
1126    
1127    
1128     @example
1129     tunnel.example.net. NS tunnel-server.example.net.
1130     tunnel-server.example.net. A 13.13.13.13
1131     @end example
1132    
1133    
1134    
1135     @item
1136 pcg 1.3 dns-hostname = hostname/ip
1137 pcg 1.1
1138     @cindex dns-hostname
1139     The address to bind the DNS tunnel socket to, similar to the @t{hostname}, but for the DNS tunnel protocol only. Default: @t{0.0.0.0}, but that might change.
1140     @refill
1141    
1142    
1143     @item
1144 pcg 1.3 dns-port = port-number
1145 pcg 1.1
1146     @cindex dns-port
1147     The port to bind the DNS tunnel socket to. Must be @t{53} on DNS tunnel servers.
1148     @refill
1149    
1150    
1151     @item
1152 pcg 1.3 enable-dns = yes|true|on | no|false|off
1153 pcg 1.1
1154     @cindex enable-dns
1155     See gvpe.protocol(7) for a description of the DNS transport protocol. Avoid this protocol if you can.
1156     @refill
1157     Enable the DNS tunneling protocol on this node, either as server or as client. Support for this transport protocol is only available when gvpe was compiled using the @t{--enable-dns} option.
1158     @refill
1159    
1160    
1161     @item
1162 pcg 1.3 enable-icmp = yes|true|on | no|false|off
1163 pcg 1.1
1164     @cindex enable-icmp
1165     See gvpe.protocol(7) for a description of the ICMP transport protocol.
1166     @refill
1167     Enable the ICMP transport using icmp packets of type @t{icmp-type} on this node.
1168     @refill
1169    
1170    
1171     @item
1172 pcg 1.3 enable-rawip = yes|true|on | no|false|off
1173 pcg 1.1
1174     @cindex enable-rawip
1175     See gvpe.protocol(7) for a description of the RAW IP transport protocol.
1176     @refill
1177     Enable the RAW IPv4 transport using the @t{ip-proto} protocol (default: @t{no}).
1178     @refill
1179    
1180    
1181     @item
1182 pcg 1.3 enable-tcp = yes|true|on | no|false|off
1183 pcg 1.1
1184     @cindex enable-tcp
1185     See gvpe.protocol(7) for a description of the TCP transport protocol.
1186     @refill
1187     Enable the TCPv4 transport using the @t{tcp-port} port (default: @t{no}). Support for this transport protocol is only available when gvpe was compiled using the @t{--enable-tcp} option.
1188     @refill
1189    
1190    
1191     @item
1192 pcg 1.3 enable-udp = yes|true|on | no|false|off
1193 pcg 1.1
1194     @cindex enable-udp
1195     See gvpe.protocol(7) for a description of the UDP transport protocol.
1196     @refill
1197     Enable the UDPv4 transport using the @t{udp-port} port (default: @t{no}, unless no other protocol is enabled for a node, in which case this protocol is enabled automatically).
1198     @refill
1199     NOTE: Please specify @t{enable-udp = yes} if you want t use it even though it might get switched on automatically, as some future version might default to another default protocol.
1200     @refill
1201    
1202    
1203     @item
1204 pcg 1.3 hostname = hostname | ip [can not be defaulted]
1205 pcg 1.1
1206     @cindex hostname
1207     Forces the address of this node to be set to the given dns hostname or ip address. It will be resolved before each connect request, so dyndns should work fine. If this setting is not specified and a router is available, then the router will be queried for the address of this node. Otherwise, the connection attempt will fail.
1208     @refill
1209    
1210    
1211     @item
1212 pcg 1.3 icmp-type = integer
1213 pcg 1.1
1214     @cindex icmp-type
1215     Sets the type value to be used for outgoing (and incoming) packets sent via the ICMP transport.
1216     @refill
1217     The default is @t{0} (which is @t{echo-reply}, also known as "ping-replies"). Other useful values include @t{8} (@t{echo-request}, a.k.a. "ping") and @t{11} (@t{time-exceeded}), but any 8-bit value can be used.
1218     @refill
1219    
1220    
1221     @item
1222 pcg 1.3 if-up-data = value
1223 pcg 1.1
1224     @cindex if-up-data
1225     The value specified using this directive will be passed to the @t{if-up} script in the environment variable @t{IFUPDATA}.
1226     @refill
1227    
1228    
1229     @item
1230 pcg 1.3 inherit-tos = yes|true|on | no|false|off
1231 pcg 1.1
1232     @cindex inherit-tos
1233     Wether to inherit the TOS settings of packets sent to the tunnel when sending packets to this node (default: @t{yes}). If set to @t{yes} then outgoing tunnel packets will have the same TOS setting as the packets sent to the tunnel device, which is usually what you want.
1234     @refill
1235    
1236    
1237     @item
1238 pcg 1.3 max-retry = positive-number
1239 pcg 1.1
1240     @cindex max-retry
1241     The maximum interval in seconds (default: @t{3600}, one hour) between retries to establish a connection to this node. When a connection cannot be established, gvpe uses exponential backoff capped at this value. It's sometimes useful to set this to a much lower value (e.g. @t{120}) on connections to routers that usually are stable but sometimes are down, to assure quick reconnections even after longer downtimes.
1242     @refill
1243    
1244    
1245     @item
1246 pcg 1.3 max-ttl = seconds
1247    
1248     @cindex max-ttl
1249     Expire packets that couldn't be sent after this many seconds (default: @t{60}). Gvpe will normally queue packets for a node without an active connection, in the hope of establishing a connection soon. This value specifies the maximum lifetime a packet will stay in the queue, if a packet gets older, it will be thrown away.
1250     @refill
1251    
1252    
1253     @item
1254     max-queue = positive-number>=1
1255    
1256     @cindex max-queue
1257     The maximum number of packets that will be queued (default: @t{512}) for this node. If more packets are sent then earlier packets will be expired. See @t{max-ttl}, above.
1258     @refill
1259    
1260    
1261     @item
1262     router-priority = 0 | 1 | positive-number>=2
1263 pcg 1.1
1264     @cindex router-priority
1265 pcg 1.3 Sets the router priority of the given node (default: @t{0}, disabled).
1266 pcg 1.1 @refill
1267 pcg 1.3 If some node tries to connect to another node but it doesn't have a hostname, it asks a router node for it's IP address. The router node chosen is the one with the highest priority larger than @t{1} that is currently reachable. This is called a @emph{mediated} connection, as the connection itself will still be direct, but it uses another node to mediate between the two nodes.
1268 pcg 1.1 @refill
1269 pcg 1.3 The value @t{0} disables routing, that means if the node receives a packet not for itself it will not forward it but instead drop it.
1270     @refill
1271     The special value @t{1} allows other hosts to route through the router host, but they will never route through it by default (i.e. the config file of another node needs to specify a router priority higher than one to choose such a node for routing).
1272     @refill
1273     The idea behind this is that some hosts can, if required, bump the @t{router-priority} setting to higher than @t{1} in their local config to route through specific hosts. If @t{router-priority} is @t{0}, then routing will be refused, so @t{1} serves as a "enable, but do not use by default" switch.
1274     @refill
1275     Nodes with @t{router-priority} set to @t{2} or higher will always be forced to @t{connect} = @t{always} (unless they are @t{disabled}).
1276 pcg 1.1 @refill
1277    
1278    
1279     @item
1280 pcg 1.3 tcp-port = port-number
1281 pcg 1.1
1282     @cindex tcp-port
1283     Similar to @t{udp-port} (default: @t{655}), but sets the TCP port number.
1284     @refill
1285    
1286    
1287     @item
1288 pcg 1.3 udp-port = port-number
1289 pcg 1.1
1290     @cindex udp-port
1291     Sets the port number used by the UDP protocol (default: @t{655}, not officially assigned by IANA!).
1292     @refill
1293     @end itemize
1294    
1295    
1296    
1297     @section CONFIG DIRECTORY LAYOUT
1298     The default (or recommended) directory layout for the config directory is:
1299     @refill
1300    
1301    
1302     @itemize
1303    
1304    
1305     @item
1306 pcg 1.3
1307 pcg 1.1 @cindex gvpe.conf
1308 pcg 1.3 gvpe.conf
1309 pcg 1.1
1310     The config file.
1311     @refill
1312    
1313    
1314     @item
1315 pcg 1.3
1316 pcg 1.1 @cindex if-up
1317 pcg 1.3 if-up
1318 pcg 1.1
1319     The if-up script
1320     @refill
1321    
1322    
1323     @item
1324 pcg 1.3
1325 pcg 1.1 @cindex node-up
1326     node-up,
1327     @cindex node-down
1328 pcg 1.3 node-down
1329 pcg 1.1
1330     If used the node up or node-down scripts.
1331     @refill
1332    
1333    
1334     @item
1335 pcg 1.3
1336 pcg 1.1 @cindex hostkey
1337 pcg 1.3 hostkey
1338 pcg 1.1
1339     The private key (taken from @t{hostkeys/nodename}) of the current host.
1340     @refill
1341    
1342    
1343     @item
1344 pcg 1.3
1345 pcg 1.1 @cindex pubkey/nodename
1346 pcg 1.3 pubkey/nodename
1347 pcg 1.1
1348     The public keys of the other nodes, one file per node.
1349     @refill
1350     @end itemize
1351    
1352    
1353    
1354    
1355     @node gvpectrl,gvpe,gvpe.conf,Top
1356    
1357     @chapter gvpectrl
1358    
1359     @section NAME
1360     @t{gvpectrl} - GNU Virtual Private Ethernet Control Program
1361     @refill
1362    
1363    
1364     @section SYNOPSIS
1365     @t{gvpectrl} [@strong{-ckgs}] [@strong{--config=}@emph{DIR}] [@strong{--generate-keys}] [@strong{--help}] [@strong{--kill}[@strong{=}@emph{SIGNAL}]] [@strong{--show-config}] [@strong{--version}]
1366     @refill
1367    
1368    
1369     @section DESCRIPTION
1370     This is the control program for the @t{gvpe}, the virtual private ethernet daemon.
1371     @refill
1372    
1373    
1374     @section OPTIONS
1375    
1376    
1377     @itemize
1378    
1379    
1380     @item
1381 pcg 1.3 @strong{-c}, @strong{--config=}@emph{DIR}
1382 pcg 1.1
1383     Read configuration options from @emph{DIR}.
1384     @refill
1385    
1386    
1387     @item
1388 pcg 1.3 @strong{-g}, @strong{--generate-keys}
1389 pcg 1.1
1390     Generate public/private RSA keypair and exit.
1391     @refill
1392    
1393    
1394     @item
1395 pcg 1.3 @strong{-q}, @strong{--quiet}
1396    
1397     Suppresses messages the author finds nonessential for scripting purposes.
1398     @refill
1399    
1400    
1401     @item
1402     @strong{--help}
1403 pcg 1.1
1404     Display short list of options.
1405     @refill
1406    
1407    
1408     @item
1409 pcg 1.3 @strong{--kill}[@strong{=}@emph{SIGNAL}]
1410 pcg 1.1
1411     Attempt to kill a running @t{gvpectrl} (optionally with the specified @emph{SIGNAL} instead of @t{SIGTERM}) and exit.
1412     @refill
1413    
1414    
1415     @item
1416 pcg 1.3 @strong{--show-config}
1417 pcg 1.1
1418     Show a summary of the configuration, and how gvpe interprets it. Can also be very useful when designing firewall scripts.
1419     @refill
1420    
1421    
1422     @item
1423 pcg 1.3 @strong{--version}
1424 pcg 1.1
1425     Output version information and exit.
1426     @refill
1427     @end itemize
1428    
1429    
1430    
1431     @section BUGS
1432     If you find any bugs, report them to @t{gvpe@@schmorp.de}.
1433     @refill
1434    
1435    
1436    
1437     @node gvpe,gvpe.protocol,gvpectrl,Top
1438    
1439     @chapter gvpe
1440    
1441     @section NAME
1442     @t{gvpe} - GNU Virtual Private Ethernet Daemon
1443     @refill
1444    
1445    
1446     @section SYNOPSIS
1447     @t{gvpe} [@strong{-cDlL}] [@strong{--config=}@emph{DIR}] [@strong{--no-detach}] [@strong{-l=}@emph{LEVEL]}] [@strong{--kill}[@strong{=}@emph{SIGNAL}]] [@strong{--mlock}] [@strong{--help}] [@strong{--version}] @emph{NODENAME} [@emph{option...}]
1448     @refill
1449    
1450    
1451     @section DESCRIPTION
1452     See the gvpe(5) manpage for an introduction to the gvpe suite.
1453     @refill
1454     This is the manual page for gvpe, the virtual private ethernet daemon. When started, @t{gvpe} will read it's configuration file to determine the network topology, and other configuration information, assuming the role of node @emph{NODENAME}. It will then connect to the tun/tap device and set up a socket for incoming connections. Then a script will be executed to further configure the virtual device. If that succeeds, it will detach from the controlling terminal and continue in the background, accepting and setting up connections to other gvpe daemons that are part of the virtual private ethernet.
1455     @refill
1456     The optional arguments after the node name have to be of the form:
1457     @refill
1458    
1459    
1460     @example
1461     [I<nodename>.]var=value
1462     @end example
1463    
1464     If the argument has a prefix of @t{nodename.} (i.e. @t{laptop.enable-dns=yes}) then it will be parsed after all the config directives for that node, if not, it is parsed befroe the first node directive in the config file, and can be used to set global options or default variables.
1465     @refill
1466     For example, to start @t{gvpe} in the foreground, with log-level @t{info} on the node @t{laptop}, with TCP enabled and HTTP-Proxy host and Port set, use this:
1467     @refill
1468    
1469    
1470     @example
1471     gvpe -D -l info laptop \
1472     http-proxy-host=10.0.0.18 http-proxy-port=3128 \
1473     laptop.enable-tcp=yes
1474     @end example
1475    
1476    
1477    
1478     @section OPTIONS
1479    
1480    
1481     @itemize
1482    
1483    
1484     @item
1485 pcg 1.3 @strong{-c}, @strong{--config=}@emph{DIR}
1486 pcg 1.1
1487     Read configuration options from @emph{DIR}
1488     @refill
1489    
1490    
1491     @item
1492 pcg 1.3 @strong{-d}, @strong{--l=}@emph{LEVEL}
1493 pcg 1.1
1494     Set logging level to @emph{LEVEL} (one of: noise, trace, debug, info, notice, warn, error, critical).
1495     @refill
1496    
1497    
1498     @item
1499 pcg 1.3 @strong{--help}
1500 pcg 1.1
1501     Display short list of options.
1502     @refill
1503    
1504    
1505     @item
1506 pcg 1.3 @strong{-D}, @strong{--no-detach}
1507 pcg 1.1
1508     Don't fork and detach but stay in foreground and log messages to stderr in addition to syslog.
1509     @refill
1510    
1511    
1512     @item
1513 pcg 1.3 @strong{-L}, @strong{--mlock}
1514 pcg 1.1
1515     Lock @t{gvpe} into main memory. This will prevent sensitive data like shared private keys to be written to the system swap files/partitions.
1516     @refill
1517    
1518    
1519     @item
1520 pcg 1.3 @strong{--version}
1521 pcg 1.1
1522     Output version information and exit.
1523     @refill
1524     @end itemize
1525    
1526    
1527    
1528     @section SIGNALS
1529    
1530    
1531     @itemize
1532    
1533    
1534     @item
1535 pcg 1.3 HUP
1536 pcg 1.1
1537     Closes/resets all connections, resets the retry time and will start connecting again (it will NOT re-read the config file). This is useful e.g. in a @t{/etc/ppp/if-up} script.
1538     @refill
1539    
1540    
1541     @item
1542 pcg 1.3 TERM
1543 pcg 1.1
1544     Closes/resets all connections and exits.
1545     @refill
1546    
1547    
1548     @item
1549 pcg 1.3 USR1
1550 pcg 1.1
1551     Dump current network status into the syslog (at loglevel @t{notice}, so make sure your loglevel allows this).
1552     @refill
1553     @end itemize
1554    
1555    
1556    
1557     @section FILES
1558    
1559    
1560     @itemize
1561    
1562    
1563     @item
1564 pcg 1.3 @t{/etc/gvpe/gvpe.conf}
1565 pcg 1.1
1566     The configuration file for @t{gvpe}.
1567     @refill
1568    
1569    
1570     @item
1571 pcg 1.3 @t{/etc/gvpe/if-up}
1572 pcg 1.1
1573     Script which is executed as soon as the virtual network device has been allocated. Purpose is to further configure that device.
1574     @refill
1575    
1576    
1577     @item
1578 pcg 1.3 @t{/etc/gvpe/node-up}
1579 pcg 1.1
1580     Script which is executed whenever a node connects to this node. This can be used for example to run nsupdate.
1581     @refill
1582    
1583    
1584     @item
1585 pcg 1.3 @t{/etc/gvpe/node-down}
1586 pcg 1.1
1587     Script which is executed whenever a connection to another node is lost. for example to run nsupdate.
1588     @refill
1589    
1590    
1591     @item
1592 pcg 1.3 @t{/etc/gvpe/pubkey/*}
1593 pcg 1.1
1594     The directory containing the public keys for every node, usually autogenerated by executing @t{gvpectrl --generate-keys}.
1595     @refill
1596    
1597    
1598     @item
1599 pcg 1.3 @t{/var/run/gvpe.pid}
1600 pcg 1.1
1601     The PID of the currently running @t{gvpe} is stored in this file.
1602     @refill
1603     @end itemize
1604    
1605    
1606    
1607     @section BUGS
1608     The cryptography in gvpe has not been thoroughly checked by many people yet. Use it at your own risk!
1609     @refill
1610     If you find any bugs, report them to @t{gvpe@@schmorp.de}.
1611     @refill
1612    
1613    
1614    
1615     @node gvpe.protocol,Simple Example,gvpe,Top
1616    
1617     @chapter gvpe.protocol
1618    
1619     @section The GNU-VPE Protocols
1620    
1621    
1622     @section Overview
1623     GVPE can make use of a number of protocols. One of them is the GNU VPE protocol which is used to authenticate tunnels and send encrypted data packets. This protocol is described in more detail the second part of this document.
1624     @refill
1625     The first part of this document describes the transport protocols which are used by GVPE to send it's data packets over the network.
1626     @refill
1627    
1628    
1629     @section PART 1: Transport protocols
1630 pcg 1.3 GVPE offers a wide range of transport protocols that can be used to interchange data between nodes. Protocols differ in their overhead, speed, reliability, and robustness.
1631 pcg 1.1 @refill
1632     The following sections describe each transport protocol in more detail. They are sorted by overhead/efficiency, the most efficient transport is listed first:
1633     @refill
1634    
1635    
1636     @subsection RAW IP
1637     This protocol is the best choice, performance-wise, as the minimum overhead per packet is only 38 bytes.
1638     @refill
1639     It works by sending the VPN payload using raw ip frames (using the protocol set by @t{ip-proto}).
1640     @refill
1641     Using raw ip frames has the drawback that many firewalls block "unknown" protocols, so this transport only works if you have full IP connectivity between nodes.
1642     @refill
1643    
1644    
1645     @subsection ICMP
1646 pcg 1.3 This protocol offers very low overhead (minimum 42 bytes), and can sometimes tunnel through firewalls when other protocols can not.
1647 pcg 1.1 @refill
1648 pcg 1.3 It works by prepending an ICMP header with type @t{icmp-type} and a code of @t{255}. The default @t{icmp-type} is @t{echo-reply}, so the resulting packets look like echo replies, which looks rather strange to network admins.
1649 pcg 1.1 @refill
1650     This transport should only be used if other transports (i.e. raw ip) are not available or undesirable (due to their overhead).
1651     @refill
1652    
1653    
1654     @subsection UDP
1655     This is a good general choice for the transport protocol as UDP packets tunnel well through most firewalls and routers, and the overhead per packet is moderate (minimum 58 bytes).
1656     @refill
1657     It should be used if RAW IP is not available.
1658     @refill
1659    
1660    
1661     @subsection TCP
1662     This protocol is a very bad choice, as it not only has high overhead (more than 60 bytes), but the transport also retries on it's own, which leads to congestion when the link has moderate packet loss (as both the TCP transport and the tunneled traffic will retry, increasing congestion more and more). It also has high latency and is quite inefficient.
1663     @refill
1664     It's only useful when tunneling through firewalls that block better protocols. If a node doesn't have direct internet access but a HTTP proxy that supports the CONNECT method it can be used to tunnel through a web proxy. For this to work, the @t{tcp-port} should be @t{443} (@t{https}), as most proxies do not allow connections to other ports.
1665     @refill
1666     It is an abuse of the usage a proxy was designed for, so make sure you are allowed to use it for GVPE.
1667     @refill
1668 pcg 1.3 This protocol also has server and client sides. If the @t{tcp-port} is set to zero, other nodes cannot connect to this node directly. If the @t{tcp-port} is non-zero, the node can act both as a client as well as a server.
1669 pcg 1.1 @refill
1670    
1671    
1672     @subsection DNS
1673     @strong{WARNING:} Parsing and generating DNS packets is rather tricky. The code almost certainly contains buffer overflows and other, likely exploitable, bugs. You have been warned.
1674     @refill
1675     This is the worst choice of transport protocol with respect to overhead (overhead can be 2-3 times higher than the transferred data), and latency (which can be many seconds). Some DNS servers might not be prepared to handle the traffic and drop or corrupt packets. The client also has to constantly poll the server for data, so the client will constantly create traffic even if it doesn't need to transport packets.
1676     @refill
1677     In addition, the same problems as the TCP transport also plague this protocol.
1678     @refill
1679 pcg 1.3 It's only use is to tunnel through firewalls that do not allow direct internet access. Similar to using a HTTP proxy (as the TCP transport does), it uses a local DNS server/forwarder (given by the @t{dns-forw-host} configuration value) as a proxy to send and receive data as a client, and an @t{NS} record pointing to the GVPE server (as given by the @t{dns-hostname} directive).
1680 pcg 1.1 @refill
1681 pcg 1.3 The only good side of this protocol is that it can tunnel through most firewalls mostly undetected, iff the local DNS server/forwarder is sane (which is true for most routers, WLAN gateways and nameservers).
1682 pcg 1.1 @refill
1683 pcg 1.3 Finetuning needs to be done by editing @t{src/vpn_dns.C} directly.
1684 pcg 1.1 @refill
1685    
1686    
1687     @section PART 2: The GNU VPE protocol
1688     This section, unfortunately, is not yet finished, although the protocol is stable (until bugs in the cryptography are found, which will likely completely change the following description). Nevertheless, it should give you some overview over the protocol.
1689     @refill
1690    
1691    
1692     @subsection Anatomy of a VPN packet
1693     The exact layout and field lengths of a VPN packet is determined at compiletime and doesn't change. The same structure is used for all transort protocols, be it RAWIP or TCP.
1694     @refill
1695    
1696    
1697     @example
1698     +------+------+--------+------+
1699     | HMAC | TYPE | SRCDST | DATA |
1700     +------+------+--------+------+
1701     @end example
1702    
1703     The HMAC field is present in all packets, even if not used (e.g. in auth request packets), in which case it is set to all zeroes. The checksum itself is calculated over the TYPE, SRCDST and DATA fields in all cases.
1704     @refill
1705     The TYPE field is a single byte and determines the purpose of the packet (e.g. RESET, COMPRESSED/UNCOMPRESSED DATA, PING, AUTH REQUEST/RESPONSE, CONNECT REQUEST/INFO etc.).
1706     @refill
1707 pcg 1.3 SRCDST is a three byte field which contains the source and destination node IDs (12 bits each).
1708 pcg 1.1 @refill
1709     The DATA portion differs between each packet type, naturally, and is the only part that can be encrypted. Data packets contain more fields, as shown:
1710     @refill
1711    
1712    
1713     @example
1714     +------+------+--------+------+-------+------+
1715     | HMAC | TYPE | SRCDST | RAND | SEQNO | DATA |
1716     +------+------+--------+------+-------+------+
1717     @end example
1718    
1719     RAND is a sequence of fully random bytes, used to increase the entropy of the data for encryption purposes.
1720     @refill
1721 pcg 1.3 SEQNO is a 32-bit sequence number. It is negotiated at every connection initialization and starts at some random 31 bit value. VPE currently uses a sliding window of 512 packets/sequence numbers to detect reordering, duplication and replay attacks.
1722 pcg 1.1 @refill
1723    
1724    
1725 pcg 1.3 @subsection The authentication protocol
1726 pcg 1.1 Before hosts can exchange packets, they need to establish authenticity of the other side and a key. Every host has a private RSA key and the public RSA keys of all other hosts.
1727     @refill
1728 pcg 1.3 A host establishes a simplex connection by sending the other host an RSA encrypted challenge containing a random challenge (consisting of the encryption key to use when sending packets, more random data and PKCS1_OAEP padding) and a random 16 byte "challenge-id" (used to detect duplicate auth packets). The destination host will respond by replying with an (unencrypted) RIPEMD160 hash of the decrypted challenge, which will authenticate that host. The destination host will also set the outgoing encryption parameters as given in the packet.
1729 pcg 1.1 @refill
1730     When the source host receives a correct auth reply (by verifying the hash and the id, which will expire after 120 seconds), it will start to accept data packets from the destination host.
1731     @refill
1732     This means that a host can only initate a simplex connection, telling the other side the key it has to use when it sends packets. The challenge reply is only used to set the current IP address of the other side and protocol parameters.
1733     @refill
1734     This protocol is completely symmetric, so to be able to send packets the destination host must send a challenge in the exact same way as already described (so, in essence, two simplex connections are created per host pair).
1735     @refill
1736    
1737    
1738     @subsection Retrying
1739 pcg 1.3 When there is no response to an auth request, the host will send auth requests in bursts with an exponential backoff. After some time it will resort to PING packets, which are very small (8 bytes + protocol header) and lightweight (no RSA operations required). A host that receives ping requests from an unconnected peer will respond by trying to create a connection.
1740 pcg 1.1 @refill
1741     In addition to the exponential backoff, there is a global rate-limit on a per-IP base. It allows long bursts but will limit total packet rate to something like one control packet every ten seconds, to avoid accidental floods due to protocol problems (like a RSA key file mismatch between two hosts).
1742     @refill
1743 pcg 1.3 The intervals between retries are limited by the @t{max-retry} configuration value. A node with @t{connect} = @t{always} will always retry, a node with @t{connect} = @t{ondemand} will only try (and re-try) to connect as long as there are packets in the queue, usually this limits the retry period to @t{max-ttl} seconds.
1744     @refill
1745     Sending packets over the VPN will reset the retry intervals as well, which means as long as somebody is trying to send packets to a given node, GVPE will try to connect every few seconds.
1746     @refill
1747 pcg 1.1
1748    
1749     @subsection Routing and Protocol translation
1750 pcg 1.3 The GVPE routing algorithm is easy: there isn't much routing to speak of: When routing packets to another node, GVPE trues the following options, in order:
1751 pcg 1.1 @refill
1752 pcg 1.3
1753    
1754     @itemize
1755    
1756    
1757     @item
1758     If the two hosts should be able to reach each other directly (common protocol, port known), then GVPE will send the packet directly to the other node.
1759    
1760    
1761    
1762     @item
1763     If this isn't possible (e.g. because the node doesn't have a @t{hostname} or known port), but the nodes speak a common protocol and a router is available, then GVPE will ask a router to "mediate" between both nodes (see below).
1764    
1765    
1766    
1767     @item
1768     If a direct connection isn't possible (no common protocols) or forbidden (@t{deny-direct}) and there are any routers, then GVPE will try to send packets to the router with the highest priority that is connected already @emph{and} is able (as specified by the config file) to connect directly to the target node.
1769    
1770    
1771    
1772     @item
1773     If no such router exists, then GVPE will simply send the packet to the node with the highest priority available.
1774    
1775    
1776    
1777     @item
1778     Failing all that, the packet will be dropped.
1779    
1780     @end itemize
1781    
1782     A host can usually declare itself unreachable directly by setting it's port number(s) to zero. It can declare other hosts as unreachable by using a config-file that disables all protocols for these other hosts. Another option is to disable all protocols on that host in the other config files.
1783 pcg 1.1 @refill
1784 pcg 1.3 If two hosts cannot connect to each other because their IP address(es) are not known (such as dialup hosts), one side will send a @emph{mediated} connection request to a router (routers must be configured to act as routers!), which will send both the originating and the destination host a connection info request with protocol information and IP address of the other host (if known). Both hosts will then try to establish a direct connection to the other peer, which is usually possible even when both hosts are behind a NAT gateway.
1785 pcg 1.1 @refill
1786 pcg 1.3 Routing via other nodes works because the SRCDST field is not encrypted, so the router can just forward the packet to the destination host. Since each host uses it's own private key, the router will not be able to decrypt or encrypt packets, it will just act as a simple router and protocol translator.
1787 pcg 1.1 @refill
1788    
1789    
1790    
1791     @node Simple Example,Complex Example,gvpe.protocol,Top
1792    
1793     @chapter Simple Example
1794     In this example, gvpe is used to implement a simple, UDP-based ethernet on three hosts.
1795     @refill
1796     The config file (@t{gvpe.conf}) is the same on all hosts:
1797     @refill
1798    
1799    
1800     @example
1801     enable-udp = yes # use UDP
1802     udp-port = 407 # use this UDP port
1803     mtu = 1492 # handy for TDSL
1804     ifname = vpn0 # I prefer vpn0 over e.g. tap0
1805     @end example
1806    
1807    
1808    
1809     @example
1810     node = huffy # arbitrary node name
1811     hostname = 1.2.3.4 # ip address if this host
1812     @end example
1813    
1814    
1815    
1816     @example
1817     node = welshy
1818     hostname = www.example.net # resolve at connection time
1819     @end example
1820    
1821    
1822    
1823     @example
1824     node = wheelery
1825     # no hostname, will be determinded dynamically using router1 or router2
1826     @end example
1827    
1828     @t{gvpe} will execute the @t{if-up} script on every hosts, which, for linux, could look like this for all three hosts:
1829     @refill
1830    
1831    
1832     @example
1833     ifconfig $IFNAME hw ether $MAC mtu $MTU
1834     ifconfig $IFNAME 10.0.0.$NODE
1835     route add -net 10.0.0.0 netmask 255.0.0.0 dev $IFNAME
1836     @end example
1837    
1838     The @t{10.0.0.$NODE} resolves to @t{10.0.0.1} on @t{huffy}, @t{10.0.0.2} on @t{welshy} and so on. Other schemes, such as @t{10.$NODE.0.1} might be useful, too.
1839     @refill
1840     After generating the keys (gvpectrl) and starting the daemon (@t{gvpe -D -l info }@emph{NODENAME} for test purposes) the three hosts should be able to ping each other.
1841     @refill
1842     If you have an internal @t{10.x.x.x} network (with a tighter netmask then @t{255.0.0.0}, e.g. @t{10.1.0.0} on @t{huffy}, @t{10.2.0.0} on @t{welshy} and so on), you can now enable ip-forwarding and proxy-arp (or set the hosts as default gateway), and your three hosts should forward traffic from each network to each other.
1843     @refill
1844    
1845    
1846     @node Complex Example,complex/gvpe.conf,Simple Example,Top
1847    
1848     @chapter Complex Example
1849     These files are configuration files for "our" internal network.
1850    
1851     It is highly non-trivial, so don't use this configuration as the basis of
1852     your network unless you know what you are doing.
1853    
1854     It features: around 30 hosts, many of them have additional networks behind
1855     them and use an assortment of different tunneling protocols. The vpn is
1856     fully routed, no arp is used at all.
1857    
1858     The public IP addresses of connecting nodes are automatically registered
1859     via dns on the node ruth, using a node-up/node-down script.
1860    
1861     And last not least: the if-up script can generate information to be used
1862     in firewall rules (IP-net/MAC-address pairs) so ensure packet integrity so
1863     you can use your iptables etc. firewall to filter by IP address only.
1864    
1865     @menu
1866     * complex/gvpe.conf:: An example gvpe configuration
1867     * complex/if-up:: A fully-routing if-up config
1868     * complex/node-up:: A node-up/node-down script utilizing dynds
1869     @end menu
1870    
1871    
1872     @node complex/gvpe.conf,complex/if-up,Complex Example,Complex Example
1873    
1874     @chapter complex/gvpe.conf
1875    
1876    
1877     @example
1878     # sample configfile
1879     # the config file must be exactly(!) the same on all nodes
1880    
1881     rekey = 54321 # the rekeying interval
1882     keepalive = 300 # the keepalive interval
1883     on ruth keepalive = 120 # ruth is important and demands lower keepalives
1884     on surfer keepalive = 40
1885     mtu = 1492 # the mtu (minimum mtu of attached host)
1886     ifname = vpn0 # the tunnel interface name to use
1887     ifpersist = no # the tun device should be persistent
1888     inherit-tos = yes # should tunnel packets inherit tos flags?
1889     compress = yes # wether compression should be used (NYI)
1890     connect = ondemand # connect to this host always/never or ondemand
1891     router-priority = 1 # route for everybody - if necessary
1892    
1893     loglevel = notice # info logs connects, notice only important messages
1894     on mobil loglevel = info
1895     on doom loglevel = info
1896     on ruth loglevel = info
1897    
1898     udp-port = 407 # the udp port to use for sending/receiving packets
1899     tcp-port = 443 # the tcp port to listen for connections (we use https over proxy)
1900     ip-proto = 50 # (ab)use the ipsec protocol as rawip
1901     icmp-type = 0 # (ab)use echo replies for tunneling
1902     enable-udp = yes # udp is spoken almost everywhere
1903     enable-tcp = no # tcp is not spoken everywhere
1904     enable-rawip = no # rawip is not spoken everywhere
1905     enable-icmp = no # most hosts don't bother to icmp
1906    
1907     # every "node =" introduces a new node in the network
1908     # the options following it don't set defaults but are
1909     # node-specific.
1910    
1911     # marc@@lap
1912     node = mobil
1913    
1914     # marc@@home
1915     node = doom
1916     enable-rawip = yes
1917     enable-tcp = yes
1918    
1919     # marc@@uni
1920     node = ruth
1921     enable-rawip = yes
1922     enable-tcp = yes
1923     enable-icmp = yes
1924     hostname = 200.100.162.95
1925     connect = always
1926     router-priority = 30
1927     on ruth node-up = node-up
1928     on ruth node-down = node-up
1929    
1930     # marc@@mu
1931     node = frank
1932     enable-rawip = yes
1933     hostname = 44.88.167.250
1934     router-priority = 20
1935     connect = always
1936    
1937     # nethype
1938     node = rain
1939     enable-rawip = yes
1940     hostname = 145.253.105.130
1941     router-priority = 10
1942     connect = always
1943    
1944     # marco@@home
1945     node = marco
1946     enable-rawip = yes
1947    
1948     # stefan@@ka
1949     node = wappla
1950     connect = never
1951    
1952     # stefan@@lap
1953     node = stefan
1954     udp-port = 408
1955     connect = never
1956    
1957     # paul@@wg
1958     node = n8geil
1959     on ruth enable-icmp = yes
1960     on n8geil enable-icmp = yes
1961     enable-udp = no
1962    
1963     # paul@@lap
1964     node = syrr
1965    
1966     # paul@@lu
1967     node = donomos
1968    
1969     # marco@@hn
1970     node = core
1971    
1972     # elmex@@home
1973     node = elmex
1974     enable-rawip = yes
1975     hostname = 100.251.143.181
1976    
1977     # stefan@@kwc.at
1978     node = fwkw
1979     connect = never
1980     on stefan connect = always
1981     on wappla connect = always
1982     hostname = 182.73.81.146
1983    
1984     # elmex@@home
1985     node = jungfrau
1986     enable-rawip = yes
1987    
1988     # uni main router
1989     node = surfer
1990     enable-rawip = yes
1991     enable-tcp = no
1992     enable-icmp = yes
1993     hostname = 200.100.162.79
1994     connect = always
1995     router-priority = 40
1996    
1997     # jkneer@@marvin
1998     node = marvin
1999     enable-rawip = yes
2000     enable-udp = no
2001    
2002     # jkneer@@entrophy
2003     node = entrophy
2004     enable-udp = no
2005     enable-tcp = yes
2006    
2007     # mr. primitive
2008     node = voyager
2009     enable-udp = no
2010     enable-tcp = no
2011     on voyager enable-tcp = yes
2012     on voyager enable-udp = yes
2013    
2014     # v-server (barbados.dn-systems.de)
2015     #node = vserver
2016     #enable-udp = yes
2017     #hostname = 193.108.181.74
2018     @end example
2019    
2020    
2021    
2022     @node complex/if-up,complex/node-up,complex/gvpe.conf,Complex Example
2023    
2024     @chapter complex/if-up
2025    
2026    
2027     @example
2028     #!/bin/bash
2029    
2030     # Some environment variables will be set:
2031     #
2032     # CONFBASE=/etc/vpe # the configuration directory prefix
2033     # IFNAME=vpn0 # the network interface (ifname)
2034     # MAC=fe:fd:80:00:00:01 # the mac-address to use for the interface
2035     # NODENAME=cerebro # the selected nodename (-n switch)
2036     # NODEID=1 # the numerical node id
2037     # MTU=1436 # the tunnel packet overhead (set mtu to 1500-$OVERHEAD)
2038    
2039     # this if-up script is rather full-featured, and is used to
2040     # generate a fully-routed (no arp traffic) vpn. the main portion
2041     # consists of "ipn" calls (see below).
2042    
2043     # some hosts require additional specific configuration, this is handled
2044     # using if statements near the end of the script.
2045    
2046     # with the --fw switch, outputs mac/net pairs for your firewall use:
2047     # if-up --fw | while read mac net; do
2048     # iptables -t filter -A INPUT -i vpn0 -p all -m mac --mac-source \! $mac -s $net -j DROP
2049     # done
2050    
2051     ipn() @{
2052     local id="$1"; shift
2053     local mac=fe:fd:80:00:00:$(printf "%02x" $id)
2054     if [ -n "$FW" ]; then
2055     for net in "$@@"; do
2056     echo "$mac $net"
2057     done
2058     else
2059     local ip="$1"; shift
2060     if [ "$id" == $NODEID ]; then
2061     [ -n "$ADDR_ONLY" ] && ip addr add $ip broadcast 10.255.255.255 dev $IFNAME
2062     elif [ -z "$ADDR_ONLY" ]; then
2063     ip neighbour add $ip lladdr $mac nud permanent dev $IFNAME
2064     for route in "$@@"; do
2065     ip route add $route via $ip dev vpn0
2066     done
2067     fi
2068     fi
2069     @}
2070    
2071     ipns() @{
2072     # this contains the generic routing information for the vpn
2073     # each call to ipn has the following parameters:
2074     # ipn <node-id> <gateway-ip> [<route> ...]
2075     # the second line (ipn 2) means:
2076     # the second node (doom in the config file) has the ip address 10.0.0.5,
2077     # which is the gateway for the 10.0/28 network and three additional ip
2078     # addresses
2079    
2080     ipn 1 10.0.0.20
2081     ipn 2 10.0.0.5 10.0.0.0/28 #200.100.162.92 200.100.162.93 100.99.218.222
2082     ipn 3 10.0.0.17
2083     ipn 4 10.0.0.18
2084     ipn 5 10.0.0.19 10.3.0.0/16
2085     ipn 6 10.0.0.21 10.0.2.0/26 #200.100.162.17
2086     ipn 7 10.0.0.22 10.1.2.0/24 # wappla, off
2087     ipn 8 10.0.0.23 # stefan, off
2088     ipn 9 10.0.0.24 10.13.0.0/16
2089     ipn 10 10.0.0.25
2090     ipn 11 10.0.0.26
2091     ipn 12 10.0.0.27 10.0.2.64/26
2092     ipn 13 10.0.0.28 10.0.3.0/24
2093     ipn 14 10.0.0.29 10.1.1.0/24 # fwkw, off
2094     # mind the gateway ip gap
2095     ipn 15 10.9.0.30 10.0.4.0/24
2096     ipn 16 10.9.0.31
2097     ipn 17 10.9.0.32 10.42.0.0/16
2098     ipn 18 10.9.0.33
2099     ipn 19 10.9.0.34
2100     #ipn 20 10.9.0.35
2101     @}
2102    
2103     if [ "$1" == "--fw" ]; then
2104     FW=1
2105    
2106     ipns
2107     else
2108     exec >/var/log/vpe.if-up 2>&1
2109     set -x
2110    
2111     [ $NODENAME = "ruth" ] && ip link set $IFNAME down # hack
2112    
2113     # first set the link up and initialize the interface ip
2114     # address.
2115     ip link set $IFNAME address $MAC
2116     ip link set $IFNAME mtu $MTU up
2117     ADDR_ONLY=1 ipns # set addr only
2118    
2119     # now initialize the main vpn routes (10.0/8)
2120     # the second route is a hack to to reach some funnily-connected
2121     # machines.
2122     ip route add 10.0.0.0/8 dev $IFNAME
2123     ip route add 10.0.0.0/27 dev $IFNAME
2124    
2125     ipns # set the interface routes
2126    
2127     # now for something completely different, ehr, something not
2128     # easily doable with ipn, namely some extra specific highly complicated
2129     # and non-regular setups for some machines.
2130     if [ $NODENAME = doom ]; then
2131     ip addr add 200.100.162.92 dev $IFNAME
2132     ip route add 200.100.0.0/16 via 10.0.0.17 dev $IFNAME
2133     ip route flush table 101
2134     ip route add table 101 default src 200.100.162.92 via 10.0.0.17 dev $IFNAME
2135    
2136     ip addr add 100.99.218.222 dev $IFNAME
2137     ip route add 100.99.218.192/27 via 10.0.0.19 dev $IFNAME
2138     ip route flush table 103
2139     ip route add table 103 default src 100.99.218.222 via 10.0.0.19
2140    
2141     elif [ $NODENAME = marco ]; then
2142     ip addr add 200.100.162.17 dev $IFNAME
2143    
2144     for addr in 79 89 90 91 92 93 94 95; do
2145     ip route add 200.100.162.$addr dev ppp0
2146     done
2147     ip route add 200.100.76.0/23 dev ppp0
2148     ip route add src 200.100.162.17 200.100.0.0/16 via 10.0.0.17 dev $IFNAME
2149    
2150     elif [ $NODENAME = ruth ]; then
2151     ip route add 200.100.162.17 via 10.0.0.21 dev vpn0
2152     ip route add 200.100.162.92 via 10.0.0.5 dev vpn0
2153     ip route add 200.100.162.93 via 10.0.0.5 dev vpn0
2154    
2155     fi
2156    
2157     # and this is the second part of the 10.0/27 hack. don't ask.
2158     [ $NODENAME != fwkw ] && ip route add 10.0.0.0/24 via 10.0.0.29 dev $IFNAME
2159     fi
2160     @end example
2161    
2162    
2163    
2164     @node complex/node-up,Index,complex/if-up,Complex Example
2165    
2166     @chapter complex/node-up
2167    
2168    
2169     @example
2170     #!/bin/sh
2171    
2172     # Some environment variables will be set (in addition the ones
2173     # set in if-up, too):
2174     #
2175     # DESTNODE=doom # others nodename
2176     # DESTID=5 # others node id
2177     # DESTIP=188.13.66.8 # others ip
2178     # DESTPORT=407 # others port
2179     # STATE=up/down # node-up gets UP, node-down script gets DOWN
2180    
2181     if [ $STATE = up ]; then
2182     @{
2183     echo update delete $DESTNODE.lowttl.example.com. a
2184     echo update delete $DESTNODE-last.lowttl.example.com. a
2185     echo update add $DESTNODE.lowttl.example.com. 1 in a $DESTIP
2186     echo update add $DESTNODE-last.lowttl.example.com. 1 in a $DESTIP
2187     echo
2188     @} | nsupdate -d -k $CONFBASE:marc.example.net.
2189     else
2190     @{
2191     echo update delete $DESTNODE.lowttl.example.com. a
2192     echo update delete $DESTNODE-last.lowttl.example.com. a
2193     echo update add $DESTNODE-last.lowttl.example.com. 1 in a $DESTIP
2194     echo
2195     @} | nsupdate -d -k $CONFBASE:marc.example.net.
2196     fi
2197     @end example
2198    
2199    
2200    
2201     @node Index,,complex/node-up,Top
2202    
2203     @chapter Index
2204     @printindex cp
2205    
2206    
2207    
2208     @bye
2209