ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/gvpe/doc/gvpe.texi
Revision: 1.1
Committed: Wed Jan 18 13:15:07 2006 UTC (18 years, 4 months ago) by pcg
Content type: application/x-texinfo
Branch: MAIN
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     Copyright @copyright{} 2003-2005 Marc Lehmann <gvpe@@schmorp.de>.
24    
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     @author Marc Lehmann (template by Ivo Timmermans and Guus Sliepen)
39    
40     @page
41     @vskip 0pt plus 1filll
42     @cindex copyright
43    
44     Copyright @copyright{} 2003-2005 Marc Lehmann <gvpe@@schmorp.de>.
45    
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     @b{
104     @cindex Virtual
105     Virtual}
106    
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     @b{
115     @cindex Private
116     Private}
117    
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     @b{
126     @cindex Network
127     Network}
128    
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     @b{SIMPLE DESIGN}
145    
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     @b{EASY TO SETUP}
152    
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     @b{MAC-BASED SECURITY}
159    
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     @b{gvpectrl}
176    
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     @b{gvpe}
183    
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     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 hosts. It is not uncommon for node sections to be completely empty - if the default values are right.
651     @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     @b{dns-forw-host = hostname/ip}
669    
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     @b{dns-forw-port = port-number}
677    
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     @b{dns-max-outstanding = integer-number-of-requests}
685    
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     @b{dns-overlap-factor = float}
695    
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     @b{dns-send-interval = send-interval-in-seconds}
707    
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     @b{dns-timeout-factor = float}
717    
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     The default should be working ok for most links.
724     @refill
725    
726    
727     @item
728     @b{if-up = relative-or-absolute-path}
729    
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     @b{CONFBASE=/etc/gvpe}
742    
743     @cindex CONFBASE
744     The configuration base directory.
745     @refill
746    
747    
748     @item
749     @b{IFNAME=vpn0}
750    
751     @cindex IFNAME
752     The network interface to initialize.
753     @refill
754    
755    
756     @item
757     @b{IFTYPE=native # or tincd}
758    
759     @cindex IFTYPE
760    
761    
762     @item
763     @b{IFSUBTYPE=linux # or freebsd, darwin etc..}
764    
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     @b{MTU=1436}
772    
773     @cindex MTU
774     The MTU to set the interface to. You can use lower values (if done consistently on all hosts), but this is usually ineffective.
775     @refill
776    
777    
778     @item
779     @b{NODES=5}
780    
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     @b{IFUPDATA=string}
795    
796     @cindex IFUPDATA
797     The value of the configuration directive @t{if-up-data}.
798     @refill
799    
800    
801     @item
802     @b{MAC=fe:fd:80:00:00:01}
803    
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     @b{NODENAME=branch1}
813    
814     @cindex NODENAME
815     The nickname of the node.
816     @refill
817    
818    
819     @item
820     @b{NODEID=1}
821    
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     @b{ifname = devname}
847    
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     @b{ifpersist = yes|true|on | no|false|off}
855    
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     @b{ip-proto = numerical-ip-protocol}
863    
864     @cindex ip-proto
865     Sets the protocol number to be used for the rawip protocol. This is a global option because all hosts 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     @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     @b{http-proxy-host = hostname/ip}
873    
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     To make best use of this option disable all protocols except tcp in your config file and make sure your routers (or all other hosts) are listening on a port that the proxy allows (443, https, is a common choice).
882     @refill
883     If you have a router, connecting to it will suffice. Otherwise tcp must be enabled on all hosts.
884     @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     @b{http-proxy-port = proxy-tcp-port}
899    
900     @cindex http-proxy-port
901     The port where your proxy server listens.
902     @refill
903    
904    
905     @item
906     @b{http-proxy-auth = login:password}
907    
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     @b{keepalive = seconds}
915    
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     @b{loglevel = noise|trace|debug|info|notice|warn|error|critical}
923    
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     @b{mtu = bytes}
931    
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     This value must be the minimum of the mtu values of all hosts.
938     @refill
939    
940    
941     @item
942     @b{node = nickname}
943    
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     @b{node-up = relative-or-absolute-path}
951    
952     @cindex node-up
953     Sets a command (default: no script) that should be called whenever a connection is established (even on rekeying operations). In addition to all the variables passed to @t{if-up} scripts, the following environment variables will be set:
954     @refill
955    
956    
957     @itemize
958    
959    
960     @item
961     @b{DESTNODE=branch2}
962    
963     @cindex DESTNODE
964     The name of the remote node.
965     @refill
966    
967    
968     @item
969     @b{DESTID=2}
970    
971     @cindex DESTID
972     The node id of the remote node.
973     @refill
974    
975    
976     @item
977     @b{DESTIP=188.13.66.8}
978    
979     @cindex DESTIP
980     The numerical IP address of the remote host (gvpe accepts connections from everywhere, as long as the other host can authenticate itself).
981     @refill
982    
983    
984     @item
985     @b{DESTPORT=655 # deprecated}
986    
987     @cindex DESTPORT
988     The UDP port used by the other side.
989     @refill
990    
991    
992     @item
993     @b{STATE=UP}
994    
995     @cindex STATE
996     Node-up scripts get called with STATE=UP, node-down scripts get called with STATE=DOWN.
997     @refill
998     @end itemize
999    
1000     Here is a nontrivial example that uses nsupdate to update the name => ip mapping in some dns zone:
1001     @refill
1002    
1003    
1004     @example
1005     #!/bin/sh
1006     @{
1007     echo update delete $DESTNODE.lowttl.example.net. a
1008     echo update add $DESTNODE.lowttl.example.net. 1 in a $DESTIP
1009     echo
1010     @} | nsupdate -d -k $CONFBASE:key.example.net.
1011     @end example
1012    
1013    
1014    
1015     @item
1016     @b{node-down = relative-or-absolute-path}
1017    
1018     @cindex node-down
1019     Same as @t{node-up}, but gets called whenever a connection is lost.
1020     @refill
1021    
1022    
1023     @item
1024     @b{pid-file = path}
1025    
1026     @cindex pid-file
1027     The path to the pid file to check and create (default: @t{LOCALSTATEDIR/run/gvpe.pid}).
1028     @refill
1029    
1030    
1031     @item
1032     @b{private-key = relative-path-to-key}
1033    
1034     @cindex private-key
1035     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.
1036     @refill
1037     Since only the private key file of the current node is used and the private key file should be kept secret per-host to avoid spoofings, it is not recommended to use this feature.
1038     @refill
1039    
1040    
1041     @item
1042     @b{rekey = seconds}
1043    
1044     @cindex rekey
1045     Sets the rekeying interval in seconds (default: @t{3600}). Connections are reestablished every @t{rekey} seconds.
1046     @refill
1047     @end itemize
1048    
1049    
1050    
1051     @subsection NODE SPECIFIC SETTINGS
1052     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.
1053     @refill
1054    
1055    
1056     @itemize
1057    
1058    
1059     @item
1060     @b{allow-direct = nodename}
1061    
1062     @cindex allow-direct
1063     Allow direct connections to this node. See @t{deny-direct} for more info.
1064     @refill
1065    
1066    
1067     @item
1068     @b{compress = yes|true|on | no|false|off}
1069    
1070     @cindex compress
1071     Wether to compress data packets sent to this host (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.
1072     @refill
1073    
1074    
1075     @item
1076     @b{connect = ondemand | never | always | disabled}
1077    
1078     @cindex connect
1079     Sets the connect mode (default: @t{always}). It can be @t{always} (always try to establish and keep a connection to the given host), @t{never} (never initiate a connection to the given host, but accept connections), @t{ondemand} (try to establish a connection on the first packet sent, and take it down after the keepalive interval) or @t{disabled} (node is bad, don't talk to it).
1080     @refill
1081    
1082    
1083     @item
1084     @b{deny-direct = nodename | *}
1085    
1086     @cindex deny-direct
1087     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.
1088     @refill
1089     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).
1090     @refill
1091     The algorithm to check wether a connection may be direct is as follows:
1092     @refill
1093     1. Other node mentioned in a @t{allow-direct}? If yes, allow the connection.
1094     @refill
1095     2. Other node mentioned in a @t{deny-direct}? If yes, deny direct connections.
1096     @refill
1097     3. Allow the connection.
1098     @refill
1099     That is, @t{allow-direct} takes precende over @t{deny-direct}.
1100     @refill
1101     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.
1102     @refill
1103    
1104    
1105     @item
1106     @b{dns-domain = domain-suffix}
1107    
1108     @cindex dns-domain
1109     The DNS domain suffix that points to the DNS tunnel server for this node.
1110     @refill
1111     The domain must point to a NS record that points to the @emph{dns-hostname}, i.e.
1112     @refill
1113    
1114    
1115     @example
1116     dns-domainname = tunnel.example.net
1117     dns-hostname = tunnel-server.example.net
1118     @end example
1119    
1120     Corresponds to the following DNS entries in the @t{example.net} domain:
1121     @refill
1122    
1123    
1124     @example
1125     tunnel.example.net. NS tunnel-server.example.net.
1126     tunnel-server.example.net. A 13.13.13.13
1127     @end example
1128    
1129    
1130    
1131     @item
1132     @b{dns-hostname = hostname/ip}
1133    
1134     @cindex dns-hostname
1135     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.
1136     @refill
1137    
1138    
1139     @item
1140     @b{dns-port = port-number}
1141    
1142     @cindex dns-port
1143     The port to bind the DNS tunnel socket to. Must be @t{53} on DNS tunnel servers.
1144     @refill
1145    
1146    
1147     @item
1148     @b{enable-dns = yes|true|on | no|false|off}
1149    
1150     @cindex enable-dns
1151     See gvpe.protocol(7) for a description of the DNS transport protocol. Avoid this protocol if you can.
1152     @refill
1153     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.
1154     @refill
1155    
1156    
1157     @item
1158     @b{enable-icmp = yes|true|on | no|false|off}
1159    
1160     @cindex enable-icmp
1161     See gvpe.protocol(7) for a description of the ICMP transport protocol.
1162     @refill
1163     Enable the ICMP transport using icmp packets of type @t{icmp-type} on this node.
1164     @refill
1165    
1166    
1167     @item
1168     @b{enable-rawip = yes|true|on | no|false|off}
1169    
1170     @cindex enable-rawip
1171     See gvpe.protocol(7) for a description of the RAW IP transport protocol.
1172     @refill
1173     Enable the RAW IPv4 transport using the @t{ip-proto} protocol (default: @t{no}).
1174     @refill
1175    
1176    
1177     @item
1178     @b{enable-tcp = yes|true|on | no|false|off}
1179    
1180     @cindex enable-tcp
1181     See gvpe.protocol(7) for a description of the TCP transport protocol.
1182     @refill
1183     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.
1184     @refill
1185    
1186    
1187     @item
1188     @b{enable-udp = yes|true|on | no|false|off}
1189    
1190     @cindex enable-udp
1191     See gvpe.protocol(7) for a description of the UDP transport protocol.
1192     @refill
1193     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).
1194     @refill
1195     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.
1196     @refill
1197    
1198    
1199     @item
1200     @b{hostname = hostname | ip [can not be defaulted]}
1201    
1202     @cindex hostname
1203     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.
1204     @refill
1205    
1206    
1207     @item
1208     @b{icmp-type = integer}
1209    
1210     @cindex icmp-type
1211     Sets the type value to be used for outgoing (and incoming) packets sent via the ICMP transport.
1212     @refill
1213     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.
1214     @refill
1215    
1216    
1217     @item
1218     @b{if-up-data = value}
1219    
1220     @cindex if-up-data
1221     The value specified using this directive will be passed to the @t{if-up} script in the environment variable @t{IFUPDATA}.
1222     @refill
1223    
1224    
1225     @item
1226     @b{inherit-tos = yes|true|on | no|false|off}
1227    
1228     @cindex inherit-tos
1229     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.
1230     @refill
1231    
1232    
1233     @item
1234     @b{max-retry = positive-number}
1235    
1236     @cindex max-retry
1237     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.
1238     @refill
1239    
1240    
1241     @item
1242     @b{router-priority = 0 | 1 | positive-number>=2}
1243    
1244     @cindex router-priority
1245     Sets the router priority of the given host (default: @t{0}, disabled). If some host tries to connect to another host without a hostname, it asks the router host for it's IP address. The router host is the one with the highest priority larger than @t{1} that is currently reachable.
1246     @refill
1247     Make sure all hosts always connect (@t{connect = always}) to the router hosts, otherwise connecting to them might be impossible.
1248     @refill
1249     The special value @t{1} allows other hosts to route through the router host, but they will never route through it by default. The value @t{0} disables routing. 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.
1250     @refill
1251    
1252    
1253     @item
1254     @b{tcp-port = port-number}
1255    
1256     @cindex tcp-port
1257     Similar to @t{udp-port} (default: @t{655}), but sets the TCP port number.
1258     @refill
1259    
1260    
1261     @item
1262     @b{udp-port = port-number}
1263    
1264     @cindex udp-port
1265     Sets the port number used by the UDP protocol (default: @t{655}, not officially assigned by IANA!).
1266     @refill
1267     @end itemize
1268    
1269    
1270    
1271     @section CONFIG DIRECTORY LAYOUT
1272     The default (or recommended) directory layout for the config directory is:
1273     @refill
1274    
1275    
1276     @itemize
1277    
1278    
1279     @item
1280     @b{
1281     @cindex gvpe.conf
1282     gvpe.conf}
1283    
1284     The config file.
1285     @refill
1286    
1287    
1288     @item
1289     @b{
1290     @cindex if-up
1291     if-up}
1292    
1293     The if-up script
1294     @refill
1295    
1296    
1297     @item
1298     @b{
1299     @cindex node-up
1300     node-up,
1301     @cindex node-down
1302     node-down}
1303    
1304     If used the node up or node-down scripts.
1305     @refill
1306    
1307    
1308     @item
1309     @b{
1310     @cindex hostkey
1311     hostkey}
1312    
1313     The private key (taken from @t{hostkeys/nodename}) of the current host.
1314     @refill
1315    
1316    
1317     @item
1318     @b{
1319     @cindex pubkey/nodename
1320     pubkey/nodename}
1321    
1322     The public keys of the other nodes, one file per node.
1323     @refill
1324     @end itemize
1325    
1326    
1327    
1328    
1329     @node gvpectrl,gvpe,gvpe.conf,Top
1330    
1331     @chapter gvpectrl
1332    
1333     @section NAME
1334     @t{gvpectrl} - GNU Virtual Private Ethernet Control Program
1335     @refill
1336    
1337    
1338     @section SYNOPSIS
1339     @t{gvpectrl} [@strong{-ckgs}] [@strong{--config=}@emph{DIR}] [@strong{--generate-keys}] [@strong{--help}] [@strong{--kill}[@strong{=}@emph{SIGNAL}]] [@strong{--show-config}] [@strong{--version}]
1340     @refill
1341    
1342    
1343     @section DESCRIPTION
1344     This is the control program for the @t{gvpe}, the virtual private ethernet daemon.
1345     @refill
1346    
1347    
1348     @section OPTIONS
1349    
1350    
1351     @itemize
1352    
1353    
1354     @item
1355     @b{@strong{-c}, @strong{--config=}@emph{DIR}}
1356    
1357     Read configuration options from @emph{DIR}.
1358     @refill
1359    
1360    
1361     @item
1362     @b{@strong{-g}, @strong{--generate-keys}}
1363    
1364     Generate public/private RSA keypair and exit.
1365     @refill
1366    
1367    
1368     @item
1369     @b{@strong{--help}}
1370    
1371     Display short list of options.
1372     @refill
1373    
1374    
1375     @item
1376     @b{@strong{--kill}[@strong{=}@emph{SIGNAL}]}
1377    
1378     Attempt to kill a running @t{gvpectrl} (optionally with the specified @emph{SIGNAL} instead of @t{SIGTERM}) and exit.
1379     @refill
1380    
1381    
1382     @item
1383     @b{@strong{--show-config}}
1384    
1385     Show a summary of the configuration, and how gvpe interprets it. Can also be very useful when designing firewall scripts.
1386     @refill
1387    
1388    
1389     @item
1390     @b{@strong{--version}}
1391    
1392     Output version information and exit.
1393     @refill
1394     @end itemize
1395    
1396    
1397    
1398     @section BUGS
1399     If you find any bugs, report them to @t{gvpe@@schmorp.de}.
1400     @refill
1401    
1402    
1403    
1404     @node gvpe,gvpe.protocol,gvpectrl,Top
1405    
1406     @chapter gvpe
1407    
1408     @section NAME
1409     @t{gvpe} - GNU Virtual Private Ethernet Daemon
1410     @refill
1411    
1412    
1413     @section SYNOPSIS
1414     @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...}]
1415     @refill
1416    
1417    
1418     @section DESCRIPTION
1419     See the gvpe(5) manpage for an introduction to the gvpe suite.
1420     @refill
1421     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.
1422     @refill
1423     The optional arguments after the node name have to be of the form:
1424     @refill
1425    
1426    
1427     @example
1428     [I<nodename>.]var=value
1429     @end example
1430    
1431     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.
1432     @refill
1433     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:
1434     @refill
1435    
1436    
1437     @example
1438     gvpe -D -l info laptop \
1439     http-proxy-host=10.0.0.18 http-proxy-port=3128 \
1440     laptop.enable-tcp=yes
1441     @end example
1442    
1443    
1444    
1445     @section OPTIONS
1446    
1447    
1448     @itemize
1449    
1450    
1451     @item
1452     @b{@strong{-c}, @strong{--config=}@emph{DIR}}
1453    
1454     Read configuration options from @emph{DIR}
1455     @refill
1456    
1457    
1458     @item
1459     @b{@strong{-d}, @strong{--l=}@emph{LEVEL}}
1460    
1461     Set logging level to @emph{LEVEL} (one of: noise, trace, debug, info, notice, warn, error, critical).
1462     @refill
1463    
1464    
1465     @item
1466     @b{@strong{--help}}
1467    
1468     Display short list of options.
1469     @refill
1470    
1471    
1472     @item
1473     @b{@strong{-D}, @strong{--no-detach}}
1474    
1475     Don't fork and detach but stay in foreground and log messages to stderr in addition to syslog.
1476     @refill
1477    
1478    
1479     @item
1480     @b{@strong{-L}, @strong{--mlock}}
1481    
1482     Lock @t{gvpe} into main memory. This will prevent sensitive data like shared private keys to be written to the system swap files/partitions.
1483     @refill
1484    
1485    
1486     @item
1487     @b{@strong{--version}}
1488    
1489     Output version information and exit.
1490     @refill
1491     @end itemize
1492    
1493    
1494    
1495     @section SIGNALS
1496    
1497    
1498     @itemize
1499    
1500    
1501     @item
1502     @b{HUP}
1503    
1504     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.
1505     @refill
1506    
1507    
1508     @item
1509     @b{TERM}
1510    
1511     Closes/resets all connections and exits.
1512     @refill
1513    
1514    
1515     @item
1516     @b{USR1}
1517    
1518     Dump current network status into the syslog (at loglevel @t{notice}, so make sure your loglevel allows this).
1519     @refill
1520     @end itemize
1521    
1522    
1523    
1524     @section FILES
1525    
1526    
1527     @itemize
1528    
1529    
1530     @item
1531     @b{@t{/etc/gvpe/gvpe.conf}}
1532    
1533     The configuration file for @t{gvpe}.
1534     @refill
1535    
1536    
1537     @item
1538     @b{@t{/etc/gvpe/if-up}}
1539    
1540     Script which is executed as soon as the virtual network device has been allocated. Purpose is to further configure that device.
1541     @refill
1542    
1543    
1544     @item
1545     @b{@t{/etc/gvpe/node-up}}
1546    
1547     Script which is executed whenever a node connects to this node. This can be used for example to run nsupdate.
1548     @refill
1549    
1550    
1551     @item
1552     @b{@t{/etc/gvpe/node-down}}
1553    
1554     Script which is executed whenever a connection to another node is lost. for example to run nsupdate.
1555     @refill
1556    
1557    
1558     @item
1559     @b{@t{/etc/gvpe/pubkey/*}}
1560    
1561     The directory containing the public keys for every node, usually autogenerated by executing @t{gvpectrl --generate-keys}.
1562     @refill
1563    
1564    
1565     @item
1566     @b{@t{/var/run/gvpe.pid}}
1567    
1568     The PID of the currently running @t{gvpe} is stored in this file.
1569     @refill
1570     @end itemize
1571    
1572    
1573    
1574     @section BUGS
1575     The cryptography in gvpe has not been thoroughly checked by many people yet. Use it at your own risk!
1576     @refill
1577     If you find any bugs, report them to @t{gvpe@@schmorp.de}.
1578     @refill
1579    
1580    
1581    
1582     @node gvpe.protocol,Simple Example,gvpe,Top
1583    
1584     @chapter gvpe.protocol
1585    
1586     @section The GNU-VPE Protocols
1587    
1588    
1589     @section Overview
1590     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.
1591     @refill
1592     The first part of this document describes the transport protocols which are used by GVPE to send it's data packets over the network.
1593     @refill
1594    
1595    
1596     @section PART 1: Transport protocols
1597     GVPE offers a range of transport protocols that can be used to interchange data between nodes. Protocols differ in their overhead, speed, reliability, and robustness.
1598     @refill
1599     The following sections describe each transport protocol in more detail. They are sorted by overhead/efficiency, the most efficient transport is listed first:
1600     @refill
1601    
1602    
1603     @subsection RAW IP
1604     This protocol is the best choice, performance-wise, as the minimum overhead per packet is only 38 bytes.
1605     @refill
1606     It works by sending the VPN payload using raw ip frames (using the protocol set by @t{ip-proto}).
1607     @refill
1608     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.
1609     @refill
1610    
1611    
1612     @subsection ICMP
1613     This protocol offers very low overhead (minimum 42 bytes), and can sometimes tunnel through firewalls when other protocols cannot.
1614     @refill
1615     It works by prepending a 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.
1616     @refill
1617     This transport should only be used if other transports (i.e. raw ip) are not available or undesirable (due to their overhead).
1618     @refill
1619    
1620    
1621     @subsection UDP
1622     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).
1623     @refill
1624     It should be used if RAW IP is not available.
1625     @refill
1626    
1627    
1628     @subsection TCP
1629     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.
1630     @refill
1631     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.
1632     @refill
1633     It is an abuse of the usage a proxy was designed for, so make sure you are allowed to use it for GVPE.
1634     @refill
1635     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 (and @t{tcp-port} zero cannot be used). If the @t{tcp-port} is non-zero, the node can act both as a client as well as a server.
1636     @refill
1637    
1638    
1639     @subsection DNS
1640     @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.
1641     @refill
1642     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.
1643     @refill
1644     In addition, the same problems as the TCP transport also plague this protocol.
1645     @refill
1646     Most configuration needs to be done by editing @t{src/vpn_dns.C} directly.
1647     @refill
1648     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 a @t{NS} record pointing to the GVPE server (as given by the @t{dns-hostname} directive).
1649     @refill
1650     The only good side of this protocol is that it can tunnel through most firewalls undetected, iff the local DNS server/forwarder is sane (which is true for most routers, wlan gateways and nameservers).
1651     @refill
1652    
1653    
1654     @section PART 2: The GNU VPE protocol
1655     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.
1656     @refill
1657    
1658    
1659     @subsection Anatomy of a VPN packet
1660     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.
1661     @refill
1662    
1663    
1664     @example
1665     +------+------+--------+------+
1666     | HMAC | TYPE | SRCDST | DATA |
1667     +------+------+--------+------+
1668     @end example
1669    
1670     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.
1671     @refill
1672     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.).
1673     @refill
1674     SRCDST is a three byte field which contains the source and destination node ids (12 bits each). The protocol does not yet scale well beyond 30+ hosts, since all hosts must connect to each other once on startup. But if restarts are rare or tolerable and most connections are on demand, much larger networks are feasible.
1675     @refill
1676     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:
1677     @refill
1678    
1679    
1680     @example
1681     +------+------+--------+------+-------+------+
1682     | HMAC | TYPE | SRCDST | RAND | SEQNO | DATA |
1683     +------+------+--------+------+-------+------+
1684     @end example
1685    
1686     RAND is a sequence of fully random bytes, used to increase the entropy of the data for encryption purposes.
1687     @refill
1688     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 reply attacks.
1689     @refill
1690    
1691    
1692     @subsection The authentification protocol
1693     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.
1694     @refill
1695     A host establishes a simplex connection by sending the other host a 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 authentify that host. The destination host will also set the outgoing encryption parameters as given in the packet.
1696     @refill
1697     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.
1698     @refill
1699     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.
1700     @refill
1701     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).
1702     @refill
1703    
1704    
1705     @subsection Retrying
1706     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) and lightweight (no RSA operations required). A host that receives ping requests from an unconnected peer will respond by trying to create a connection.
1707     @refill
1708     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).
1709     @refill
1710    
1711    
1712     @subsection Routing and Protocol translation
1713     The gvpe routing algorithm is easy: there isn't any routing. GVPE always tries to establish direct connections, if the protocol abilities of the two hosts allow it.
1714     @refill
1715     If the two hosts should be able to reach each other (common protocol, ip and port all known), but cannot (network down), then there will be no connection, point.
1716     @refill
1717     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.
1718     @refill
1719     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 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 connection to the other peer, which is usually possible even when both hosts are behind a NAT gateway.
1720     @refill
1721     If the hosts cannot reach each other because they have no common protocol, the originator instead use the router with highest priority and matching protocol as peer. Since the SRCDST field is not encrypted, the router host 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.
1722     @refill
1723     When no router is connected, the host will aggressively try to connect to all routers, and if a router is asked for an unconnected host it will try to ask another router to establish the connection.
1724     @refill
1725     ... more not yet written about the details of the routing, please bug me ...
1726     @refill
1727    
1728    
1729    
1730     @node Simple Example,Complex Example,gvpe.protocol,Top
1731    
1732     @chapter Simple Example
1733     In this example, gvpe is used to implement a simple, UDP-based ethernet on three hosts.
1734     @refill
1735     The config file (@t{gvpe.conf}) is the same on all hosts:
1736     @refill
1737    
1738    
1739     @example
1740     enable-udp = yes # use UDP
1741     udp-port = 407 # use this UDP port
1742     mtu = 1492 # handy for TDSL
1743     ifname = vpn0 # I prefer vpn0 over e.g. tap0
1744     @end example
1745    
1746    
1747    
1748     @example
1749     node = huffy # arbitrary node name
1750     hostname = 1.2.3.4 # ip address if this host
1751     @end example
1752    
1753    
1754    
1755     @example
1756     node = welshy
1757     hostname = www.example.net # resolve at connection time
1758     @end example
1759    
1760    
1761    
1762     @example
1763     node = wheelery
1764     # no hostname, will be determinded dynamically using router1 or router2
1765     @end example
1766    
1767     @t{gvpe} will execute the @t{if-up} script on every hosts, which, for linux, could look like this for all three hosts:
1768     @refill
1769    
1770    
1771     @example
1772     ifconfig $IFNAME hw ether $MAC mtu $MTU
1773     ifconfig $IFNAME 10.0.0.$NODE
1774     route add -net 10.0.0.0 netmask 255.0.0.0 dev $IFNAME
1775     @end example
1776    
1777     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.
1778     @refill
1779     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.
1780     @refill
1781     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.
1782     @refill
1783    
1784    
1785     @node Complex Example,complex/gvpe.conf,Simple Example,Top
1786    
1787     @chapter Complex Example
1788     These files are configuration files for "our" internal network.
1789    
1790     It is highly non-trivial, so don't use this configuration as the basis of
1791     your network unless you know what you are doing.
1792    
1793     It features: around 30 hosts, many of them have additional networks behind
1794     them and use an assortment of different tunneling protocols. The vpn is
1795     fully routed, no arp is used at all.
1796    
1797     The public IP addresses of connecting nodes are automatically registered
1798     via dns on the node ruth, using a node-up/node-down script.
1799    
1800     And last not least: the if-up script can generate information to be used
1801     in firewall rules (IP-net/MAC-address pairs) so ensure packet integrity so
1802     you can use your iptables etc. firewall to filter by IP address only.
1803    
1804     @menu
1805     * complex/gvpe.conf:: An example gvpe configuration
1806     * complex/if-up:: A fully-routing if-up config
1807     * complex/node-up:: A node-up/node-down script utilizing dynds
1808     @end menu
1809    
1810    
1811     @node complex/gvpe.conf,complex/if-up,Complex Example,Complex Example
1812    
1813     @chapter complex/gvpe.conf
1814    
1815    
1816     @example
1817     # sample configfile
1818     # the config file must be exactly(!) the same on all nodes
1819    
1820     rekey = 54321 # the rekeying interval
1821     keepalive = 300 # the keepalive interval
1822     on ruth keepalive = 120 # ruth is important and demands lower keepalives
1823     on surfer keepalive = 40
1824     mtu = 1492 # the mtu (minimum mtu of attached host)
1825     ifname = vpn0 # the tunnel interface name to use
1826     ifpersist = no # the tun device should be persistent
1827     inherit-tos = yes # should tunnel packets inherit tos flags?
1828     compress = yes # wether compression should be used (NYI)
1829     connect = ondemand # connect to this host always/never or ondemand
1830     router-priority = 1 # route for everybody - if necessary
1831    
1832     loglevel = notice # info logs connects, notice only important messages
1833     on mobil loglevel = info
1834     on doom loglevel = info
1835     on ruth loglevel = info
1836    
1837     udp-port = 407 # the udp port to use for sending/receiving packets
1838     tcp-port = 443 # the tcp port to listen for connections (we use https over proxy)
1839     ip-proto = 50 # (ab)use the ipsec protocol as rawip
1840     icmp-type = 0 # (ab)use echo replies for tunneling
1841     enable-udp = yes # udp is spoken almost everywhere
1842     enable-tcp = no # tcp is not spoken everywhere
1843     enable-rawip = no # rawip is not spoken everywhere
1844     enable-icmp = no # most hosts don't bother to icmp
1845    
1846     # every "node =" introduces a new node in the network
1847     # the options following it don't set defaults but are
1848     # node-specific.
1849    
1850     # marc@@lap
1851     node = mobil
1852    
1853     # marc@@home
1854     node = doom
1855     enable-rawip = yes
1856     enable-tcp = yes
1857    
1858     # marc@@uni
1859     node = ruth
1860     enable-rawip = yes
1861     enable-tcp = yes
1862     enable-icmp = yes
1863     hostname = 200.100.162.95
1864     connect = always
1865     router-priority = 30
1866     on ruth node-up = node-up
1867     on ruth node-down = node-up
1868    
1869     # marc@@mu
1870     node = frank
1871     enable-rawip = yes
1872     hostname = 44.88.167.250
1873     router-priority = 20
1874     connect = always
1875    
1876     # nethype
1877     node = rain
1878     enable-rawip = yes
1879     hostname = 145.253.105.130
1880     router-priority = 10
1881     connect = always
1882    
1883     # marco@@home
1884     node = marco
1885     enable-rawip = yes
1886    
1887     # stefan@@ka
1888     node = wappla
1889     connect = never
1890    
1891     # stefan@@lap
1892     node = stefan
1893     udp-port = 408
1894     connect = never
1895    
1896     # paul@@wg
1897     node = n8geil
1898     on ruth enable-icmp = yes
1899     on n8geil enable-icmp = yes
1900     enable-udp = no
1901    
1902     # paul@@lap
1903     node = syrr
1904    
1905     # paul@@lu
1906     node = donomos
1907    
1908     # marco@@hn
1909     node = core
1910    
1911     # elmex@@home
1912     node = elmex
1913     enable-rawip = yes
1914     hostname = 100.251.143.181
1915    
1916     # stefan@@kwc.at
1917     node = fwkw
1918     connect = never
1919     on stefan connect = always
1920     on wappla connect = always
1921     hostname = 182.73.81.146
1922    
1923     # elmex@@home
1924     node = jungfrau
1925     enable-rawip = yes
1926    
1927     # uni main router
1928     node = surfer
1929     enable-rawip = yes
1930     enable-tcp = no
1931     enable-icmp = yes
1932     hostname = 200.100.162.79
1933     connect = always
1934     router-priority = 40
1935    
1936     # jkneer@@marvin
1937     node = marvin
1938     enable-rawip = yes
1939     enable-udp = no
1940    
1941     # jkneer@@entrophy
1942     node = entrophy
1943     enable-udp = no
1944     enable-tcp = yes
1945    
1946     # mr. primitive
1947     node = voyager
1948     enable-udp = no
1949     enable-tcp = no
1950     on voyager enable-tcp = yes
1951     on voyager enable-udp = yes
1952    
1953     # v-server (barbados.dn-systems.de)
1954     #node = vserver
1955     #enable-udp = yes
1956     #hostname = 193.108.181.74
1957     @end example
1958    
1959    
1960    
1961     @node complex/if-up,complex/node-up,complex/gvpe.conf,Complex Example
1962    
1963     @chapter complex/if-up
1964    
1965    
1966     @example
1967     #!/bin/bash
1968    
1969     # Some environment variables will be set:
1970     #
1971     # CONFBASE=/etc/vpe # the configuration directory prefix
1972     # IFNAME=vpn0 # the network interface (ifname)
1973     # MAC=fe:fd:80:00:00:01 # the mac-address to use for the interface
1974     # NODENAME=cerebro # the selected nodename (-n switch)
1975     # NODEID=1 # the numerical node id
1976     # MTU=1436 # the tunnel packet overhead (set mtu to 1500-$OVERHEAD)
1977    
1978     # this if-up script is rather full-featured, and is used to
1979     # generate a fully-routed (no arp traffic) vpn. the main portion
1980     # consists of "ipn" calls (see below).
1981    
1982     # some hosts require additional specific configuration, this is handled
1983     # using if statements near the end of the script.
1984    
1985     # with the --fw switch, outputs mac/net pairs for your firewall use:
1986     # if-up --fw | while read mac net; do
1987     # iptables -t filter -A INPUT -i vpn0 -p all -m mac --mac-source \! $mac -s $net -j DROP
1988     # done
1989    
1990     ipn() @{
1991     local id="$1"; shift
1992     local mac=fe:fd:80:00:00:$(printf "%02x" $id)
1993     if [ -n "$FW" ]; then
1994     for net in "$@@"; do
1995     echo "$mac $net"
1996     done
1997     else
1998     local ip="$1"; shift
1999     if [ "$id" == $NODEID ]; then
2000     [ -n "$ADDR_ONLY" ] && ip addr add $ip broadcast 10.255.255.255 dev $IFNAME
2001     elif [ -z "$ADDR_ONLY" ]; then
2002     ip neighbour add $ip lladdr $mac nud permanent dev $IFNAME
2003     for route in "$@@"; do
2004     ip route add $route via $ip dev vpn0
2005     done
2006     fi
2007     fi
2008     @}
2009    
2010     ipns() @{
2011     # this contains the generic routing information for the vpn
2012     # each call to ipn has the following parameters:
2013     # ipn <node-id> <gateway-ip> [<route> ...]
2014     # the second line (ipn 2) means:
2015     # the second node (doom in the config file) has the ip address 10.0.0.5,
2016     # which is the gateway for the 10.0/28 network and three additional ip
2017     # addresses
2018    
2019     ipn 1 10.0.0.20
2020     ipn 2 10.0.0.5 10.0.0.0/28 #200.100.162.92 200.100.162.93 100.99.218.222
2021     ipn 3 10.0.0.17
2022     ipn 4 10.0.0.18
2023     ipn 5 10.0.0.19 10.3.0.0/16
2024     ipn 6 10.0.0.21 10.0.2.0/26 #200.100.162.17
2025     ipn 7 10.0.0.22 10.1.2.0/24 # wappla, off
2026     ipn 8 10.0.0.23 # stefan, off
2027     ipn 9 10.0.0.24 10.13.0.0/16
2028     ipn 10 10.0.0.25
2029     ipn 11 10.0.0.26
2030     ipn 12 10.0.0.27 10.0.2.64/26
2031     ipn 13 10.0.0.28 10.0.3.0/24
2032     ipn 14 10.0.0.29 10.1.1.0/24 # fwkw, off
2033     # mind the gateway ip gap
2034     ipn 15 10.9.0.30 10.0.4.0/24
2035     ipn 16 10.9.0.31
2036     ipn 17 10.9.0.32 10.42.0.0/16
2037     ipn 18 10.9.0.33
2038     ipn 19 10.9.0.34
2039     #ipn 20 10.9.0.35
2040     @}
2041    
2042     if [ "$1" == "--fw" ]; then
2043     FW=1
2044    
2045     ipns
2046     else
2047     exec >/var/log/vpe.if-up 2>&1
2048     set -x
2049    
2050     [ $NODENAME = "ruth" ] && ip link set $IFNAME down # hack
2051    
2052     # first set the link up and initialize the interface ip
2053     # address.
2054     ip link set $IFNAME address $MAC
2055     ip link set $IFNAME mtu $MTU up
2056     ADDR_ONLY=1 ipns # set addr only
2057    
2058     # now initialize the main vpn routes (10.0/8)
2059     # the second route is a hack to to reach some funnily-connected
2060     # machines.
2061     ip route add 10.0.0.0/8 dev $IFNAME
2062     ip route add 10.0.0.0/27 dev $IFNAME
2063    
2064     ipns # set the interface routes
2065    
2066     # now for something completely different, ehr, something not
2067     # easily doable with ipn, namely some extra specific highly complicated
2068     # and non-regular setups for some machines.
2069     if [ $NODENAME = doom ]; then
2070     ip addr add 200.100.162.92 dev $IFNAME
2071     ip route add 200.100.0.0/16 via 10.0.0.17 dev $IFNAME
2072     ip route flush table 101
2073     ip route add table 101 default src 200.100.162.92 via 10.0.0.17 dev $IFNAME
2074    
2075     ip addr add 100.99.218.222 dev $IFNAME
2076     ip route add 100.99.218.192/27 via 10.0.0.19 dev $IFNAME
2077     ip route flush table 103
2078     ip route add table 103 default src 100.99.218.222 via 10.0.0.19
2079    
2080     elif [ $NODENAME = marco ]; then
2081     ip addr add 200.100.162.17 dev $IFNAME
2082    
2083     for addr in 79 89 90 91 92 93 94 95; do
2084     ip route add 200.100.162.$addr dev ppp0
2085     done
2086     ip route add 200.100.76.0/23 dev ppp0
2087     ip route add src 200.100.162.17 200.100.0.0/16 via 10.0.0.17 dev $IFNAME
2088    
2089     elif [ $NODENAME = ruth ]; then
2090     ip route add 200.100.162.17 via 10.0.0.21 dev vpn0
2091     ip route add 200.100.162.92 via 10.0.0.5 dev vpn0
2092     ip route add 200.100.162.93 via 10.0.0.5 dev vpn0
2093    
2094     fi
2095    
2096     # and this is the second part of the 10.0/27 hack. don't ask.
2097     [ $NODENAME != fwkw ] && ip route add 10.0.0.0/24 via 10.0.0.29 dev $IFNAME
2098     fi
2099     @end example
2100    
2101    
2102    
2103     @node complex/node-up,Index,complex/if-up,Complex Example
2104    
2105     @chapter complex/node-up
2106    
2107    
2108     @example
2109     #!/bin/sh
2110    
2111     # Some environment variables will be set (in addition the ones
2112     # set in if-up, too):
2113     #
2114     # DESTNODE=doom # others nodename
2115     # DESTID=5 # others node id
2116     # DESTIP=188.13.66.8 # others ip
2117     # DESTPORT=407 # others port
2118     # STATE=up/down # node-up gets UP, node-down script gets DOWN
2119    
2120     if [ $STATE = up ]; then
2121     @{
2122     echo update delete $DESTNODE.lowttl.example.com. a
2123     echo update delete $DESTNODE-last.lowttl.example.com. a
2124     echo update add $DESTNODE.lowttl.example.com. 1 in a $DESTIP
2125     echo update add $DESTNODE-last.lowttl.example.com. 1 in a $DESTIP
2126     echo
2127     @} | nsupdate -d -k $CONFBASE:marc.example.net.
2128     else
2129     @{
2130     echo update delete $DESTNODE.lowttl.example.com. a
2131     echo update delete $DESTNODE-last.lowttl.example.com. a
2132     echo update add $DESTNODE-last.lowttl.example.com. 1 in a $DESTIP
2133     echo
2134     @} | nsupdate -d -k $CONFBASE:marc.example.net.
2135     fi
2136     @end example
2137    
2138    
2139    
2140     @node Index,,complex/node-up,Top
2141    
2142     @chapter Index
2143     @printindex cp
2144    
2145    
2146    
2147     @bye
2148