Initial revision
[tinc] / doc / tinc.texi
1 \input texinfo   @c -*-texinfo-*-
2 @c %**start of header
3 @setfilename tinc.info
4 @settitle tinc Manual
5 @setchapternewpage odd
6 @c %**end of header
7
8 @ifinfo
9
10 This is the info manual for tinc, a Virtual Private Network daemon.
11
12 Copyright 1998 Ivo Timmermans <itimmermans@@bigfoot.com>
13
14      Permission is granted to make and distribute verbatim
15      copies of this manual provided the copyright notice and
16      this permission notice are preserved on all copies.
17
18      Permission is granted to copy and distribute modified
19      versions of this manual under the conditions for
20      verbatim copying, provided
21      that the entire resulting derived work is distributed
22      under the terms of a permission notice identical to this
23      one.
24
25 @end ifinfo
26
27 @titlepage
28 @title tinc Manual
29 @subtitle Setting up a Virtual Private Network with tinc
30 @author Ivo Timmermans <itimmermans@@bigfoot.com>
31
32 @page
33 @vskip 0pt plus 1filll
34 Copyright @copyright{} 1998 Ivo Timmermans <itimmermans@@bigfoot.com>
35
36      Permission is granted to make and distribute verbatim
37      copies of this manual provided the copyright notice and
38      this permission notice are preserved on all copies.
39
40      Permission is granted to copy and distribute modified
41      versions of this manual under the conditions for
42      verbatim copying, provided
43      that the entire resulting derived work is distributed
44      under the terms of a permission notice identical to this
45      one.
46
47 @end titlepage
48
49 @c ==================================================================
50 @node Top, Introduction, (dir), (dir)
51
52 @menu
53 * Introduction::                Introduction
54 * Configuring a Linux system::  Before compiling tinc
55 * Installing tinc::             
56 * Configuring tinc::            
57 * Running tinc::                
58 * Technical information::       
59 * About us::                    
60 * Concept Index::               All used terms explained
61 @end menu
62
63 @c ==================================================================
64 @node    Introduction, Configuring a Linux system, Top, Top
65 @chapter Introduction
66
67 @c straight from the www page
68
69 tinc is a Virtual Private Network (VPN) daemon that uses tunneling and
70 encryption to create a secure private network between hosts on the
71 Internet.
72
73 Because the tunnel appears to the IP level network code as a normal
74 network device, there is no need to adapt any existing software.
75
76 This tunneling allows VPN sites to share information with eachother
77 over the Internet without exposing any information to others.
78
79 This document is the manual for tinc. Included are chapters on how to
80 configure your computer to use tinc, as well as the configuration
81 process of tinc itself.
82
83 @menu
84 * VPNs::                        Virtual Private Networks in general
85 * tinc::                        about tinc
86 @end menu
87
88 @c ==================================================================
89 @node    VPNs, tinc, Introduction, Introduction
90 @section Virtual Private Networks
91
92 A Virtual Private Network or VPN is a network that can only be accessed
93 by a few elected computers that participate. This goal is achievable in
94 more than just one way.
95
96 @cindex private
97 For instance, a VPN can consist of a single standalone ethernet LAN. Or
98 even two computers hooked up using a nullmodem cable@footnote{Though
99 discussable, I think it qualifies as a VPN.}. In these cases, it is
100 obvious that the network is @emph{private}. But there is another type
101 of VPN, the type tinc was made for.
102
103 @cindex virtual
104 tinc uses normal IP datagrams to encapsulate data that goes over the VPN
105 network link. In this case it's also clear that the network is
106 @emph{virtual}, because no direct network link has to exist between to
107 participants.
108
109 As is the case with either type of VPN, anybody could eavesdrop. Or
110 worse, alter data. Hence it's probably advisable to encrypt the data
111 that flows over the network.
112
113 `
114 @c ==================================================================
115 @node    tinc,  , VPNs, Introduction
116 @section tinc
117
118 I really don't quite remember what got us started, but it must have been
119 Guus' idea. He wrote a simple implementation (about 50 lines of C) that
120 used the @emph{ethertap} device that linux knows of since somewhere
121 about kernel 2.1.60. It didn't work immediately and he improved it a
122 bit. At this stage, the project was still simply called @samp{vpnd}.
123
124 Since then, a lot has changed---to say the least.
125
126 @cindex tincd
127 tinc now supports encryption, it consists of a single daemon (tincd) for
128 both the receiving and sending end, it hase becom largely
129 runtime-configurable---in short, it has become a full-fledged
130 professional package.
131
132 A lot can---and will be---changed. I have a few things that I'd like to
133 see in the future releases of tinc. Not everything will be available in
134 the near future. Our first objective is to make tinc work perfectly as
135 it stands, and then add more advanced features.
136
137 Meanwhile, we're always open-minded towards new ideas. And we're
138 available too.
139
140
141 @c ==================================================================
142 @node    Configuring a Linux system, Installing tinc, Introduction, Top
143 @chapter Configuring a Linux system
144
145 This chapter contains information on how a Linux system is configured
146 for the use of tinc.
147
148 @menu
149 * Configuring the kernel::      
150 * Files Needed::                
151 * Setting up the devices::      
152 @end menu
153
154
155 @c ==================================================================
156 @node    Configuring the kernel, Files Needed, Configuring a Linux system, Configuring a Linux system
157 @section Configuring the kernel
158
159 Since this particular implementation only runs on 2.1 or higher Linux
160 kernels, you should grab one (2.2 is current at this time). A 2.0 port
161 is not really possible, unless someone tells me someone ported the
162 ethertap and netlink devices back to 2.0.
163
164 If you are unfamiliar with the process of configuring and compiling a
165 new kernel, you should read the
166 @uref{http://howto.linuxberg.com/LDP/HOWTO/Kernel-HOWTO.html, Kernel
167 HOWTO} first. Do that now!
168
169 Here are the options you have to turn on/off when configuring a new
170 kernel.
171
172 @example
173 Code maturity level options
174 [*] Prompt for development and/or incomplete code/drivers
175 Networking options
176 [*] Kernel/User netlink socket
177 <*> Netlink device emulation
178 Network device support
179 <*> Ethertap network tap
180 @end example
181
182 Any other options not mentioned here are not relevant to tinc. If you
183 decide to build any of these as dynamic kernel modules, it's a good idea
184 to add these lines to @file{/etc/modules.conf}.
185
186 @example
187 alias tap0 ethertap
188 alias char-major-36 netlink_dev
189 @end example
190
191 Finally, after having set up other options, build the kernel and boot
192 it. Unfortunately it's not possible to insert these modules in a running
193 kernel.
194
195
196 @c ==================================================================
197 @node    Files Needed, Setting up the devices, Configuring the kernel, Configuring a Linux system
198 @section Files Needed
199
200 @subsubheading Device files
201
202 First, you'll need the special device file(s) that form the interface
203 between the kernel and the daemon.
204
205 @example
206 mknod -m 600 /dev/tap0 c 36 16
207 chown 0.0 /dev/tap0
208 @end example
209
210 The permissions now will be such that only the super user may read/write
211 to this file. You'd want this, because otherwise eavesdropping would
212 become a tad too easy. This does, however, imply that you'd have to run
213 tincd as root.
214
215 If you want to, you may also create more device files, which would be
216 numbered 0...15, with minor device numbers 16...31. They all should be
217 owned by root and have permission 600.
218
219
220 @subsubheading @file{/etc/networks}
221
222 You may add a line to @file{/etc/networks} so that your vpn will get a
223 symoblic name. For example:
224
225 @example
226 myvpn 10.0.0.0
227 @end example
228
229
230 @subsubheading @file{/etc/services}
231
232 You may add this line to @file{/etc/services}. The effect is that you
233 may supply a @samp{vpn} as a valid port number to some programs. The
234 number 655 is registered with the IANA.
235
236 @example
237 tinc            655/tcp    TINC
238 tinc            655/udp    TINC
239 #                          Ivo Timmermans <itimmermans@@bigfoot.com>
240 @end example
241
242
243 @c ==================================================================
244 @node    Setting up the devices,  , Files Needed, Configuring a Linux system
245 @section Setting up the devices
246
247 Before you can start transmitting data over the tinc tunnel, you must
248 set up the ethertap network devices.
249
250 First, decide which IP addresses you want to have associated with these
251 devices, and what network mask they must have. You also need these
252 numbers when you are going to configure tinc itself. @xref{Configuring
253 tinc}.
254
255 It doesn't matter much which part you do first, setting up the network
256 devices or configure tinc. But they both have to be done before you try
257 to start a tincd.
258
259 The actual setup of the ethertap device is quite simple, just repeat
260 after me:
261
262 @example
263 ifconfig tap@emph{n} hw ether fe:fd:@emph{xx}:@emph{xx}:@emph{xx}:@emph{xx}
264 @end example
265
266 The @emph{n} here is the number of the ethertap device you want to
267 use. It should be the same @emph{n} as the one you use for
268 @file{/dev/tap@emph{n}}. The @emph{xx}s are four hexadecimal numbers
269 (0--ff). With previous versions of tincd, it didn't matter what they
270 were. But newer kernels require properly set up ehternet addresses.
271 In fact, the old behaviour was wrong. It is required that the @emph{xx}s
272 match MyOwnVPNIP.
273
274 @example
275 ifconfig tap@emph{n} @emph{IP} netmask @emph{mask}
276 @end example
277
278 This will activate the device with an IP address @emph{IP} with network
279 mask @emph{mask}.
280
281
282
283 @c ==================================================================
284 @node    Installing tinc, Configuring tinc, Configuring a Linux system, Top
285 @chapter Installing tinc
286
287 First download it. This is the
288 @uref{http://tinc.nl.linux.org/download.html, download
289 page}, which has the checksums of these files listed; you may wish to
290 check these with md5sum before continuing.
291
292 tinc comes in a handy autoconf/automake package, which you can just
293 treat the same as any other package. Which is just untar it, type
294 `configure' and then `make'.
295
296 More detailed instructions are in the file @file{INSTALL}, which is
297 included in the source distribution.
298
299
300 @c ==================================================================
301 @node    Configuring tinc, Running tinc, Installing tinc, Top
302 @chapter Configuring tinc
303
304 @menu
305 * Multiple networks::           
306 * How connections work::        
307 * Configuration file::          
308 * Example::                     
309 @end menu
310
311
312 @c ==================================================================
313 @node    Multiple networks, How connections work, Configuring tinc, Configuring tinc
314 @section Multiple networks
315
316 @c from the manpage
317
318 It is perfectly ok for you to run more than one tinc daemon.
319 However, in its default form, you will soon notice that you can't use
320 two different configuration files without the -c option.
321
322 We have thought of another way of dealing with this: network names. This
323 means that you call tincd with the -n argument, which will assign a name
324 to this daemon.
325
326 The effect of this is that the daemon will set its configuration
327 ``root'' to /etc/tinc/nn/, where nn is your argument to the -n
328 option. You'll notice that it appears in syslog as ``tincd.nn''.
329
330 However, it is not strictly necessary that you call tinc with the -n
331 option. In this case, the network name would just be empty, and it will
332 be used as such. tinc now looks for files in /etc/tinc/, instead of
333 /etc/tinc/nn/; the configuration file should be /etc/tinc/tincd.conf,
334 and the passphrases are now expected to be in /etc/tinc/passphrases/.
335
336 But it is highly recommended that you use this feature of tinc, because
337 it will be so much clearer whom your daemon talks to. Hence, we will
338 assume that you use it.
339
340
341 @c ==================================================================
342 @node    How connections work, Configuration file, Multiple networks, Configuring tinc
343 @section How connections work
344
345 Before going on, first a bit on how tinc sees connections.
346
347 When tinc starts up, it reads in the configuration file and parses the
348 commandline options. If it sees a `ConnectTo' value in the file, it will
349 try to connect to it, on the given port. If this fails, tinc exits.
350
351
352 @c ==================================================================
353 @node    Configuration file, Example, How connections work, Configuring tinc
354 @section Configuration file
355
356 The actual configuration of the daemon is done in the file
357 @file{/etc/tinc/nn/tincd.conf}.
358
359 This file consists of comments (lines started with a #) or assignments
360 in the form of
361
362 @example
363 Variable = Value.
364 @end example
365
366 The variable names are case insensitive, and any spaces, tabs, newlines
367 and carriage returns are ignored. Note: it is not required that you put
368 in the `=' sign, but doing so improves readability.  If you leave it
369 out, remember to replace it with at least one space character.
370
371 @menu
372 * Variables::                   
373 @end menu
374
375 @c ==================================================================
376 @node    Variables,  , Configuration file, Configuration file
377 @subsection Variables
378
379 Here are all valid variables, listed in alphabetical order:
380
381 @c straight from the manpage
382 @table @asis
383 @item AllowConnect = (yes|no)
384 If set to yes, anyone may try to connect to you. If you set this to no,
385 no incoming connections will be accepted. This does not affect the
386 outgoing connections.
387
388 @item ConnectPort = port
389 Connect to the upstream host (given with the ConnectTo directive) on
390 port port. port may be given in decimal (default), octal (when preceded
391 by a single zero) or hexadecimal (prefixed with 0x).  port is the port
392 number for both the UDP and the TCP (meta) connections.
393
394 @item ConnectTo = (IP address|hostname)
395 Specifies which host to connect to on startup. If the ConnectPort
396 variable is omitted, then tinc will try to connect to port 655.
397
398 If you don't specify a host with ConnectTo, regardless of whether a
399 value for ConnectPort is given, tinc won't connect at all, and will
400 instead just listen for incoming connections. Only the initiator of a
401 tinc VPN should need this.
402
403 @item ListenPort = port
404 Listen on local port port. The computer connecting to this daemon should
405 use this number as the argument for his ConnectPort. Again, the
406 default is 655.
407
408 @item MyOwnVPNIP = local address[/maskbits]
409 The local address is the number that the daemon will propagate to
410 other daemons on the network when it is identifying itself. Hence this
411 will be the file name of the passphrase file that the other end expects
412 to find the passphrase in.
413
414 The local address is the IP address of the tap device, not the real IP
415 address of the host running tincd. Due to changes in recent kernels, it
416 is also necessary that you make the ethernet (also known as MAC) address
417 equal to the IP address (see the example).
418
419 maskbits is the number of bits set to 1 in the netmask part.
420
421 @item MyVirtualIP = local address[/maskbits]
422 This is an alias for MyOwnVPNIP.
423
424 @item Passphrases = directory
425 The directory where tinc will look for passphrases when someone tries to
426 cennect. Please see the manpage for genauth(8) for more information
427 about passphrases as used by tinc.
428
429 @item PingTimeout = number
430 The number of seconds of inactivity that tinc will wait before sending a
431 probe to the other end. If that other end doesn't answer within that
432 same amount of seconds, the connection is terminated, and the others
433 will be notified of this.
434
435 @item TapDevice = device
436 The ethertap device to use. Note that you can only use one device per
437 daemon. The info pages of the tinc package contain more information
438 about configuring an ethertap device for linux.
439
440 @end table
441
442
443 @c ==================================================================
444 @node    Example,  , Configuration file, Configuring tinc
445 @section Example
446
447 Imagine the following situation. An A-based company wants to connect
448 three branch offices in B, C and D using the internet. All four offices
449 have a 24/7 connection to the internet.
450
451 A is going to serve as the center of the network. B and C will connect
452 to A, and D will connect to C. Each office will be assigned their own IP
453 network, 10.x.0.0.
454
455 @example
456 A: net 10.1.0.0 mask 255.255.0.0 gateway 10.1.54.1 internet IP 1.2.3.4
457 B: net 10.2.0.0 mask 255.255.0.0 gateway 10.2.1.12 internet IP 2.3.4.5
458 C: net 10.3.0.0 mask 255.255.0.0 gateway 10.3.69.254 internet IP 3.4.5.6
459 D: net 10.4.0.0 mask 255.255.0.0 gateway 10.4.3.32 internet IP 4.5.6.7
460 @end example
461
462 ``gateway'' is the VPN IP address of the machine that is running the
463 tincd. ``internet IP'' is the IP address of the firewall, which does not
464 need to run tincd, but it must do a port forwarding of TCP&UDP on port
465 655 (unless otherwise configured).e
466
467 In this example, it is assumed that eth0 is the interface that points to
468 the inner LAN of the office. This could be the same as the interface
469 that leads to the internet.
470
471 @subsubheading For A
472
473 @emph{A} would be configured like this:
474
475 @example
476 ifconfig tap0 hw ether fe:fd:0a:01:36:01
477 ifconfig tap0 10.1.54.1 netmask 255.0.0.0
478 ifconfig eth0 10.1.54.1 netmask 255.255.0.0 broadcast 10.1.255.255
479 @end example
480
481 and in /etc/tinc/tincd.conf:
482
483 @example
484 TapDevice = /dev/tap0
485 MyVirtualIP = 10.1.54.1/16
486 @end example
487
488 @subsubheading For B
489
490 @example
491 ifconfig tap0 hw ether fe:fd:0a:02:01:0c
492 ifconfig tap0 10.2.1.12 netmask 255.0.0.0
493 ifconfig eth0 10.2.43.8 netmask 255.255.0.0 broadcast 10.2.255.255
494 @end example
495
496 and in /etc/tinc/tincd.conf:
497
498 @example
499 TapDevice = /dev/tap0
500 MyVirtualIP = 10.2.1.12/16
501 ConnectTo = 1.2.3.4
502 AllowConnect = no
503 @end example
504
505 Note here that the internal address (on eth0) doesn't have to be the
506 same as on the tap0 device. Also, ConnectTo is given so that no-one can
507 connect to this node.
508
509 @subsubheading For C
510
511 @example
512 ifconfig tap0 hw ether fe:fd:0a:03:45:fe
513 ifconfig tap0 10.3.69.254 netmask 255.0.0.0
514 ifconfig eth0 10.3.69.254 netmask 255.255.0.0 broadcast 10.3.255.255
515 @end example
516
517 and in /etc/tinc/A/tincd.conf:
518
519 @example
520 MyVirtualIP = 10.3.69.254/16
521 ConnectTo = 1.2.3.4
522 ListenPort = 2000
523 @end example
524
525 C already has another daemon that runs on port 655, so they have to
526 reserve another port for tinc. They also use the netname to distinguish
527 between the two. tinc is started with `tincd -n A'.
528
529 @subsubheading For D
530
531 @example
532 ifconfig tap0 hw ether fe:fd:0a:04:03:20
533 ifconfig tap0 10.4.3.32 netmask 255.0.0.0
534 ifconfig tap0 10.4.3.32 netmask 255.255.0.0 broadcast 10.4.255.255
535 @end example
536
537 and in /etc/tinc/tincd.conf:
538
539 @example
540 MyVirtualIP = 10.4.3.32/16
541 ConnectTo = 3.4.5.6
542 ConnectPort = 2000
543 AllowConnect = no
544 @end example
545
546 D will be connecting to C, which has a tincd running for this network on
547 port 2000. Hence they need to put in a ConnectPort.
548
549 @subsubheading Authentication
550
551 A, B, C and D all generate a passphrase with genauth 2048, the output is
552 stored in /etc/tinc/passphrases/local, except for C, where it should be
553 /etc/tinc/A/passphrases/local.
554
555 A stores a copy of B's passphrase in /etc/tinc/passphrases/10.2.0.0
556
557 A stores a copy of C's passphrase in /etc/tinc/passphrases/10.3.0.0
558
559 B stores a copy of A's passphrase in /etc/tinc/passphrases/10.1.0.0
560
561 C stores a copy of A's passphrase in /etc/tinc/A/passphrases/10.1.0.0
562
563 C stores a copy of D's passphrase in /etc/tinc/A/passphrases/10.4.0.0
564
565 D stores a copy of C's passphrase in /etc/tinc/passphrases/10.3.0.0
566
567 @subsubheading Starting
568
569 A has to start their tincd first. Then come B and C, where C has to
570 provide the option `-n A', because they have more than one tinc
571 network. Finally, D's tincd is started.
572
573
574
575 @c ==================================================================
576 @node    Running tinc, Technical information, Configuring tinc, Top
577 @chapter Running tinc
578
579 Running tinc isn't just as easy as typing `tincd' and hoping everything
580 will just work out the way you wanted. Instead, the use of tinc is a
581 project that involves trust relations and more than one computer.
582
583 @menu
584 * Managing keys::               
585 * Runtime options::             
586 @end menu
587
588
589 @c ==================================================================
590 @node    Managing keys, Runtime options, Running tinc, Running tinc
591 @section Managing keys
592
593 Before attempting to start tinc, you have to create passphrases. When
594 tinc tries to make a connection, it exchanges some sensitive
595 data. Before doing so, it likes to know if the other end is
596 trustworthy.
597
598 To do this, both ends must have some knowledge about the other. In the
599 case of tinc this is the authentication passphrase.
600
601 This passphrase is a number, which is chosen at random. This number is
602 then sent to the other computers which want to talk to us directly. To
603 avoid breaking security, this should be done over a known secure channel
604 (such as ssh or similar).
605
606 All passphrases are stored in the passphrases directory, which is
607 normally /etc/tinc/nn/passphrases/, but it may be changed using the
608 `Passphrases' option in the config file.
609
610 To generate a passphrase, run `genauth'. genauth takes one argument,
611 which is the length of the passphrase in bits. The length of the
612 passphrase should be in the range 1024--2048 for a key length of 128
613 bits. genauth creates a random number of the specified length, and puts
614 it to stdout.
615
616 Every computer that wants to participate in the VPN should do this, and
617 store the output in the passphrases directory, in the file @file{local}.
618
619 When every computer has his own local key, it should copy it to the
620 computer that it wants to talk to directly. (i.e. the one it connects to
621 during startup.) This should be done via a secure channel, because it is
622 sensitive information. If this is not done securely, someone might break
623 in on you later on.
624
625 Those non-local passphrase files must have the name of the VPN IP
626 address that they will advertise to you. For instance, if a computer
627 tells us it likes to be 10.1.1.3 with netmask 255.255.0.0, the file
628 should still be called 10.1.1.3, and not 10.1.0.0.
629
630
631 @c ==================================================================
632 @node    Runtime options,  , Managing keys, Running tinc
633 @section Runtime options
634
635 Besides the settings in the configuration file, tinc also accepts some
636 command line options.
637
638 This list is a longer version of that in the manpage. The latter is
639 generated automatically, so may be more up-to-date.
640
641 @c from the manpage
642 @table @asis
643 @item -c, --config=FILE
644 Read configuration options from FILE. The default is
645 @file{/etc/tinc/nn/tincd.conf}.
646
647 @item -d
648 Increase debug level. The higher it gets, the more gets
649 logged. Everything goes via syslog.
650
651 0 is the default, only some basic information connection attempts get
652 logged. Setting it to 1 will log a bit more, still not very
653 disturbing. With two -d's tincd will log protocol information, which can
654 get pretty noisy. Three or more -d's will output every single packet
655 that goes out or comes in, which probably generates more data than the
656 packets themselves.
657
658 @item -k, --kill
659 Attempt to kill a running tincd and exit. A TERM signal (15) gets sent
660 to the daemon that his its PID in /var/run/tincd.nn.pid.
661
662 Because it kills only one tincd, you should use -n here if you use it
663 normally.
664
665 @item -n, --net=NETNAME
666 Connect to net NETNAME. @xref{Multiple networks}.
667
668 @item -t, --timeout=TIMEOUT
669 Seconds to wait before giving a timeout. Should not be set too low,
670 because every time tincd senses a timeout, it disconnects and reconnects
671 again, which will cause unnecessary network traffic and log messages.
672
673 @item --help
674 Display a short reminder of these runtime options and terminate.
675
676 @item --version
677 Output version information and exit.
678
679 @end table
680
681
682 @c ==================================================================
683 @node    Technical information, About us, Running tinc, Top
684 @chapter Technical information
685
686
687 @c ==================================================================
688 @menu
689 * The Connection::              
690 * Security::                    
691 * The Protocol::                
692 @end menu
693
694 @node    The Connection, Security, Technical information, Technical information
695 @section The basic philosophy of the way tinc works
696 @cindex Connection
697
698 tinc is a daemon that takes VPN data and transmit that to another host
699 computer over the existing Internet infrastructure.
700
701 @menu
702 * Protocol Preview::            
703 * The Meta-connection::         
704 @end menu
705
706
707 @c ==================================================================
708 @node    Protocol Preview, The Meta-connection, The Connection, The Connection
709 @subsection A preview of the way the tinc works
710
711 @cindex ethertap
712 @cindex frame type
713 The data itself is read from a character device file, the so-called
714 @emph{ethertap} device. This device is associated with a network
715 interface. Any data sent to this interface can be read from the device,
716 and any data written to the device gets sent from the interface. Data to
717 and from the device is formatted as if it were a normal ethernet card,
718 so a frame is preceded by two MAC addresses and a @emph{frame type}
719 field.
720
721 So when tinc reads an ethernet frame from the device, it determines its
722 type. Right now, tinc can only handle Internet Protocol version 4 (IPv4)
723 frames. Plans to support other protocols are being made. When tinc knows
724 which type of frame it has read, it can also read the source and
725 destination address from it.
726
727 Now it is time that the frame gets encrypted. Currently the only
728 encryption algorithm available is blowfish.
729
730 @cindex encapsulating
731 When the encryption is ready, time has come to actually transport the
732 packet to the destination computer. We do this by sending the packet
733 over an UDP connection to the destination host. This is called
734 @emph{encapsulating}, the VPN packet (though now encrypted) is
735 encapsulated in another IP datagram.
736
737 When the destination receives this packet, the same thing happens, only
738 in reverse. So it does a decrypt on the contents of the UDP datagram,
739 and it writes the decrypted information to its own ethertap device.
740
741
742 @c ==================================================================
743 @node    The Meta-connection,  , Protocol Preview, The Connection
744 @subsection The meta-connection
745
746 Having only a UDP connection available is not enough. Though suitable
747 for transmitting data, we want to be able to reliably send other
748 information, such as routing and encryption information to somebody.
749
750 TCP is a better alternative, because it already contains protection
751 against information being lost, unlike UDP.
752
753 So we establish two connections. One for the encrypted VPN data, and one
754 for other information, the meta-data. Hence, we call the second
755 connection the meta-connection. We can now be sure that the
756 meta-information doesn't get lost on the way to another computer.
757
758 @cindex data-protocol
759 @cindex meta-protocol
760 Like with any communication, we must have a protocol, so that everybody
761 knows what everything stands for, an how he should react. Because we
762 have two connections, we also have two protocols. The protocol used for
763 the UDP data is the ``data-protocol,'' the other one is the
764 ``meta-protocol.''
765
766
767 @c ==================================================================
768 @node    Security, The Protocol, The Connection, Technical information
769 @section About tinc's encryption and other security-related issues.
770
771 @cindex tinc
772 @cindex Cabal
773 tinc got its name from ``TINC,'' short for @emph{There Is No Cabal}; the
774 alleged Cabal was/is an organization that was said to keep an eye on the
775 entire Internet. As this is exactly what you @emph{don't} want, we named
776 the tinc project after TINC.
777
778 @cindex SVPN
779 But in order to be ``immune'' to eavesdropping, you'll have to encrypt
780 your data. Because tinc is a @emph{Secure} VPN (SVPN) daemon, it does
781 exactly that: encrypt.
782
783 This chapter is a mixture of ideas, reasoning and explanation, please
784 don't take it too serious.
785
786 @menu
787 * Encryption::                  
788 * Key Management::              
789 * Authentification::            How to be sure we're talking to the right person
790 * Protection::                  
791 @end menu
792
793
794 @c ==================================================================
795 @node    Encryption, Key Management, Security, Security
796 @subsection Encryption
797
798 Encryption algorithms come in lots of flavors, most of which are not
799 safe enough to use on the Internet, if at all. Algorithms that we've
800 considered using are: RSA, blowfish, twofish and IDEA.
801
802 @itemize @bullet
803 @item
804 @cindex RSA
805 @emph{RSA} is patented. A fee must be paid if you use it, so it can't
806 be used in an Open Source program.
807
808 @item
809 @cindex blowfish
810 @emph{blowfish} was the standard encryption method at least up to version
811 0.2.23, but as Dekan pointed out, it may not be all that secure. It is
812 also patented, but it may be used freely.
813
814 @item
815 @cindex twofish
816 @emph{twofish} should be better, but i've not seen a useable
817 ready-to-use implementation somewhere out of the US. I'll remember this
818 as a future encryption method.
819
820 @item
821 @cindex IDEA
822 @emph{IDEA} is patented, and free for non-commercial use. It is going to
823 be the standard encryption method.
824
825 @end itemize
826
827 You may choose any of the last three encryption methods in tinc. Please
828 note, however, that ALL computers on your VPN must currenttly use the
829 same. This should (among other things) be more flexible, tinc could for
830 instance load a new encryption library the minute it is needed.
831
832
833 @c ==================================================================
834 @node    Key Management, Authentification, Encryption, Security
835 @subsection Key Management
836 @c FIXME: recheck
837
838 @cindex Diffie-Hellman
839 You can't just send a private encryption key to your peer, because
840 somebody else might already be listening to you. So you'll have to
841 negotiate over a shared but secret key. One way to do this is by using
842 the ``Diffie-Hellman key exchange'' protocol
843 (@uref{http://www.rsa.com/rsalabs/faq/html/3-6-1.html}). The idea is as
844 follows.
845
846 You have two participants A and B that want to agree over a shared
847 secret encryption key. Both parties have some large prime number p and a
848 generator g. These numbers may be known to the outside world, and hence
849 may be included in the source distribution.
850
851 @cindex secret key
852 Both parties then generate a secret key. A generates a, and computes g^a
853 mod p. This is then sent to B; while B computes g^b mod p, and transmits
854 this to A, b being generated by B. Both a and b must be smaller than
855 p-1.
856
857 These private keys are generated upon startup, and they are not changed
858 while the connection exists. A possible feature in the future is to
859 dynamically change the keys, every hour for example.
860
861 Both parties then calculate g^ab mod p = k. k is the new, shared, but
862 still secret key.
863
864 To obtain a key k of a sufficient length (128 bits in our vpnd), p
865 should be 2^129-1 or more.
866
867
868 @c ==================================================================
869 @node    Authentification, Protection, Key Management, Security
870 @subsection Authentification
871 @c FIXME: recheck
872
873 @cindex man-in-the-middle attack
874 Because the Diffie-Hellman protocol is in itself vulnerable to the
875 ``man-in-the-middle attack,'' we should introduce an authentification
876 system.
877
878 We will let A transmit a passphrase that is also known to B encrypted
879 with g^a, before A sends this to B. This way, B can check whether A is
880 really A or just someone else.
881
882 @cindex passphrase
883 This passphrase should be 2304 bits for a symmetric encryption
884 system. But since an asymmetric system is more secure, we could do with
885 2048 bits. This only holds if the passphrase is very random. 
886
887 These passphrases could be stored in a file that is non-readable by
888 anyone else but root; e.g. @file{/etc/vpn/passphrases}.
889
890 The only thing that needs to be taken care of is how A announces its
891 passphrase to B.
892
893
894 @c ==================================================================
895 @node    Protection,  , Authentification, Security
896 @subsection Protecting your data
897
898 Now we have securely hidden our data. But a malicious cracker may still
899 bother you by randomly altering the encrypted data he intercepts.
900
901
902 @c ==================================================================
903 @node    The Protocol,  , Security, Technical information
904 @section Detailed protocol specifications
905
906
907
908 @menu
909 * Data protocol::               
910 * Meta protocol::               
911 @end menu
912
913 @c ==================================================================
914 @node    Data protocol, Meta protocol, The Protocol, The Protocol
915 @subsection The data protocol
916
917 The data that is sent through the UDP connection is formatted as follows:
918
919 @example
920
921   bytes  |  Contents
922 ----------------------
923    0-1   |  The length of this packet, including all leading fields
924    2-5   |  The destination IP address
925   6-...  |  The encrypted data
926
927 @end example
928
929 The method that was used to encrypt the data should be made known via
930 the meta-protocol, during early identification stages.
931
932
933 @c ==================================================================
934 @node    Meta protocol,  , Data protocol, The Protocol
935 @subsection The Meta protocol
936
937 This protocol consists of separate packets of enformation, that are
938 generally formatted thusly:
939
940 @example
941
942   bytes  |  Contents
943 ----------------------
944     0    |  The request ID
945   1-...  |  (Optional: arguments)
946
947 @end example
948
949 What follows is a listing of possible request IDs.
950
951 @table @samp
952 @item ACK
953 Acknowledge. This generally means that the authentication has been
954 accepted by the remote computer. Takes no arguments.
955
956 @example
957
958   bytes  |  Contents
959 ----------------------
960     0    |  `1'
961
962 @end example
963
964 @item AUTH_S_INIT
965 @itemx AUTH_C_INIT
966 Obsolete. Use @samp{BASIC_INFO}.
967
968 @item AUTH_S_SPP
969 @itemx AUTH_C_SPP
970 Obsolete. Use @samp{PASSPHRASE}.
971
972 @item AUTH_S_SKEY
973 @itemx AUTH_C_SKEY
974 Obsolete. Use @samp{PUBLIC_KEY}, @samp{REQ_KEY} and @samp{ANS_KEY}.
975
976 @item AUTH_S_SACK
977 @itemx AUTH_C_RACK
978 Obsolete. Use @samp{ACK}.
979
980 @item TERMREQ
981 A request to terminate this connection, for whatever reason.
982
983 @example
984
985   bytes  |  Contents
986 ----------------------
987     0    |  `30'
988    1-4   |  The VPN IP address of the host that has exited
989
990 @end example
991
992
993 @item PINGTIMEOUT
994 Terminate connection, but the reason must be a ping timeout.
995
996 @example
997
998   bytes  |  Contents
999 ----------------------
1000     0    |  `31'
1001    1-4   |  The VPN IP address of the host that has exited
1002
1003 @end example
1004
1005
1006 @item PING
1007 Send probe to the other end, if he hasn't returned a @samp{PONG} within
1008 10 seconds, the connection is considered to be dead and will be
1009 terminated, we should try to notify the other by sending a
1010 @samp{PINGTIMEOUT} packet.
1011
1012 @example
1013
1014   bytes  |  Contents
1015 ----------------------
1016     0    |  `40'
1017
1018 @end example
1019
1020
1021 @item PONG
1022 See explanation for @samp{PING}
1023
1024 @example
1025
1026   bytes  |  Contents
1027 ----------------------
1028     0    |  `41'
1029
1030 @end example
1031
1032
1033 @item ADD_HOST
1034 Send an @samp{ADD_HOST} packet if you want to propagate all your current
1035 connections to a new computer on a network. If we get this request, we
1036 must forward it to everyone that hasn't got it yet.
1037
1038 @example
1039
1040   bytes  |  Contents
1041 ----------------------
1042     0    |  `60'
1043    1-4   |  The real IP address of the new host
1044    5-8   |  The VPN IP address of the new host
1045    9-12  |  The VPN netmask
1046   13-14  |  The port number that the new host listens on
1047
1048 @end example
1049
1050
1051 @item BASIC_INFO
1052 This packet will contain all necessary basic information about
1053 ourselves, such as the port we listen on and our desired VPN IP address.
1054
1055 @example
1056
1057   bytes  |  Contents
1058 ----------------------
1059     0    |  `61'
1060     1    |  The protocol version.
1061          |  This chapter describes version 4.
1062    2-3   |  The port number that the new host listens on
1063    4-7   |  The VPN IP address of the new host
1064    8-11  |  The VPN netmask
1065
1066 @end example
1067
1068
1069 @item PASSPHRASE
1070 Send an encrypted passphrase. Should be encrypted with our
1071 @strong{public} key, and it must reach us before a @samp{PUBLIC_KEY}
1072 request.
1073
1074 @example
1075
1076   bytes  |  Contents
1077 ----------------------
1078     0    |  `62'
1079    1-2   |  The length of the encrypted passphrase
1080   3-...  |  The encrypted passphrase
1081
1082 @end example
1083
1084
1085 @item PUBLIC_KEY
1086 This is only used during authentication of a new connection, later on we
1087 may use @samp{REQ_KEY} and @samp{ANS_KEY}.
1088
1089 @example
1090
1091   bytes  |  Contents
1092 ----------------------
1093     0    |  `63'
1094    1-2   |  The length of the key
1095   3-...  |  The public key, given in base-36
1096
1097 @end example
1098
1099
1100 @item HOLD
1101 @itemx RESUME
1102 Unused.
1103
1104 @item CALCULATE
1105 @itemx CALC_RES
1106 @itemx ALMOST_KEY
1107 Never been in use.
1108
1109 @item REQ_KEY
1110 Request a public key from someone and return it to the sender of this
1111 request using a @samp{ANS_KEY} packet. If we get such request, we must
1112 forward it to the connection that leads to the destination.
1113
1114 @example
1115
1116   bytes  |  Contents
1117 ----------------------
1118     0    |  `160'
1119    1-4   |  The source VPN IP address
1120    5-8   |  The destination VPN IP address
1121    9-14  |  `0'
1122
1123 @end example
1124
1125
1126 @item ANS_KEY
1127 Answer to a @samp{REQ_KEY} request, forward it to the destination if it
1128 is not meant for us.
1129
1130 @example
1131
1132   bytes  |  Contents
1133 ----------------------
1134     0    |  `161'
1135    1-4   |  The source VPN IP address
1136    5-8   |  The destination VPN IP address
1137    9-12  |  The expiration date/time in seconds
1138   13-14  |  The key length
1139   15-... |  The public key in base-36
1140
1141 @end example
1142
1143
1144 @item KEY_CHANGED
1145 The source computer wants to tell that it has regenerated its private
1146 and public keys, so anything going there must be encrypted with a new
1147 shared key.
1148
1149 @example
1150
1151   bytes  |  Contents
1152 ----------------------
1153     0    |  `162'
1154    1-4   |  The source VPN IP address
1155
1156 @end example
1157
1158
1159 @end table
1160
1161
1162 @c ==================================================================
1163 @node    About us, Concept Index, Technical information, Top
1164 @chapter About us
1165
1166
1167 @menu
1168 * Contact Information::         
1169 * Authors::                     
1170 @end menu
1171
1172
1173 @c ==================================================================
1174 @node    Contact Information, Authors, About us, About us
1175 @section Contact information
1176
1177 tinc's main page is at @url{http://tinc.nl.linux.org/},
1178 this server is located in the Netherlands.
1179
1180 We have an IRC channel on the Open Projects IRC network. Connect to
1181 @uref{http://openprojects.nu/services/irc.html, irc.openprojects.net},
1182 and join channel #tinc.
1183
1184
1185 @c ==================================================================
1186 @node    Authors,  , Contact Information, About us
1187 @section Authors
1188
1189 @table @asis
1190 @item Ivo Timmermans (zarq) (@email{itimmermans@@bigfoot.com})
1191 Main coder/hacker and maintainer of the package.
1192
1193 @item Guus Sliepen (guus)
1194 Originator of it all, co-author.
1195
1196 @item Wessel Dankers (Ubiq)
1197 General obfuscator of the code.
1198
1199 @end table
1200
1201 Thank you's to: Dekan, Emphyrio, vDong
1202
1203 Greetings to: braque, Fluor, giggles, macro, smoke, tribbel
1204
1205
1206 @c ==================================================================
1207 @node    Concept Index,  , About us, Top
1208 @c        node-name,    next, previous,        up
1209 @unnumbered Concept Index
1210
1211 @c ==================================================================
1212 @printindex cp
1213
1214
1215 @c ==================================================================
1216 @contents
1217 @bye
1218