69ac5a49a8dc6d28c57f902d5c9fce8d9261f1e9
[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 each other
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 stand-alone ethernet LAN. Or
98 even two computers hooked up using a null-modem cable@footnote{Though
99 discuss-able, 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 has become 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 bit 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 symbolic 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{tinc} 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 ethernet addresses.
271 In fact, the old behavior 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 command-line options. If it sees a `ConnectTo' value in the file, it
349 will 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 connect. 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).
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 * Key Management::              
788 * Authentication::              
789 * Protection::                  
790 @end menu
791
792
793 @c ==================================================================
794 @node    Key Management, Authentication, Security, Security
795 @subsection Key Management
796 @c FIXME: recheck
797
798 @cindex Diffie-Hellman
799 You can't just send a private encryption key to your peer, because
800 somebody else might already be listening to you. So you'll have to
801 negotiate over a shared but secret key. One way to do this is by using
802 the ``Diffie-Hellman key exchange'' protocol
803 (@uref{http://www.rsa.com/rsalabs/faq/html/3-6-1.html}). The idea is as
804 follows.
805
806 You have two participants A and B that want to agree over a shared
807 secret encryption key. Both parties have some large prime number p and a
808 generator g. These numbers may be known to the outside world, and hence
809 may be included in the source distribution.
810
811 @cindex secret key
812 Both parties then generate a secret key. A generates a, and computes g^a
813 mod p. This is then sent to B; while B computes g^b mod p, and transmits
814 this to A, b being generated by B. Both a and b must be smaller than
815 p-1.
816
817 These private keys are generated upon startup, and they are not changed
818 while the connection exists. A possible feature in the future is to
819 dynamically change the keys, every hour for example.
820
821 Both parties then calculate g^ab mod p = k. k is the new, shared, but
822 still secret key.
823
824 To obtain a key k of a sufficient length (128 bits in our vpnd), p
825 should be 2^129-1 or more.
826
827
828 @c ==================================================================
829 @node    Authentication, Protection, Key Management, Security
830 @subsection Authentication
831 @c FIXME: recheck
832
833 @cindex man-in-the-middle attack
834 Because the Diffie-Hellman protocol is in itself vulnerable to the
835 ``man-in-the-middle attack,'' we should introduce an authentication
836 system.
837
838 We will let A transmit a passphrase that is also known to B encrypted
839 with g^a, before A sends this to B. This way, B can check whether A is
840 really A or just someone else.
841
842 @cindex passphrase
843 This passphrase should be 2304 bits for a symmetric encryption
844 system. But since an asymmetric system is more secure, we could do with
845 2048 bits. This only holds if the passphrase is very random. 
846
847 These passphrases could be stored in a file that is non-readable by
848 anyone else but root; e.g. @file{/etc/vpn/passphrases}.
849
850 The only thing that needs to be taken care of is how A announces its
851 passphrase to B.
852
853
854 @c ==================================================================
855 @node    Protection,  , Authentication, Security
856 @subsection Protecting your data
857
858 Now we have securely hidden our data. But a malicious cracker may still
859 bother you by randomly altering the encrypted data he intercepts.
860
861
862 @c ==================================================================
863 @node    The Protocol,  , Security, Technical information
864 @section Detailed protocol specifications
865
866
867
868 @menu
869 * Data protocol::               
870 * Meta protocol::               
871 @end menu
872
873 @c ==================================================================
874 @node    Data protocol, Meta protocol, The Protocol, The Protocol
875 @subsection The data protocol
876
877 The data that is sent through the UDP connection is formatted as follows:
878
879 @example
880
881   bytes  |  Contents
882 ----------------------
883    0-1   |  The length of this packet, including all leading fields
884    2-5   |  The destination IP address
885   6-...  |  The encrypted data
886
887 @end example
888
889 The method that was used to encrypt the data should be made known via
890 the meta-protocol, during early identification stages.
891
892
893 @c ==================================================================
894 @node    Meta protocol,  , Data protocol, The Protocol
895 @subsection The Meta protocol
896
897 This protocol consists of separate packets of information, that are
898 generally formatted thusly:
899
900 @example
901
902   bytes  |  Contents
903 ----------------------
904     0    |  The request ID
905   1-...  |  (Optional: arguments)
906
907 @end example
908
909 What follows is a listing of possible request IDs.
910
911 @table @samp
912 @item ACK
913 Acknowledge. This generally means that the authentication has been
914 accepted by the remote computer. Takes no arguments.
915
916 @example
917
918   bytes  |  Contents
919 ----------------------
920     0    |  `1'
921
922 @end example
923
924 @item AUTH_S_INIT
925 @itemx AUTH_C_INIT
926 Obsolete. Use @samp{BASIC_INFO}.
927
928 @item AUTH_S_SPP
929 @itemx AUTH_C_SPP
930 Obsolete. Use @samp{PASSPHRASE}.
931
932 @item AUTH_S_SKEY
933 @itemx AUTH_C_SKEY
934 Obsolete. Use @samp{PUBLIC_KEY}, @samp{REQ_KEY} and @samp{ANS_KEY}.
935
936 @item AUTH_S_SACK
937 @itemx AUTH_C_RACK
938 Obsolete. Use @samp{ACK}.
939
940 @item TERMREQ
941 A request to terminate this connection, for whatever reason.
942
943 @example
944
945   bytes  |  Contents
946 ----------------------
947     0    |  `30'
948    1-4   |  The VPN IP address of the host that has exited
949
950 @end example
951
952
953 @item PINGTIMEOUT
954 Terminate connection, but the reason must be a ping timeout.
955
956 @example
957
958   bytes  |  Contents
959 ----------------------
960     0    |  `31'
961    1-4   |  The VPN IP address of the host that has exited
962
963 @end example
964
965
966 @item PING
967 Send probe to the other end, if he hasn't returned a @samp{PONG} within
968 10 seconds, the connection is considered to be dead and will be
969 terminated, we should try to notify the other by sending a
970 @samp{PINGTIMEOUT} packet.
971
972 @example
973
974   bytes  |  Contents
975 ----------------------
976     0    |  `40'
977
978 @end example
979
980
981 @item PONG
982 See explanation for @samp{PING}
983
984 @example
985
986   bytes  |  Contents
987 ----------------------
988     0    |  `41'
989
990 @end example
991
992
993 @item ADD_HOST
994 Send an @samp{ADD_HOST} packet if you want to propagate all your current
995 connections to a new computer on a network. If we get this request, we
996 must forward it to everyone that hasn't got it yet.
997
998 @example
999
1000   bytes  |  Contents
1001 ----------------------
1002     0    |  `60'
1003    1-4   |  The real IP address of the new host
1004    5-8   |  The VPN IP address of the new host
1005    9-12  |  The VPN netmask
1006   13-14  |  The port number that the new host listens on
1007
1008 @end example
1009
1010
1011 @item BASIC_INFO
1012 This packet will contain all necessary basic information about
1013 ourselves, such as the port we listen on and our desired VPN IP address.
1014
1015 @example
1016
1017   bytes  |  Contents
1018 ----------------------
1019     0    |  `61'
1020     1    |  The protocol version.
1021          |  This chapter describes version 4.
1022    2-3   |  The port number that the new host listens on
1023    4-7   |  The VPN IP address of the new host
1024    8-11  |  The VPN netmask
1025
1026 @end example
1027
1028
1029 @item PASSPHRASE
1030 Send an encrypted passphrase. Should be encrypted with our
1031 @strong{public} key, and it must reach us before a @samp{PUBLIC_KEY}
1032 request.
1033
1034 @example
1035
1036   bytes  |  Contents
1037 ----------------------
1038     0    |  `62'
1039    1-2   |  The length of the encrypted passphrase
1040   3-...  |  The encrypted passphrase
1041
1042 @end example
1043
1044
1045 @item PUBLIC_KEY
1046 This is only used during authentication of a new connection, later on we
1047 may use @samp{REQ_KEY} and @samp{ANS_KEY}.
1048
1049 @example
1050
1051   bytes  |  Contents
1052 ----------------------
1053     0    |  `63'
1054    1-2   |  The length of the key
1055   3-...  |  The public key, given in base-36
1056
1057 @end example
1058
1059
1060 @item HOLD
1061 @itemx RESUME
1062 Unused.
1063
1064 @item CALCULATE
1065 @itemx CALC_RES
1066 @itemx ALMOST_KEY
1067 Never been in use.
1068
1069 @item REQ_KEY
1070 Request a public key from someone and return it to the sender of this
1071 request using a @samp{ANS_KEY} packet. If we get such request, we must
1072 forward it to the connection that leads to the destination.
1073
1074 @example
1075
1076   bytes  |  Contents
1077 ----------------------
1078     0    |  `160'
1079    1-4   |  The source VPN IP address
1080    5-8   |  The destination VPN IP address
1081    9-14  |  `0'
1082
1083 @end example
1084
1085
1086 @item ANS_KEY
1087 Answer to a @samp{REQ_KEY} request, forward it to the destination if it
1088 is not meant for us.
1089
1090 @example
1091
1092   bytes  |  Contents
1093 ----------------------
1094     0    |  `161'
1095    1-4   |  The source VPN IP address
1096    5-8   |  The destination VPN IP address
1097    9-12  |  The expiration date/time in seconds
1098   13-14  |  The key length
1099   15-... |  The public key in base-36
1100
1101 @end example
1102
1103
1104 @item KEY_CHANGED
1105 The source computer wants to tell that it has regenerated its private
1106 and public keys, so anything going there must be encrypted with a new
1107 shared key.
1108
1109 @example
1110
1111   bytes  |  Contents
1112 ----------------------
1113     0    |  `162'
1114    1-4   |  The source VPN IP address
1115
1116 @end example
1117
1118
1119 @end table
1120
1121
1122 @c ==================================================================
1123 @node    About us, Concept Index, Technical information, Top
1124 @chapter About us
1125
1126
1127 @menu
1128 * Contact Information::         
1129 * Authors::                     
1130 @end menu
1131
1132
1133 @c ==================================================================
1134 @node    Contact Information, Authors, About us, About us
1135 @section Contact information
1136
1137 tinc's main page is at @url{http://tinc.nl.linux.org/},
1138 this server is located in the Netherlands.
1139
1140 We have an IRC channel on the Open Projects IRC network. Connect to
1141 @uref{http://openprojects.nu/services/irc.html, irc.openprojects.net},
1142 and join channel #tinc.
1143
1144
1145 @c ==================================================================
1146 @node    Authors,  , Contact Information, About us
1147 @section Authors
1148
1149 @table @asis
1150 @item Ivo Timmermans (zarq) (@email{itimmermans@@bigfoot.com})
1151 Main coder/hacker and maintainer of the package.
1152
1153 @item Guus Sliepen (guus)
1154 Originator of it all, co-author.
1155
1156 @item Wessel Dankers (Ubiq)
1157 General obfuscater of the code.
1158
1159 @end table
1160
1161 Thank you's to: Dekan, Emphyrio, vDong
1162
1163 Greetings to: braque, Fluor, giggles, macro, smoke, tribbel
1164
1165
1166 @c ==================================================================
1167 @node    Concept Index,  , About us, Top
1168 @c        node-name,    next, previous,        up
1169 @unnumbered Concept Index
1170
1171 @c ==================================================================
1172 @printindex cp
1173
1174
1175 @c ==================================================================
1176 @contents
1177 @bye
1178