dd1143557c4fd9a31b03520e7c755dbfe3d8b320
[tinc] / doc / tinc.texi
1 \input texinfo   @c -*-texinfo-*-
2 @c $Id: tinc.texi,v 1.8.4.44 2003/08/09 00:53:22 guus Exp $
3 @c %**start of header
4 @setfilename tinc.info
5 @settitle tinc Manual
6 @setchapternewpage odd
7 @c %**end of header
8
9 @include tincinclude.texi
10
11 @ifinfo
12 @dircategory Networking tools
13 @direntry
14 * tinc: (tinc).              The tinc Manual.
15 @end direntry
16
17 This is the info manual for @value{PACKAGE} version @value{VERSION}, a Virtual Private Network daemon.
18
19 Copyright @copyright{} 1998-2003 Ivo Timmermans
20 <ivo@@o2w.nl>, Guus Sliepen <guus@@sliepen.eu.org> and
21 Wessel Dankers <wsl@@nl.linux.org>.
22
23 $Id: tinc.texi,v 1.8.4.44 2003/08/09 00:53:22 guus Exp $
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 tinc Manual
38 @subtitle Setting up a Virtual Private Network with tinc
39 @author Ivo Timmermans and Guus Sliepen
40
41 @page
42 @vskip 0pt plus 1filll
43 @cindex copyright
44 This is the info manual for @value{PACKAGE} version @value{VERSION}, a Virtual Private Network daemon.
45
46 Copyright @copyright{} 1998-2003 Ivo Timmermans
47 <ivo@@o2w.nl>, Guus Sliepen <guus@@sliepen.eu.org> and
48 Wessel Dankers <wsl@@nl.linux.org>.
49
50 $Id: tinc.texi,v 1.8.4.44 2003/08/09 00:53:22 guus Exp $
51
52 Permission is granted to make and distribute verbatim copies of this
53 manual provided the copyright notice and this permission notice are
54 preserved on all copies.
55
56 Permission is granted to copy and distribute modified versions of this
57 manual under the conditions for verbatim copying, provided that the
58 entire resulting derived work is distributed under the terms of a
59 permission notice identical to this one.
60
61 @end titlepage
62
63 @c ==================================================================
64 @node Top, Introduction, (dir), (dir)
65
66 @menu
67 * Introduction::
68 * Preparations::
69 * Installation::
70 * Configuration::
71 * Running tinc::
72 * Technical information::
73 * About us::
74 * Concept Index::               All used terms explained
75 @end menu
76
77
78 @contents
79
80 @c ==================================================================
81 @node    Introduction, Preparations, Top, Top
82 @chapter Introduction
83
84 @cindex tinc
85 tinc is a Virtual Private Network (VPN) daemon that uses tunneling and
86 encryption to create a secure private network between hosts on the
87 Internet.
88
89 Because the tunnel appears to the IP level network code as a normal
90 network device, there is no need to adapt any existing software.
91 The encrypted tunnels allows VPN sites to share information with each other
92 over the Internet without exposing any information to others.
93
94 This document is the manual for tinc.  Included are chapters on how to
95 configure your computer to use tinc, as well as the configuration
96 process of tinc itself.
97
98 @menu
99 * Virtual Private Networks::
100 * tinc::                        About tinc
101 * Supported platforms::
102 @end menu
103
104 @c ==================================================================
105 @node    Virtual Private Networks, tinc, Introduction, Introduction
106 @section Virtual Private Networks
107
108 @cindex VPN
109 A Virtual Private Network or VPN is a network that can only be accessed
110 by a few elected computers that participate.  This goal is achievable in
111 more than just one way.
112
113 @cindex private
114 Private networks can consist of a single stand-alone Ethernet LAN.  Or
115 even two computers hooked up using a null-modem cable.  In these cases,
116 it is
117 obvious that the network is @emph{private}, no one can access it from the
118 outside.  But if your computers are linked to the Internet, the network
119 is not private anymore, unless one uses firewalls to block all private
120 traffic.  But then, there is no way to send private data to trusted
121 computers on the other end of the Internet.
122
123 @cindex virtual
124 This problem can be solved by using @emph{virtual} networks.  Virtual
125 networks can live on top of other networks, but they use encapsulation to
126 keep using their private address space so they do not interfere with
127 the Internet.  Mostly, virtual networks appear like a singe LAN, even though
128 they can span the entire world.  But virtual networks can't be secured
129 by using firewalls, because the traffic that flows through it has to go
130 through the Internet, where other people can look at it.
131
132 As is the case with either type of VPN, anybody could eavesdrop.  Or
133 worse, alter data.  Hence it's probably advisable to encrypt the data
134 that flows over the network.
135
136 When one introduces encryption, we can form a true VPN.  Other people may
137 see encrypted traffic, but if they don't know how to decipher it (they
138 need to know the key for that), they cannot read the information that flows
139 through the VPN.  This is what tinc was made for.
140
141
142 @c ==================================================================
143 @node    tinc, Supported platforms, Virtual Private Networks, Introduction
144 @section tinc
145
146 @cindex vpnd
147 I really don't quite remember what got us started, but it must have been
148 Guus' idea.  He wrote a simple implementation (about 50 lines of C) that
149 used the ethertap device that Linux knows of since somewhere
150 about kernel 2.1.60.  It didn't work immediately and he improved it a
151 bit.  At this stage, the project was still simply called @samp{vpnd}.
152
153 Since then, a lot has changed---to say the least.
154
155 @cindex tincd
156 tinc now supports encryption, it consists of a single daemon (tincd) for
157 both the receiving and sending end, it has become largely
158 runtime-configurable---in short, it has become a full-fledged
159 professional package.
160
161 @cindex Traditional VPNs
162 @cindex scalability
163 tinc also allows more than two sites to connect to eachother and form a single VPN.
164 Traditionally VPNs are created by making tunnels, which only have two endpoints.
165 Larger VPNs with more sites are created by adding more tunnels.
166 tinc takes another approach: only endpoints are specified,
167 the software itself will take care of creating the tunnels.
168 This allows for easier configuration and improved scalability.
169
170 A lot can---and will be---changed. We have a number of things that we would like to
171 see in the future releases of tinc.  Not everything will be available in
172 the near future.  Our first objective is to make tinc work perfectly as
173 it stands, and then add more advanced features.
174
175 Meanwhile, we're always open-minded towards new ideas.  And we're
176 available too.
177
178
179 @c ==================================================================
180 @node    Supported platforms,  , tinc, Introduction
181 @section Supported platforms
182
183 @cindex platforms
184 tinc has been verified to work under Linux, FreeBSD, OpenBSD, NetBSD, MacOS/X (Darwin), Solaris, and Windows (both natively and in a Cygwin environment),
185 with various hardware architectures.  These are some of the platforms
186 that are supported by the universal tun/tap device driver or other virtual network device drivers.
187 Without such a driver, tinc will most
188 likely compile and run, but it will not be able to send or receive data
189 packets.
190
191 @cindex release
192 For an up to date list of supported platforms, please check the list on
193 our website:
194 @uref{http://tinc.nl.linux.org/platforms}.
195
196
197 @c ==================================================================
198 @subsection Linux
199
200 @cindex Linux
201 tinc was first written for Linux running on an intel x86 processor, so
202 this is the best supported platform.  The protocol however, and actually
203 anything about tinc, has been rewritten to support random byte ordering
204 and arbitrary word length.  So in theory it should run on other
205 processors that Linux runs on.  It has already been verified to run on
206 alpha and sparc processors as well.
207
208 tinc uses the ethertap device or the universal tun/tap driver. The former is provided in the standard kernel
209 from version 2.1.60 up to 2.3.x, but has been replaced in favour of the tun/tap driver in kernel versions 2.4.0 and later.
210
211
212 @c ==================================================================
213 @subsection FreeBSD
214
215 @cindex FreeBSD
216 tinc on FreeBSD relies on the universal tun/tap driver for its data
217 acquisition from the kernel.  Therefore, tinc will work on the same platforms
218 as this driver.  These are: FreeBSD 3.x, 4.x, 5.x.
219
220
221 @c ==================================================================
222 @subsection OpenBSD
223
224 @cindex OpenBSD
225 tinc on OpenBSD relies on the tun driver for its data
226 acquisition from the kernel. It has been verified to work under at least OpenBSD 2.9.
227
228 Tunneling IPv6 packets may not work on OpenBSD.
229
230
231 @c ==================================================================
232 @subsection Solaris
233
234 @c ==================================================================
235 @subsection NetBSD
236
237 @cindex NetBSD
238 tinc on NetBSD relies on the tun driver for its data
239 acquisition from the kernel. It has been verified to work under at least NetBSD 1.5.2.
240
241 Tunneling IPv6 does not work on OpenBSD.
242
243
244 @c ==================================================================
245 @subsection Solaris
246
247 @cindex Solaris
248 tinc on Solaris relies on the universal tun/tap driver for its data
249 acquisition from the kernel.  Therefore, tinc will work on the same platforms
250 as this driver.  These are: Solaris 8 (SunOS 5.8).
251
252 IPv6 packets cannot be tunneled on Solaris.
253
254 @c ==================================================================
255 @subsection Darwin (MacOS/X)
256
257 @cindex Darwin
258 @cindex MacOS/X
259 tinc on Darwin relies on the tunnel driver for its data
260 acquisition from the kernel. This driver is not part of Darwin but can be
261 downloaded from @uref{http://chrisp.de/en/projects/tunnel.html}.
262
263 IPv6 packets cannot be tunneled on Darwin.
264
265 @c ==================================================================
266 @subsection Windows
267
268 @cindex Windows
269 tinc on Windows, in a Cygwin environment, relies on the CIPE driver or the TAP-Win32 driver for its data
270 acquisition from the kernel. This driver is not part of Windows but can be
271 downloaded from @uref{http://cipe-win32.sourceforge.net/}.
272
273
274 @c
275 @c
276 @c
277 @c
278 @c
279 @c
280 @c       Preparing your system
281 @c
282 @c
283 @c
284 @c
285 @c
286
287 @c ==================================================================
288 @node    Preparations, Installation, Introduction, Top
289 @chapter Preparations
290
291 This chapter contains information on how to prepare your system to
292 support tinc.
293
294 @menu
295 * Configuring the kernel::
296 * Libraries::
297 @end menu
298
299
300 @c ==================================================================
301 @node    Configuring the kernel, Libraries, Preparations, Preparations
302 @section Configuring the kernel
303
304 @cindex RedHat
305 @cindex Debian
306 @cindex netlink_dev
307 @cindex tun
308 @cindex ethertap
309 If you are running Linux, chances are good that your kernel already supports
310 all the devices that tinc needs for proper operation.  For example, the
311 standard kernel from Redhat Linux already has support for ethertap and netlink
312 compiled in.  Debian users can use the modconf utility to select the modules.
313 If your Linux distribution supports this method of selecting devices, look out
314 for something called `ethertap', and `netlink_dev' if it is using a kernel
315 version prior to 2.4.0. In that case you will need both these devices.  If you
316 are using kernel 2.4.0 or later, you need to select `tun'.
317
318 @cindex Kernel-HOWTO
319 If you can install these devices in a similar manner, you may skip this section.
320 Otherwise, you will have to recompile the kernel in order to turn on the required features.
321 If you are unfamiliar with the process of configuring and compiling a new kernel,
322 you should read the @uref{http://howto.linuxberg.com/LDP/HOWTO/Kernel-HOWTO.html, Kernel HOWTO} first.
323
324 @menu
325 * Configuration of Linux kernels 2.1.60 up to 2.4.0::
326 * Configuration of Linux kernels 2.4.0 and higher::
327 * Configuration of FreeBSD kernels::
328 * Configuration of OpenBSD kernels::
329 * Configuration of NetBSD kernels::
330 * Configuration of Solaris kernels::
331 * Configuration of Darwin (MacOS/X) kernels::
332 * Configuration of Windows::
333 @end menu
334
335
336 @c ==================================================================
337 @node       Configuration of Linux kernels 2.1.60 up to 2.4.0, Configuration of Linux kernels 2.4.0 and higher, Configuring the kernel, Configuring the kernel
338 @subsection Configuration of Linux kernels 2.1.60 up to 2.4.0
339
340 Here are the options you have to turn on when configuring a new kernel:
341
342 @example
343 Code maturity level options
344 [*] Prompt for development and/or incomplete code/drivers
345 Networking options
346 [*] Kernel/User netlink socket
347 <M> Netlink device emulation
348 Network device support
349 <M> Ethertap network tap
350 @end example
351
352 If you want to run more than one instance of tinc or other programs that use
353 the ethertap, you have to compile the ethertap driver as a module, otherwise
354 you can also choose to compile it directly into the kernel.
355
356 If you decide to build any of these as dynamic kernel modules, it's a good idea
357 to add these lines to @file{/etc/modules.conf}:
358
359 @example
360 alias char-major-36 netlink_dev
361 alias tap0 ethertap
362 options tap0 -o tap0 unit=0
363 alias tap1 ethertap
364 options tap1 -o tap1 unit=1
365 ...
366 alias tap@emph{N} ethertap
367 options tap@emph{N} -o tap@emph{N} unit=@emph{N}
368 @end example
369
370 Add as much alias/options lines as necessary.
371
372
373 @c ==================================================================
374 @node       Configuration of Linux kernels 2.4.0 and higher, Configuration of FreeBSD kernels, Configuration of Linux kernels 2.1.60 up to 2.4.0, Configuring the kernel
375 @subsection Configuration of Linux kernels 2.4.0 and higher
376
377 Here are the options you have to turn on when configuring a new kernel:
378
379 @example
380 Code maturity level options
381 [*] Prompt for development and/or incomplete code/drivers
382 Network device support
383 <M> Universal tun/tap device driver support
384 @end example
385
386 It's not necessary to compile this driver as a module, even if you are going to
387 run more than one instance of tinc.
388
389 If you have an early 2.4 kernel, you can choose both the tun/tap driver and the
390 `Ethertap network tap' device.  This latter is marked obsolete, and chances are
391 that it won't even function correctly anymore.  Make sure you select the
392 universal tun/tap driver.
393
394 If you decide to build the tun/tap driver as a kernel module, add these lines
395 to @file{/etc/modules.conf}:
396
397 @example
398 alias char-major-10-200 tun
399 @end example
400
401
402 @c ==================================================================
403 @node       Configuration of FreeBSD kernels, Configuration of OpenBSD kernels, Configuration of Linux kernels 2.4.0 and higher, Configuring the kernel
404 @subsection Configuration of FreeBSD kernels
405
406 For FreeBSD version 4.1 and higher, the tap driver is included in the default kernel configuration, for earlier
407 systems (4.0 and earlier), you need to install the universal tun/tap driver
408 yourself.
409
410
411 @c ==================================================================
412 @node       Configuration of OpenBSD kernels, Configuration of NetBSD kernels, Configuration of FreeBSD kernels, Configuring the kernel
413 @subsection Configuration of OpenBSD kernels
414
415 For OpenBSD version 2.9 and higher,
416 the tun driver is included in the default kernel configuration.
417
418
419 @c ==================================================================
420 @node       Configuration of NetBSD kernels, Configuration of Solaris kernels, Configuration of OpenBSD kernels, Configuring the kernel
421 @subsection Configuration of NetBSD kernels
422
423 For NetBSD version 1.5.2 and higher,
424 the tun driver is included in the default kernel configuration.
425
426
427 @c ==================================================================
428 @node       Configuration of Solaris kernels, Configuration of Darwin (MacOS/X) kernels, Configuration of NetBSD kernels, Configuring the kernel
429 @subsection Configuration of Solaris kernels
430
431 For Solaris 8 (SunOS 5.8) and higher,
432 the tun driver is included in the default kernel configuration.
433
434
435 @c ==================================================================
436 @node       Configuration of Darwin (MacOS/X) kernels, Configuration of Windows, Configuration of Solaris kernels, Configuring the kernel
437 @subsection Configuration of Darwin (MacOS/X) kernels
438
439 Darwin does not come with a tunnel driver. You must download it at
440 @uref{http://chrisp.de/en/projects/tunnel.html}. If compiling the source fails,
441 try the binary module. The tunnel driver must be loaded before starting tinc
442 with the following command:
443
444 @example
445 kmodload tunnel
446 @end example
447
448 Once loaded, the tunnel driver will automatically create @file{/dev/tun0}..@file{/dev/tun3}
449 and the corresponding network interfaces.
450
451
452 @c ==================================================================
453 @node       Configuration of Windows,  , Configuration of Darwin (MacOS/X) kernels, Configuring the kernel
454 @subsection Configuration of Windows
455
456 You will need to install the CIPE driver or the TAP-Win32 driver. You can download the CIPE driver from
457 @uref{http://cipe-win32.sourceforge.net}.  Using the Network Connections control panel,
458 configure the CIPE network device in the same way as you would do from the tinc-up script
459 as explained in the rest of the documentation.
460
461
462 @c ==================================================================
463 @node    Libraries,  , Configuring the kernel, Preparations
464 @section Libraries
465
466 @cindex requirements
467 @cindex libraries
468 Before you can configure or build tinc, you need to have the OpenSSL,
469 zlib and lzo libraries installed on your system.  If you try to configure tinc without
470 having them installed, configure will give you an error message, and stop.
471
472 @menu
473 * OpenSSL::
474 * zlib::
475 * lzo::
476 @end menu
477
478
479 @c ==================================================================
480 @node       OpenSSL, zlib, Libraries, Libraries
481 @subsection OpenSSL
482
483 @cindex OpenSSL
484 For all cryptography-related functions, tinc uses the functions provided
485 by the OpenSSL library.
486
487 If this library is not installed, you wil get an error when configuring
488 tinc for build.  Support for running tinc without having OpenSSL
489 installed @emph{may} be added in the future.
490
491 You can use your operating system's package manager to install this if
492 available.  Make sure you install the development AND runtime versions
493 of this package.
494
495 If you have to install OpenSSL manually, you can get the source code
496 from @url{http://www.openssl.org/}.  Instructions on how to configure,
497 build and install this package are included within the package.  Please
498 make sure you build development and runtime libraries (which is the
499 default).
500
501 If you installed the OpenSSL libraries from source, it may be necessary
502 to let configure know where they are, by passing configure one of the
503 --with-openssl-* parameters.
504
505 @example
506 --with-openssl=DIR      OpenSSL library and headers prefix
507 --with-openssl-include=DIR OpenSSL headers directory
508                         (Default is OPENSSL_DIR/include)
509 --with-openssl-lib=DIR  OpenSSL library directory
510                         (Default is OPENSSL_DIR/lib)
511 @end example
512
513
514 @subsubheading License
515
516 @cindex license
517 Since the license under which OpenSSL is distributed is not directly
518 compatible with the terms of the GNU GPL
519 @uref{http://www.openssl.org/support/faq.html#LEGAL2}, therefore we
520 include an addition to the GPL (see also the file COPYING.README):
521
522 @quotation
523 This program is released under the GPL with the additional exemption
524 that compiling, linking, and/or using OpenSSL is allowed.  You may
525 provide binary packages linked to the OpenSSL libraries, provided that
526 all other requirements of the GPL are met.
527 @end quotation
528
529
530 @c ==================================================================
531 @node       zlib, lzo, OpenSSL, Libraries
532 @subsection zlib
533
534 @cindex zlib
535 For the optional compression of UDP packets, tinc uses the functions provided
536 by the zlib library.
537
538 If this library is not installed, you wil get an error when configuring
539 tinc for build.  Support for running tinc without having zlib
540 installed @emph{may} be added in the future.
541
542 You can use your operating system's package manager to install this if
543 available.  Make sure you install the development AND runtime versions
544 of this package.
545
546 If you have to install zlib manually, you can get the source code
547 from @url{http://www.gzip.org/zlib/}.  Instructions on how to configure,
548 build and install this package are included within the package.  Please
549 make sure you build development and runtime libraries (which is the
550 default).
551
552
553 @c ==================================================================
554 @node       lzo,  , zlib, Libraries
555 @subsection lzo
556
557 @cindex lzo
558 Another form of compression is offered using the lzo library.
559
560 If this library is not installed, you wil get an error when configuring
561 tinc for build.  Support for running tinc without having lzo
562 installed @emph{may} be added in the future.
563
564 You can use your operating system's package manager to install this if
565 available.  Make sure you install the development AND runtime versions
566 of this package.
567
568 If you have to install lzo manually, you can get the source code
569 from @url{http://www.oberhumer.com/opensource/lzo/}.  Instructions on how to configure,
570 build and install this package are included within the package.  Please
571 make sure you build development and runtime libraries (which is the
572 default).
573
574
575 @c
576 @c
577 @c
578 @c      Installing tinc
579 @c
580 @c
581 @c
582 @c
583
584 @c ==================================================================
585 @node    Installation, Configuration, Preparations, Top
586 @chapter Installation
587
588 If you use Debian, you may want to install one of the
589 precompiled packages for your system.  These packages are equipped with
590 system startup scripts and sample configurations.
591
592 If you cannot use one of the precompiled packages, or you want to compile tinc
593 for yourself, you can use the source.  The source is distributed under
594 the GNU General Public License (GPL).  Download the source from the
595 @uref{http://tinc.nl.linux.org/download, download page}, which has
596 the checksums of these files listed; you may wish to check these with
597 md5sum before continuing.
598
599 tinc comes in a convenient autoconf/automake package, which you can just
600 treat the same as any other package.  Which is just untar it, type
601 `./configure' and then `make'.
602 More detailed instructions are in the file @file{INSTALL}, which is
603 included in the source distribution.
604
605 @menu
606 * Building and installing tinc::
607 * System files::
608 @end menu
609
610
611 @c ==================================================================
612 @node    Building and installing tinc, System files, Installation, Installation
613 @section Building and installing tinc
614
615 Detailed instructions on configuring the source, building tinc and installing tinc
616 can be found in the file called @file{INSTALL}.
617
618 @cindex binary package
619 If you happen to have a binary package for tinc for your distribution,
620 you can use the package management tools of that distribution to install tinc.
621 The documentation that comes along with your distribution will tell you how to do that.
622
623 @menu
624 * Darwin (MacOS/X) build environment::
625 * Cygwin (Windows) build environment::
626 * MinGW (Windows) build environment::
627 @end menu
628
629
630 @c ==================================================================
631 @node       Darwin (MacOS/X) build environment, Cygwin (Windows) build environment, Building and installing tinc, Building and installing tinc
632 @subsection Darwin (MacOS/X) build environment
633
634 In order to build tinc on Darwin, you need to install the MacOS/X Developer Tools
635 from @uref{http://developer.apple.com/tools/macosxtools.html} and
636 a recent version of Fink from @uref{http://fink.sourceforge.net/}.
637
638 After installation use fink to download and install the following packages:
639 autoconf25, automake, dlcompat, m4, openssl, zlib and lzo.
640
641 @c ==================================================================
642 @node       Cygwin (Windows) build environment, MinGW (Windows) build environment, Darwin (MacOS/X) build environment, Building and installing tinc
643 @subsection Cygwin (Windows) build environment
644
645 If Cygwin hasn't already been installed, install it directly from
646 @uref{http://www.cygwin.com/}.
647
648 When tinc is compiled in a Cygwin environment, it can only be run in this environment,
649 but all programs, including those started outside the Cygwin environment, will be able to use the VPN.
650 It will also support all features.
651
652 @c ==================================================================
653 @node       MinGW (Windows) build environment,  , Cygwin (Windows) build environment, Building and installing tinc
654 @subsection MinGW (Windows) build environment
655
656 You will need to install the MinGW environment from @uref{http://www.mingw.org}.
657
658 When tinc is compiled using MinGW it runs natively under Windows,
659 it is not necessary to keep MinGW installed.
660
661 When detaching, tinc will install itself as a service,
662 which will be restarted automatically after reboots.
663
664
665 @c ==================================================================
666 @node    System files,  , Building and installing tinc, Installation
667 @section System files
668
669 Before you can run tinc, you must make sure you have all the needed
670 files on your system.
671
672 @menu
673 * Device files::
674 * Other files::
675 @end menu
676
677
678 @c ==================================================================
679 @node       Device files, Other files, System files, System files
680 @subsection Device files
681
682 @cindex device files
683 First, you'll need the special device file(s) that form the interface
684 between the kernel and the daemon.
685
686 The permissions for these files have to be such that only the super user
687 may read/write to this file.  You'd want this, because otherwise
688 eavesdropping would become a bit too easy.  This does, however, imply
689 that you'd have to run tincd as root.
690
691 If you use Linux and have a kernel version prior to 2.4.0, you have to make the
692 ethertap devices:
693
694 @example
695 mknod -m 600 /dev/tap0 c 36 16
696 mknod -m 600 /dev/tap1 c 36 17
697 ...
698 mknod -m 600 /dev/tap@emph{N} c 36 @emph{N+16}
699 @end example
700
701 There is a maximum of 16 ethertap devices.
702
703 If you use the universal tun/tap driver, you have to create the
704 following device file (unless it already exist):
705
706 @example
707 mknod -m 600 /dev/tun c 10 200
708 @end example
709
710 If you use Linux, and you run the new 2.4 kernel using the devfs filesystem,
711 then the tun/tap device will probably be automatically generated as
712 @file{/dev/net/tun}.
713
714 Unlike the ethertap device, you do not need multiple device files if
715 you are planning to run multiple tinc daemons.
716
717
718 @c ==================================================================
719 @node       Other files,  , Device files, System files
720 @subsection Other files
721
722 @subsubheading @file{/etc/networks}
723
724 You may add a line to @file{/etc/networks} so that your VPN will get a
725 symbolic name.  For example:
726
727 @example
728 myvpn 10.0.0.0
729 @end example
730
731 @subsubheading @file{/etc/services}
732
733 @cindex port numbers
734 You may add this line to @file{/etc/services}.  The effect is that you
735 may supply a @samp{tinc} as a valid port number to some programs.  The
736 number 655 is registered with the IANA.
737
738 @example
739 tinc            655/tcp    TINC
740 tinc            655/udp    TINC
741 #                          Ivo Timmermans <ivo@@o2w.nl>
742 @end example
743
744
745 @c
746 @c
747 @c
748 @c
749 @c         Configuring tinc
750 @c
751 @c
752 @c
753 @c
754
755
756 @c ==================================================================
757 @node    Configuration, Running tinc, Installation, Top
758 @chapter Configuration
759
760 @menu
761 * Configuration introduction::
762 * Multiple networks::
763 * How connections work::
764 * Configuration files::
765 * Generating keypairs::
766 * Network interfaces::
767 * Example configuration::
768 @end menu
769
770 @c ==================================================================
771 @node    Configuration introduction, Multiple networks, Configuration, Configuration
772 @section Configuration introduction
773
774 Before actually starting to configure tinc and editing files,
775 make sure you have read this entire section so you know what to expect.
776 Then, make it clear to yourself how you want to organize your VPN:
777 What are the nodes (computers running tinc)?
778 What IP addresses/subnets do they have?
779 What is the network mask of the entire VPN?
780 Do you need special firewall rules?
781 Do you have to set up masquerading or forwarding rules?
782 Do you want to run tinc in router mode or switch mode?
783 These questions can only be answered by yourself,
784 you will not find the answers in this documentation.
785 Make sure you have an adequate understanding of networks in general.
786 @cindex Network Administrators Guide
787 A good resource on networking is the
788 @uref{http://www.linuxdoc.org/LDP/nag2/, Linux Network Administrators Guide}.
789
790 If you have everything clearly pictured in your mind,
791 proceed in the following order:
792 First, generate the configuration files (@file{tinc.conf}, your host configuration file, @file{tinc-up} and perhaps @file{tinc-down}).
793 Then generate the keypairs.
794 Finally, distribute the host configuration files.
795 These steps are described in the subsections below.
796
797
798 @c ==================================================================
799 @node    Multiple networks, How connections work, Configuration introduction, Configuration
800 @section Multiple networks
801
802 @cindex multiple networks
803 @cindex netname
804 In order to allow you to run more than one tinc daemon on one computer,
805 for instance if your computer is part of more than one VPN,
806 you can assign a ``netname'' to your VPN.
807 It is not required if you only run one tinc daemon,
808 it doesn't even have to be the same on all the sites of your VPN,
809 but it is recommended that you choose one anyway.
810
811 We will asume you use a netname throughout this document.
812 This means that you call tincd with the -n argument,
813 which will assign a netname to this daemon.
814
815 The effect of this is that the daemon will set its configuration
816 ``root'' to @value{sysconfdir}/tinc/@var{netname}/, where @var{netname} is your argument to the -n
817 option.  You'll notice that it appears in syslog as ``tinc.@var{netname}''.
818
819 However, it is not strictly necessary that you call tinc with the -n
820 option.  In this case, the network name would just be empty, and it will
821 be used as such.  tinc now looks for files in @value{sysconfdir}/tinc/, instead of
822 @value{sysconfdir}/tinc/@var{netname}/; the configuration file should be @value{sysconfdir}/tinc/tinc.conf,
823 and the host configuration files are now expected to be in @value{sysconfdir}/tinc/hosts/.
824
825 But it is highly recommended that you use this feature of tinc, because
826 it will be so much clearer whom your daemon talks to.  Hence, we will
827 assume that you use it.
828
829
830 @c ==================================================================
831 @node    How connections work, Configuration files, Multiple networks, Configuration
832 @section How connections work
833
834 When tinc starts up, it parses the command-line options and then
835 reads in the configuration file tinc.conf.
836 If it sees one or more  `ConnectTo' values pointing to other tinc daemons in that file,
837 it will try to connect to those other daemons.
838 Whether this succeeds or not and whether `ConnectTo' is specified or not,
839 tinc will listen for incoming connection from other deamons.
840 If you did specify a `ConnectTo' value and the other side is not responding,
841 tinc will keep retrying.
842 This means that once started, tinc will stay running until you tell it to stop,
843 and failures to connect to other tinc daemons will not stop your tinc daemon
844 for trying again later.
845 This means you don't have to intervene if there are temporary network problems.
846
847 @cindex client
848 @cindex server
849 There is no real distinction between a server and a client in tinc.
850 If you wish, you can view a tinc daemon without a `ConnectTo' value as a server,
851 and one which does specify such a value as a client.
852 It does not matter if two tinc daemons have a `ConnectTo' value pointing to each other however.
853
854
855 @c ==================================================================
856 @node    Configuration files, Generating keypairs, How connections work, Configuration
857 @section Configuration files
858
859 The actual configuration of the daemon is done in the file
860 @file{@value{sysconfdir}/tinc/@var{netname}/tinc.conf} and at least one other file in the directory
861 @file{@value{sysconfdir}/tinc/@var{netname}/hosts/}.
862
863 These file consists of comments (lines started with a #) or assignments
864 in the form of
865
866 @example
867 Variable = Value.
868 @end example
869
870 The variable names are case insensitive, and any spaces, tabs, newlines
871 and carriage returns are ignored.  Note: it is not required that you put
872 in the `=' sign, but doing so improves readability.  If you leave it
873 out, remember to replace it with at least one space character.
874
875 In this section all valid variables are listed in alphabetical order.
876 The default value is given between parentheses,
877 other comments are between square brackets.
878
879 @menu
880 * Main configuration variables::
881 * Host configuration variables::
882 * Scripts::
883 * How to configure::
884 @end menu
885
886
887 @c ==================================================================
888 @node       Main configuration variables, Host configuration variables, Configuration files, Configuration files
889 @subsection Main configuration variables
890
891 @table @asis
892 @cindex AddressFamily
893 @item @var{AddressFamily} = <ipv4|ipv6|any> (any)
894 This option affects the address family of listening and outgoing sockets.
895 If "any" is selected, then depending on the operating system
896 both IPv4 and IPv6 or just IPv6 listening sockets will be created.
897
898 @cindex BindToAddress
899 @item @var{BindToAddress} = <address> [experimental]
900 If your computer has more than one IPv4 or IPv6 address, tinc
901 will by default listen on all of them for incoming connections.
902 It is possible to bind only to a single address with this variable.
903
904 This option may not work on all platforms.
905
906 @cindex BindToInterface
907 @item @var{BindToInterface} = <interface> [experimental]
908 If you have more than one network interface in your computer, tinc will
909 by default listen on all of them for incoming connections.  It is
910 possible to bind tinc to a single interface like eth0 or ppp0 with this
911 variable.
912
913 This option may not work on all platforms.
914
915 @cindex ConnectTo
916 @item @var{ConnectTo} = <name>
917 Specifies which other tinc daemon to connect to on startup.
918 Multiple ConnectTo variables may be specified,
919 in which case outgoing connections to each specified tinc daemon are made.
920 The names should be known to this tinc daemon
921 (i.e., there should be a host configuration file for the name on the ConnectTo line).
922
923 If you don't specify a host with ConnectTo,
924 tinc won't try to connect to other daemons at all,
925 and will instead just listen for incoming connections.
926
927 @cindex Device
928 @item @var{Device} = <device> (@file{/dev/tap0}, @file{/dev/net/tun} or other depending on platform)
929 The virtual network device to use.
930 tinc will automatically detect what kind of device it is.
931 Note that you can only use one device per daemon.
932 Under Windows, use @var{Interface} instead of @var{Device}.
933 Note that you can only use one device per daemon.
934 See also @ref{Device files}.
935
936 @cindex Hostnames
937 @item @var{Hostnames} = <yes|no> (no)
938 This option selects whether IP addresses (both real and on the VPN)
939 should be resolved.  Since DNS lookups are blocking, it might affect
940 tinc's efficiency, even stopping the daemon for a few seconds everytime
941 it does a lookup if your DNS server is not responding.
942
943 This does not affect resolving hostnames to IP addresses from the
944 configuration file.
945
946 @cindex Interface
947 @item @var{Interface} = <interface>
948 Defines the name of the interface corresponding to the virtual network device.
949 Depending on the operating system and the type of device this may or may not actually set the name of the interface.
950 Under Windows, this variable is used to select which network interface will be used.
951 If you specified a Device, this variable is almost always already correctly set.
952
953 @cindex Mode
954 @item @var{Mode} = <router|switch|hub> (router)
955 This option selects the way packets are routed to other daemons.
956
957 @table @asis
958 @cindex router
959 @item router
960 In this mode Subnet
961 variables in the host configuration files will be used to form a routing table.
962 Only unicast packets of routable protocols (IPv4 and IPv6) are supported in this mode.
963
964 This is the default mode, and unless you really know you need another mode, don't change it.
965
966 @cindex switch
967 @item switch
968 In this mode the MAC addresses of the packets on the VPN will be used to
969 dynamically create a routing table just like an Ethernet switch does.
970 Unicast, multicast and broadcast packets of every protocol that runs over Ethernet are supported in this mode
971 at the cost of frequent broadcast ARP requests and routing table updates.
972
973 This mode is primarily useful if you want to bridge Ethernet segments.
974
975 @cindex hub
976 @item hub
977 This mode is almost the same as the switch mode, but instead
978 every packet will be broadcast to the other daemons
979 while no routing table is managed.
980 @end table
981
982 @cindex KeyExpire
983 @item @var{KeyExpire} = <seconds> (3600)
984 This option controls the time the encryption keys used to encrypt the data
985 are valid.  It is common practice to change keys at regular intervals to
986 make it even harder for crackers, even though it is thought to be nearly
987 impossible to crack a single key.
988
989 @cindex MACExpire
990 @item @var{MACExpire} = <seconds> (600)
991 This option controls the amount of time MAC addresses are kept before they are removed.
992 This only has effect when Mode is set to "switch".
993
994 @cindex Name
995 @item @var{Name} = <name> [required]
996 This is a symbolic name for this connection.  It can be anything
997
998 @cindex PingTimeout
999 @item @var{PingTimeout} = <seconds> (60)
1000 The number of seconds of inactivity that tinc will wait before sending a
1001 probe to the other end.  If that other end doesn't answer within that
1002 same amount of seconds, the connection is terminated, and the others
1003 will be notified of this.
1004
1005 @cindex PriorityInheritance
1006 @item @var{PriorityInheritance} = <yes|no> (no) [experimental]
1007 When this option is enabled the value of the TOS field of tunneled IPv4 packets
1008 will be inherited by the UDP packets that are sent out.
1009
1010 @cindex PrivateKey
1011 @item @var{PrivateKey} = <key> [obsolete]
1012 This is the RSA private key for tinc. However, for safety reasons it is
1013 advised to store private keys of any kind in separate files. This prevents
1014 accidental eavesdropping if you are editting the configuration file.
1015
1016 @cindex PrivateKeyFile
1017 @item @var{PrivateKeyFile} = <path> (@file{@value{sysconfdir}/tinc/@var{netname}/rsa_key.priv})
1018 This is the full path name of the RSA private key file that was
1019 generated by ``tincd --generate-keys''.  It must be a full path, not a
1020 relative directory.
1021
1022 Note that there must be exactly one of @var{PrivateKey}
1023 or @var{PrivateKeyFile}
1024 specified in the configuration file.
1025
1026 @end table
1027
1028
1029 @c ==================================================================
1030 @node       Host configuration variables, Scripts, Main configuration variables, Configuration files
1031 @subsection Host configuration variables
1032
1033 @table @asis
1034 @cindex Address
1035 @item @var{Address} = <IP address|hostname> [recommended]
1036 This variable is only required if you want to connect to this host.  It
1037 must resolve to the external IP address where the host can be reached,
1038 not the one that is internal to the VPN.
1039
1040 @cindex Cipher
1041 @item @var{Cipher} = <cipher> (blowfish)
1042 The symmetric cipher algorithm used to encrypt UDP packets.
1043 Any cipher supported by OpenSSL is recognized.
1044
1045 @cindex Compression
1046 @item @var{Compression} = <level> (0)
1047 This option sets the level of compression used for UDP packets.
1048 Possible values are 0 (off), 1 (fast zlib) and any integer up to 9 (best zlib),
1049 10 (fast lzo) and 11 (best lzo).
1050
1051 @cindex Digest
1052 @item @var{Digest} = <digest> (sha1)
1053 The digest algorithm used to authenticate UDP packets.
1054 Any digest supported by OpenSSL is recognized.
1055 Furthermore, specifying "none" will turn off packet authentication.
1056
1057 @cindex IndirectData
1058 @item @var{IndirectData} = <yes|no> (no)
1059 This option specifies whether other tinc daemons besides the one you
1060 specified with ConnectTo can make a direct connection to you.  This is
1061 especially useful if you are behind a firewall and it is impossible to
1062 make a connection from the outside to your tinc daemon.  Otherwise, it
1063 is best to leave this option out or set it to no.
1064
1065 @cindex MACLength
1066 @item @var{MACLength} = <length> (4)
1067 The length of the message authentication code used to authenticate UDP packets.
1068 Can be anything from 0
1069 up to the length of the digest produced by the digest algorithm.
1070
1071 @cindex Port
1072 @item @var{Port} = <port> (655)
1073 This is the port this tinc daemon listens on.
1074 You can use decimal portnumbers or symbolic names (as listed in /etc/services).
1075
1076 @cindex PublicKey
1077 @item @var{PublicKey} = <key> [obsolete]
1078 This is the RSA public key for this host.
1079
1080 @cindex PublicKeyFile
1081 @item @var{PublicKeyFile} = <path> [obsolete]
1082 This is the full path name of the RSA public key file that was generated
1083 by ``tincd --generate-keys''.  It must be a full path, not a relative
1084 directory.
1085
1086 @cindex PEM format
1087 From version 1.0pre4 on tinc will store the public key directly into the
1088 host configuration file in PEM format, the above two options then are not
1089 necessary. Either the PEM format is used, or exactly
1090 @strong{one of the above two options} must be specified
1091 in each host configuration file, if you want to be able to establish a
1092 connection with that host.
1093
1094 @cindex Subnet
1095 @item @var{Subnet} = <address[/prefixlength]>
1096 The subnet which this tinc daemon will serve.
1097 tinc tries to look up which other daemon it should send a packet to by searching the appropiate subnet.
1098 If the packet matches a subnet,
1099 it will be sent to the daemon who has this subnet in his host configuration file.
1100 Multiple subnet lines can be specified for each daemon.
1101
1102 Subnets can either be single MAC, IPv4 or IPv6 addresses,
1103 in which case a subnet consisting of only that single address is assumed,
1104 or they can be a IPv4 or IPv6 network address with a prefixlength.
1105 Shorthand notations are not supported.
1106 For example, IPv4 subnets must be in a form like 192.168.1.0/24,
1107 where 192.168.1.0 is the network address and 24 is the number of bits set in the netmask.
1108 Note that subnets like 192.168.1.1/24 are invalid!
1109 Read a networking HOWTO/FAQ/guide if you don't understand this.
1110 IPv6 subnets are notated like fec0:0:0:1:0:0:0:0/64.
1111 MAC addresses are notated like 0:1a:2b:3c:4d:5e.
1112
1113 @cindex CIDR notation
1114 prefixlength is the number of bits set to 1 in the netmask part; for
1115 example: netmask 255.255.255.0 would become /24, 255.255.252.0 becomes
1116 /22. This conforms to standard CIDR notation as described in
1117 @uref{ftp://ftp.isi.edu/in-notes/rfc1519.txt, RFC1519}
1118
1119 @cindex TCPonly
1120 @item @var{TCPonly} = <yes|no> (no) [experimental]
1121 If this variable is set to yes, then the packets are tunnelled over a
1122 TCP connection instead of a UDP connection.  This is especially useful
1123 for those who want to run a tinc daemon from behind a masquerading
1124 firewall, or if UDP packet routing is disabled somehow.
1125 Setting this options also implicitly sets IndirectData.
1126 @end table
1127
1128
1129 @c ==================================================================
1130 @node       Scripts, How to configure, Host configuration variables, Configuration files
1131 @subsection Scripts
1132
1133 @cindex scripts
1134 Apart from reading the server and host configuration files,
1135 tinc can also run scripts at certain moments.
1136 On Windows (not Cygwin), the scripts should have the extension .bat.
1137
1138 @table @file
1139 @cindex tinc-up
1140 @item @value{sysconfdir}/tinc/@var{netname}/tinc-up
1141 This is the most important script.
1142 If it is present it will be executed right after the tinc daemon has been
1143 started and has connected to the virtual network device.
1144 It should be used to set up the corresponding network interface,
1145 but can also be used to start other things.
1146 Under Windows you can use the Network Connections control panel instead of creating this script.
1147
1148 @cindex tinc-down
1149 @item @value{sysconfdir}/tinc/@var{netname}/tinc-down
1150 This script is started right before the tinc daemon quits.
1151
1152 @item @value{sysconfdir}/tinc/@var{netname}/hosts/@var{host}-up
1153 This script is started when the tinc daemon with name @var{host} becomes reachable.
1154
1155 @item @value{sysconfdir}/tinc/@var{netname}/hosts/@var{host}-down
1156 This script is started when the tinc daemon with name @var{host} becomes unreachable.
1157 @end table
1158
1159 @cindex environment variables
1160 The scripts are started without command line arguments,
1161 but can make use of certain environment variables.
1162 Under UNIX like operating systems the names of environment variables must be preceded by a $ in scripts.
1163 Under Windows, in @file{.bat} files, they have to be put between % signs.
1164
1165 @table @env
1166 @cindex NETNAME
1167 @item NETNAME
1168 If a netname was specified, this environment variable contains it.
1169
1170 @cindex NAME
1171 @item NAME
1172 Contains the name of this tinc daemon.
1173
1174 @cindex DEVICE
1175 @item DEVICE
1176 Contains the name of the virtual network device that tinc uses.
1177
1178 @cindex INTERFACE
1179 @item INTERFACE
1180 Contains the name of the virtual network interface that tinc uses.
1181 This should be used for commands like ifconfig.
1182
1183 @cindex NODE
1184 @item NODE
1185 When a host becomes (un)reachable, this is set to its name.
1186
1187 @cindex REMOTEADDRESS
1188 @item REMOTEADDRESS
1189 When a host becomes (un)reachable, this is set to its real address.
1190
1191 @cindex REMOTEPORT
1192 @item REMOTEPORT
1193 When a host becomes (un)reachable,
1194 this is set to the port number it uses for communication with other tinc daemons.
1195 @end table
1196
1197
1198 @c ==================================================================
1199 @node       How to configure,  , Scripts, Configuration files
1200 @subsection How to configure
1201
1202 @subsubheading Step 1.  Creating the main configuration file
1203
1204 The main configuration file will be called @file{@value{sysconfdir}/tinc/@var{netname}/tinc.conf}.
1205 Adapt the following example to create a basic configuration file:
1206
1207 @example
1208 Name = @var{yourname}
1209 Device = @file{/dev/tap0}
1210 @end example
1211
1212 Then, if you know to which other tinc daemon(s) yours is going to connect,
1213 add `ConnectTo' values.
1214
1215 @subsubheading Step 2.  Creating your host configuration file
1216
1217 If you added a line containing `Name = yourname' in the main configuarion file,
1218 you will need to create a host configuration file @file{@value{sysconfdir}/tinc/@var{netname}/hosts/yourname}.
1219 Adapt the following example to create a host configuration file:
1220
1221 @example
1222 Address = your.real.hostname.org
1223 Subnet = 192.168.1.0/24
1224 @end example
1225
1226 You can also use an IP address instead of a hostname.
1227 The `Subnet' specifies the address range that is local for @emph{your part of the VPN only}.
1228 If you have multiple address ranges you can specify more than one `Subnet'.
1229 You might also need to add a `Port' if you want your tinc daemon to run on a different port number than the default (655).
1230
1231
1232 @c ==================================================================
1233 @node    Generating keypairs, Network interfaces, Configuration files, Configuration
1234 @section Generating keypairs
1235
1236 @cindex key generation
1237 Now that you have already created the main configuration file and your host configuration file,
1238 you can easily create a public/private keypair by entering the following command:
1239
1240 @example
1241 tincd -n @var{netname} -K
1242 @end example
1243
1244 tinc will generate a public and a private key and ask you where to put them.
1245 Just press enter to accept the defaults.
1246
1247
1248 @c ==================================================================
1249 @node    Network interfaces, Example configuration, Generating keypairs, Configuration
1250 @section Network interfaces
1251
1252 Before tinc can start transmitting data over the tunnel, it must
1253 set up the virtual network interface.
1254
1255 First, decide which IP addresses you want to have associated with these
1256 devices, and what network mask they must have.
1257
1258 tinc will open a virtual network device (@file{/dev/tun}, @file{/dev/tap0} or similar),
1259 which will also create a network interface called something like `tun0', `tap0', or,
1260 if you are using the Linux tun/tap driver, the network interface will by default have the same name as the netname.
1261
1262 @cindex tinc-up
1263 You can configure the network interface by putting ordinary ifconfig, route, and other commands
1264 to a script named @file{@value{sysconfdir}/tinc/@var{netname}/tinc-up}. When tinc starts, this script
1265 will be executed. When tinc exits, it will execute the script named
1266 @file{@value{sysconfdir}/tinc/@var{netname}/tinc-down}, but normally you don't need to create that script.
1267
1268 An example @file{tinc-up} script:
1269
1270 @example
1271 #!/bin/sh
1272 ifconfig $INTERFACE 192.168.1.1 netmask 255.255.0.0
1273 @end example
1274
1275 This script gives the interface an IP address and a netmask.
1276 The kernel will also automatically add a route to this interface, so normally you don't need
1277 to add route commands to the @file{tinc-up} script.
1278 The kernel will also bring the interface up after this command.
1279 @cindex netmask
1280 The netmask is the mask of the @emph{entire} VPN network, not just your
1281 own subnet.
1282
1283
1284 @c ==================================================================
1285 @node    Example configuration,  , Network interfaces, Configuration
1286 @section Example configuration
1287
1288
1289 @cindex example
1290 Imagine the following situation.  Branch A of our example `company' wants to connect
1291 three branch offices in B, C and D using the Internet.  All four offices
1292 have a 24/7 connection to the Internet.
1293
1294 A is going to serve as the center of the network.  B and C will connect
1295 to A, and D will connect to C.  Each office will be assigned their own IP
1296 network, 10.x.0.0.
1297
1298 @example
1299 A: net 10.1.0.0 mask 255.255.0.0 gateway 10.1.54.1 internet IP 1.2.3.4
1300 B: net 10.2.0.0 mask 255.255.0.0 gateway 10.2.1.12 internet IP 2.3.4.5
1301 C: net 10.3.0.0 mask 255.255.0.0 gateway 10.3.69.254 internet IP 3.4.5.6
1302 D: net 10.4.0.0 mask 255.255.0.0 gateway 10.4.3.32 internet IP 4.5.6.7
1303 @end example
1304
1305 ``gateway'' is the VPN IP address of the machine that is running the
1306 tincd.  ``internet IP'' is the IP address of the firewall, which does not
1307 need to run tincd, but it must do a port forwarding of TCP&UDP on port
1308 655 (unless otherwise configured).
1309
1310 In this example, it is assumed that eth0 is the interface that points to
1311 the inner (physical) LAN of the office, although this could also be the
1312 same as the interface that leads to the Internet.  The configuration of
1313 the real interface is also shown as a comment, to give you an idea of
1314 how these example host is set up. All branches use the netname `company'
1315 for this particular VPN.
1316
1317 @subsubheading For Branch A
1318
1319 @emph{BranchA} would be configured like this:
1320
1321 In @file{@value{sysconfdir}/tinc/company/tinc-up}:
1322
1323 @example
1324 # Real interface of internal network:
1325 # ifconfig eth0 10.1.54.1 netmask 255.255.0.0 broadcast 10.1.255.255
1326
1327 ifconfig $INTERFACE 10.1.54.1 netmask 255.0.0.0
1328 @end example
1329
1330 and in @file{@value{sysconfdir}/tinc/company/tinc.conf}:
1331
1332 @example
1333 Name = BranchA
1334 PrivateKeyFile = @value{sysconfdir}/tinc/company/rsa_key.priv
1335 Device = /dev/tap0
1336 @end example
1337
1338 On all hosts, @value{sysconfdir}/tinc/company/hosts/BranchA contains:
1339
1340 @example
1341 Subnet = 10.1.0.0/16
1342 Address = 1.2.3.4
1343
1344 -----BEGIN RSA PUBLIC KEY-----
1345 ...
1346 -----END RSA PUBLIC KEY-----
1347 @end example
1348
1349 Note that the IP addresses of eth0 and tap0 are the same.
1350 This is quite possible, if you make sure that the netmasks of the interfaces are different.
1351 It is in fact recommended to give give both real internal network interfaces and tap interfaces the same IP address,
1352 since that will make things a lot easier to remember and set up.
1353
1354
1355 @subsubheading For Branch B
1356
1357 In @file{@value{sysconfdir}/tinc/company/tinc-up}:
1358
1359 @example
1360 # Real interface of internal network:
1361 # ifconfig eth0 10.2.43.8 netmask 255.255.0.0 broadcast 10.2.255.255
1362
1363 ifconfig $INTERFACE 10.2.1.12 netmask 255.0.0.0
1364 @end example
1365
1366 and in @file{@value{sysconfdir}/tinc/company/tinc.conf}:
1367
1368 @example
1369 Name = BranchB
1370 ConnectTo = BranchA
1371 PrivateKeyFile = @value{sysconfdir}/tinc/company/rsa_key.priv
1372 @end example
1373
1374 Note here that the internal address (on eth0) doesn't have to be the
1375 same as on the tap0 device.  Also, ConnectTo is given so that no-one can
1376 connect to this node.
1377
1378 On all hosts, in @file{@value{sysconfdir}/tinc/company/hosts/BranchB}:
1379
1380 @example
1381 Subnet = 10.2.0.0/16
1382 Address = 2.3.4.5
1383
1384 -----BEGIN RSA PUBLIC KEY-----
1385 ...
1386 -----END RSA PUBLIC KEY-----
1387 @end example
1388
1389
1390 @subsubheading For Branch C
1391
1392 In @file{@value{sysconfdir}/tinc/company/tinc-up}:
1393
1394 @example
1395 # Real interface of internal network:
1396 # ifconfig eth0 10.3.69.254 netmask 255.255.0.0 broadcast 10.3.255.255
1397
1398 ifconfig $INTERFACE 10.3.69.254 netmask 255.0.0.0
1399 @end example
1400
1401 and in @file{@value{sysconfdir}/tinc/company/tinc.conf}:
1402
1403 @example
1404 Name = BranchC
1405 ConnectTo = BranchA
1406 Device = /dev/tap1
1407 @end example
1408
1409 C already has another daemon that runs on port 655, so they have to
1410 reserve another port for tinc. It knows the portnumber it has to listen on
1411 from it's own host configuration file.
1412
1413 On all hosts, in @file{@value{sysconfdir}/tinc/company/hosts/BranchC}:
1414
1415 @example
1416 Address = 3.4.5.6
1417 Subnet = 10.3.0.0/16
1418 Port = 2000
1419
1420 -----BEGIN RSA PUBLIC KEY-----
1421 ...
1422 -----END RSA PUBLIC KEY-----
1423 @end example
1424
1425
1426 @subsubheading For Branch D
1427
1428 In @file{@value{sysconfdir}/tinc/company/tinc-up}:
1429
1430 @example
1431 # Real interface of internal network:
1432 # ifconfig eth0 10.4.3.32 netmask 255.255.0.0 broadcast 10.4.255.255
1433
1434 ifconfig $INTERFACE 10.4.3.32 netmask 255.0.0.0
1435 @end example
1436
1437 and in @file{@value{sysconfdir}/tinc/company/tinc.conf}:
1438
1439 @example
1440 Name = BranchD
1441 ConnectTo = BranchC
1442 Device = /dev/net/tun
1443 PrivateKeyFile = @value{sysconfdir}/tinc/company/rsa_key.priv
1444 @end example
1445
1446 D will be connecting to C, which has a tincd running for this network on
1447 port 2000. It knows the port number from the host configuration file.
1448 Also note that since D uses the tun/tap driver, the network interface
1449 will not be called `tun' or `tap0' or something like that, but will
1450 have the same name as netname.
1451
1452 On all hosts, in @file{@value{sysconfdir}/tinc/company/hosts/BranchD}:
1453
1454 @example
1455 Subnet = 10.4.0.0/16
1456 Address = 4.5.6.7
1457
1458 -----BEGIN RSA PUBLIC KEY-----
1459 ...
1460 -----END RSA PUBLIC KEY-----
1461 @end example
1462
1463 @subsubheading Key files
1464
1465 A, B, C and D all have generated a public/private keypair with the following command:
1466
1467 @example
1468 tincd -n company -K
1469 @end example
1470
1471 The private key is stored in @file{@value{sysconfdir}/tinc/company/rsa_key.priv},
1472 the public key is put into the host configuration file in the @file{@value{sysconfdir}/tinc/company/hosts/} directory.
1473 During key generation, tinc automatically guesses the right filenames based on the -n option and
1474 the Name directive in the @file{tinc.conf} file (if it is available).
1475
1476 @subsubheading Starting
1477
1478 After each branch has finished configuration and they have distributed
1479 the host configuration files amongst them, they can start their tinc daemons.
1480 They don't necessarily have to wait for the other branches to have started
1481 their daemons, tinc will try connecting until they are available.
1482
1483
1484 @c ==================================================================
1485 @node    Running tinc, Technical information, Configuration, Top
1486 @chapter Running tinc
1487
1488 If everything else is done, you can start tinc by typing the following command:
1489
1490 @example
1491 tincd -n @var{netname}
1492 @end example
1493
1494 @cindex daemon
1495 tinc will detach from the terminal and continue to run in the background like a good daemon.
1496 If there are any problems however you can try to increase the debug level
1497 and look in the syslog to find out what the problems are.
1498
1499 @menu
1500 * Runtime options::
1501 * Error messages::
1502 @end menu
1503
1504
1505 @c ==================================================================
1506 @node    Runtime options, Error messages, Running tinc, Running tinc
1507 @section Runtime options
1508
1509 Besides the settings in the configuration file, tinc also accepts some
1510 command line options.
1511
1512 @cindex command line
1513 @cindex runtime options
1514 @cindex options
1515 @c from the manpage
1516 @table @option
1517 @item -c, --config=PATH
1518 Read configuration options from the directory PATH.  The default is
1519 @file{@value{sysconfdir}/tinc/@var{netname}/}.
1520
1521 @item -D, --no-detach
1522 Don't fork and detach.
1523 This will also disable the automatic restart mechanism for fatal errors.
1524
1525 @cindex debug level
1526 @item -d, --debug=LEVEL
1527 Set debug level to LEVEL.  The higher the debug level, the more gets
1528 logged.  Everything goes via syslog.
1529
1530 @item -k, --kill[=SIGNAL]
1531 Attempt to kill a running tincd (optionally with the specified SIGNAL instead of SIGTERM) and exit.
1532 Use it in conjunction with the -n option to make sure you kill the right tinc daemon.
1533 Under native Windows the optional argument is ignored,
1534 the service will always be stopped and removed.
1535
1536 @item -n, --net=NETNAME
1537 Connect to net NETNAME.  @xref{Multiple networks}.
1538
1539 @item -K, --generate-keys[=BITS]
1540 Generate public/private keypair of BITS length. If BITS is not specified,
1541 1024 is the default. tinc will ask where you want to store the files,
1542 but will default to the configuration directory (you can use the -c or -n option
1543 in combination with -K). After that, tinc will quit.
1544
1545 @item -L, --mlock
1546 Lock tinc into main memory.
1547 This will prevent sensitive data like shared private keys to be written to the system swap files/partitions.
1548
1549 @item --logfile[=FILE]
1550 Write log entries to a file instead of to the system logging facility.
1551 If FILE is omitted, the default is @value{localstatedir}/log/tinc.NETNAME.log.
1552
1553 @item --pidfile=FILE
1554 Write PID to FILE instead of @value{localstatedir}/run/tinc.NETNAME.pid.
1555
1556 @item --bypass-security
1557 Disables encryption and authentication.
1558 Only useful for debugging.
1559
1560 @item --help
1561 Display a short reminder of these runtime options and terminate.
1562
1563 @item --version
1564 Output version information and exit.
1565
1566 @end table
1567
1568
1569 @c ==================================================================
1570 @node    Error messages,  , Runtime options, Running tinc
1571 @section Error messages
1572
1573 What follows is a list of the most common error messages you can see
1574 when configuring tinc.  Most of these messages are visible in the syslog
1575 only, so keep an eye on it!
1576
1577 @table @strong
1578 @item Could not open /dev/tap0: No such device
1579
1580 @itemize
1581 @item You forgot to `modprobe netlink_dev' or `modprobe ethertap'.
1582 @item You forgot to compile `Netlink device emulation' in the kernel.
1583 @end itemize
1584
1585 @item Can't write to /dev/net/tun: No such device
1586
1587 @itemize
1588 @item You forgot to `modprobe tun'.
1589 @item You forgot to compile `Universal TUN/TAP driver' in the kernel.
1590 @end itemize
1591
1592 @item Packet with destination 1.2.3.4 is looping back to us!
1593
1594 @itemize
1595 @item Something is not configured right. Packets are being sent out to the
1596 virtual network device, but according to the Subnet directives in your host configuration
1597 file, those packets should go to your own host. Most common mistake is that
1598 you have a Subnet line in your host configuration file with a prefix length which is
1599 just as large as the prefix of the virtual network interface. The latter should in almost all
1600 cases be larger. Rethink your configuration.
1601 Note that you will only see this message if you specified a debug
1602 level of 5 or higher!
1603 @item Chances are that a `Subnet = ...' line in the host configuration file of this tinc daemon is wrong.
1604 Change it to a subnet that is accepted locally by another interface,
1605 or if that is not the case, try changing the prefix length into /32. 
1606 @end itemize
1607
1608 @item Network doesn't work, syslog shows only packets of length 46
1609
1610 @item Network address and prefix length do not match!
1611
1612 @itemize
1613 @item The Subnet field must contain a @emph{network} address.
1614 @item If you only want to use one IP address, set the netmask to /32.
1615 @end itemize
1616
1617 @item This is a bug: net.c:253: 24: Some error
1618
1619 @itemize
1620 @item This is something that should not have happened.
1621 Please report this, and tell us exactly what went wrong before you got
1622 this message.  In normal operation, these errors should not occur.
1623 @end itemize
1624
1625 @item Error reading RSA key file `rsa_key.priv': No such file or directory
1626
1627 @itemize
1628 @item You must specify the complete pathname.
1629 Specifying a relative path does not make sense here.  tinc changes its
1630 directory to / when starting (to avoid keeping a mount point busy).
1631 @end itemize
1632
1633 @end table
1634
1635 @c ==================================================================
1636 @node    Technical information, About us, Running tinc, Top
1637 @chapter Technical information
1638
1639
1640 @menu
1641 * The connection::
1642 * The meta-protocol::
1643 * Security::
1644 @end menu
1645
1646
1647 @c ==================================================================
1648 @node    The connection, The meta-protocol, Technical information, Technical information
1649 @section The connection
1650
1651 @cindex connection
1652 tinc is a daemon that takes VPN data and transmit that to another host
1653 computer over the existing Internet infrastructure.
1654
1655 @menu
1656 * The UDP tunnel::
1657 * The meta-connection::
1658 @end menu
1659
1660
1661 @c ==================================================================
1662 @node    The UDP tunnel, The meta-connection, The connection, The connection
1663 @subsection The UDP tunnel
1664
1665 @cindex virtual network device
1666 @cindex frame type
1667 The data itself is read from a character device file, the so-called
1668 @emph{virtual network device}.  This device is associated with a network
1669 interface.  Any data sent to this interface can be read from the device,
1670 and any data written to the device gets sent from the interface.
1671 There are two possible types of virtual network devices:
1672 `tun' style, which are point-to-point devices which can only handle IPv4 and/or IPv6 packets,
1673 and `tap' style, which are Ethernet devices and handle complete Ethernet frames.
1674
1675 So when tinc reads an Ethernet frame from the device, it determines its
1676 type. When tinc is in it's default routing mode, it can handle IPv4 and IPv6
1677 packets. Depending on the Subnet lines, it will send the packets off to their destination IP address.
1678 In the `switch' and `hub' mode, tinc will use broadcasts and MAC address discovery
1679 to deduce the destination of the packets.
1680 Since the latter modes only depend on the link layer information,
1681 any protocol that runs over Ethernet is supported (for instance IPX and Appletalk).
1682 However, only `tap' style devices provide this information.
1683
1684 After the destination has been determined,
1685 the packet will be compressed (optionally),
1686 a sequence number will be added to the packet,
1687 the packet will then be encrypted
1688 and a message authentication code will be appended.
1689
1690 @cindex encapsulating
1691 @cindex UDP
1692 When that is done, time has come to actually transport the
1693 packet to the destination computer.  We do this by sending the packet
1694 over an UDP connection to the destination host.  This is called
1695 @emph{encapsulating}, the VPN packet (though now encrypted) is
1696 encapsulated in another IP datagram.
1697
1698 When the destination receives this packet, the same thing happens, only
1699 in reverse.  So it checks the message authentication code, decrypts the contents of the UDP datagram,
1700 checks the sequence number
1701 and writes the decrypted information to its own virtual network device.
1702
1703 If the virtual network device is a `tun' device (a point-to-point tunnel),
1704 there is no problem for the kernel to accept a packet.
1705 However, if it is a `tap' device (this is the only available type on FreeBSD),
1706 the destination MAC address must match that of the virtual network interface.
1707 If tinc is in it's default routing mode, ARP does not work, so the correct destination MAC 
1708 can not be known by the sending host.
1709 tinc solves this by letting the receiving end detect the MAC address of its own virtual network interface
1710 and overwriting the destination MAC address of the received packet.
1711
1712 In switch or hub modes ARP does work so the sender already knows the correct destination MAC address.
1713 In those modes every interface should have a unique MAC address, so make sure they are not the same.
1714 Because switch and hub modes rely on MAC addresses to function correctly,
1715 these modes cannot be used on the following operating systems which don't have a `tap' style virtual network device:
1716 OpenBSD, NetBSD, Darwin and Solaris.
1717
1718
1719 @c ==================================================================
1720 @node    The meta-connection,  , The UDP tunnel, The connection
1721 @subsection The meta-connection
1722
1723 Having only a UDP connection available is not enough.  Though suitable
1724 for transmitting data, we want to be able to reliably send other
1725 information, such as routing and session key information to somebody.
1726
1727 @cindex TCP
1728 TCP is a better alternative, because it already contains protection
1729 against information being lost, unlike UDP.
1730
1731 So we establish two connections.  One for the encrypted VPN data, and one
1732 for other information, the meta-data.  Hence, we call the second
1733 connection the meta-connection.  We can now be sure that the
1734 meta-information doesn't get lost on the way to another computer.
1735
1736 @cindex data-protocol
1737 @cindex meta-protocol
1738 Like with any communication, we must have a protocol, so that everybody
1739 knows what everything stands for, and how she should react.  Because we
1740 have two connections, we also have two protocols.  The protocol used for
1741 the UDP data is the ``data-protocol,'' the other one is the
1742 ``meta-protocol.''
1743
1744 The reason we don't use TCP for both protocols is that UDP is much
1745 better for encapsulation, even while it is less reliable.  The real
1746 problem is that when TCP would be used to encapsulate a TCP stream
1747 that's on the private network, for every packet sent there would be
1748 three ACKs sent instead of just one.  Furthermore, if there would be
1749 a timeout, both TCP streams would sense the timeout, and both would
1750 start re-sending packets.
1751
1752
1753 @c ==================================================================
1754 @node    The meta-protocol, Security, The connection, Technical information
1755 @section The meta-protocol
1756
1757 The meta protocol is used to tie all tinc daemons together, and
1758 exchange information about which tinc daemon serves which virtual
1759 subnet.
1760
1761 The meta protocol consists of requests that can be sent to the other
1762 side.  Each request has a unique number and several parameters.  All
1763 requests are represented in the standard ASCII character set.  It is
1764 possible to use tools such as telnet or netcat to connect to a tinc
1765 daemon started with the --bypass-security option
1766 and to read and write requests by hand, provided that one
1767 understands the numeric codes sent.
1768
1769 The authentication scheme is described in @ref{Authentication protocol}. After a
1770 successful authentication, the server and the client will exchange all the
1771 information about other tinc daemons and subnets they know of, so that both
1772 sides (and all the other tinc daemons behind them) have their information
1773 synchronised.
1774
1775 @cindex ADD_EDGE
1776 @cindex ADD_SUBNET
1777 @example
1778 daemon  message
1779 --------------------------------------------------------------------------
1780 origin  ADD_EDGE node1 node2 21.32.43.54 655 222 0
1781                    |     |        |       |   |  +-> options
1782                    |     |        |       |   +----> weight
1783                            |     |        |       +--------> UDP port of node2
1784                            |     |        +----------------> real address of node2
1785                            |     +-------------------------> name of destination node
1786                    +-------------------------------> name of source node
1787
1788 origin  ADD_SUBNET node 192.168.1.0/24
1789                      |         |     +--> prefixlength
1790                      |         +--------> network address
1791                      +------------------> owner of this subnet
1792 --------------------------------------------------------------------------
1793 @end example
1794
1795 The ADD_EDGE messages are to inform other tinc daemons that a connection between
1796 two nodes exist. The address of the destination node is available so that
1797 VPN packets can be sent directly to that node.
1798
1799 The ADD_SUBNET messages inform other tinc daemons that certain subnets belong
1800 to certain nodes. tinc will use it to determine to which node a VPN packet has
1801 to be sent.
1802
1803 @cindex DEL_EDGE
1804 @cindex DEL_SUBNET
1805 @example
1806 message
1807 ------------------------------------------------------------------
1808 DEL_EDGE node1 node2
1809                    |     +----> name of destination node
1810            +----------> name of source node
1811
1812 DEL_SUBNET node 192.168.1.0/24
1813              |         |     +--> prefixlength
1814              |         +--------> network address
1815              +------------------> owner of this subnet
1816 ------------------------------------------------------------------
1817 @end example
1818
1819 In case a connection between two daemons is closed or broken, DEL_EDGE messages
1820 are sent to inform the other daemons of that fact. Each daemon will calculate a
1821 new route to the the daemons, or mark them unreachable if there isn't any.
1822
1823 @cindex REQ_KEY
1824 @cindex ANS_KEY
1825 @cindex KEY_CHANGED
1826 @example
1827 message
1828 ------------------------------------------------------------------
1829 REQ_KEY origin destination
1830            |       +--> name of the tinc daemon it wants the key from
1831            +----------> name of the daemon that wants the key      
1832
1833 ANS_KEY origin destination 4ae0b0a82d6e0078 91 64 4
1834            |       |       \______________/ |  |  +--> MAC length
1835            |       |               |        |  +-----> digest algorithm
1836            |       |               |        +--------> cipher algorithm
1837            |       |               +--> 128 bits key
1838            |       +--> name of the daemon that wants the key
1839            +----------> name of the daemon that uses this key
1840
1841 KEY_CHANGED origin
1842               +--> daemon that has changed it's packet key
1843 --------------------------------------------------------------------------
1844 @end example
1845
1846 The keys used to encrypt VPN packets are not sent out directly. This is
1847 because it would generate a lot of traffic on VPNs with many daemons, and
1848 chances are that not every tinc daemon will ever send a packet to every
1849 other daemon. Instead, if a daemon needs a key it sends a request for it
1850 via the meta connection of the nearest hop in the direction of the
1851 destination.
1852
1853 @cindex PING
1854 @cindex PONG
1855 @example
1856 daemon  message
1857 --------------------------------------------------------------------------
1858 origin  PING
1859 dest.   PONG
1860 --------------------------------------------------------------------------
1861 @end example
1862
1863 There is also a mechanism to check if hosts are still alive. Since network
1864 failures or a crash can cause a daemon to be killed without properly
1865 shutting down the TCP connection, this is necessary to keep an up to date
1866 connection list. PINGs are sent at regular intervals, except when there
1867 is also some other traffic. A little bit of salt (random data) is added
1868 with each PING and PONG message, to make sure that long sequences of PING/PONG
1869 messages without any other traffic won't result in known plaintext.
1870
1871 This basically covers what is sent over the meta connection by
1872 tinc.
1873
1874
1875 @c ==================================================================
1876 @node    Security,  , The meta-protocol, Technical information
1877 @section About tinc's encryption and other security-related issues.
1878
1879 @cindex TINC
1880 @cindex Cabal
1881 tinc got its name from ``TINC,'' short for @emph{There Is No Cabal}; the
1882 alleged Cabal was/is an organisation that was said to keep an eye on the
1883 entire Internet.  As this is exactly what you @emph{don't} want, we named
1884 the tinc project after TINC.
1885
1886 @cindex SVPN
1887 But in order to be ``immune'' to eavesdropping, you'll have to encrypt
1888 your data.  Because tinc is a @emph{Secure} VPN (SVPN) daemon, it does
1889 exactly that: encrypt.
1890 tinc by default uses blowfish encryption with 128 bit keys in CBC mode, 32 bit
1891 sequence numbers and 4 byte long message authentication codes to make sure
1892 eavesdroppers cannot get and cannot change any information at all from the
1893 packets they can intercept. The encryption algorithm and message authentication
1894 algorithm can be changed in the configuration. The length of the message
1895 authentication codes is also adjustable. The length of the key for the
1896 encryption algorithm is always the default length used by OpenSSL.
1897
1898 @menu
1899 * Authentication protocol::
1900 * Encryption of network packets::
1901 @end menu
1902
1903
1904 @c ==================================================================
1905 @node       Authentication protocol, Encryption of network packets, Security, Security
1906 @subsection Authentication protocol
1907
1908 @cindex authentication
1909 A new scheme for authentication in tinc has been devised, which offers some
1910 improvements over the protocol used in 1.0pre2 and 1.0pre3. Explanation is
1911 below.
1912
1913 @cindex ID
1914 @cindex META_KEY
1915 @cindex CHALLENGE
1916 @cindex CHAL_REPLY
1917 @cindex ACK
1918 @example
1919 daemon  message
1920 --------------------------------------------------------------------------
1921 client  <attempts connection>
1922
1923 server  <accepts connection>
1924
1925 client  ID client 12
1926               |   +---> version
1927               +-------> name of tinc daemon
1928
1929 server  ID server 12
1930               |   +---> version
1931               +-------> name of tinc daemon
1932
1933 client  META_KEY 5f0823a93e35b69e...7086ec7866ce582b
1934                  \_________________________________/
1935                                  +-> RSAKEYLEN bits totally random string S1,
1936                                      encrypted with server's public RSA key
1937
1938 server  META_KEY 6ab9c1640388f8f0...45d1a07f8a672630
1939                  \_________________________________/
1940                                  +-> RSAKEYLEN bits totally random string S2,
1941                                      encrypted with client's public RSA key
1942
1943 From now on:
1944  - the client will symmetrically encrypt outgoing traffic using S1
1945  - the server will symmetrically encrypt outgoing traffic using S2
1946
1947 client  CHALLENGE da02add1817c1920989ba6ae2a49cecbda0
1948                   \_________________________________/
1949                                  +-> CHALLEN bits totally random string H1
1950
1951 server  CHALLENGE 57fb4b2ccd70d6bb35a64c142f47e61d57f
1952                   \_________________________________/
1953                                  +-> CHALLEN bits totally random string H2
1954
1955 client  CHAL_REPLY 816a86
1956                       +-> 160 bits SHA1 of H2
1957
1958 server  CHAL_REPLY 928ffe
1959                       +-> 160 bits SHA1 of H1
1960
1961 After the correct challenge replies are received, both ends have proved
1962 their identity. Further information is exchanged.
1963
1964 client  ACK 655 123 0
1965              |   |  +-> options
1966                  |   +----> estimated weight
1967                  +--------> listening port of client
1968
1969 server  ACK 655 321 0
1970              |   |  +-> options
1971                  |   +----> estimated weight
1972                  +--------> listening port of server
1973 --------------------------------------------------------------------------
1974 @end example
1975
1976 This new scheme has several improvements, both in efficiency and security.
1977
1978 First of all, the server sends exactly the same kind of messages over the wire
1979 as the client. The previous versions of tinc first authenticated the client,
1980 and then the server. This scheme even allows both sides to send their messages
1981 simultaneously, there is no need to wait for the other to send something first.
1982 This means that any calculations that need to be done upon sending or receiving
1983 a message can also be done in parallel. This is especially important when doing
1984 RSA encryption/decryption. Given that these calculations are the main part of
1985 the CPU time spent for the authentication, speed is improved by a factor 2.
1986
1987 Second, only one RSA encrypted message is sent instead of two. This reduces the
1988 amount of information attackers can see (and thus use for a cryptographic
1989 attack). It also improves speed by a factor two, making the total speedup a
1990 factor 4.
1991
1992 Third, and most important:
1993 The symmetric cipher keys are exchanged first, the challenge is done
1994 afterwards. In the previous authentication scheme, because a man-in-the-middle
1995 could pass the challenge/chal_reply phase (by just copying the messages between
1996 the two real tinc daemons), but no information was exchanged that was really
1997 needed to read the rest of the messages, the challenge/chal_reply phase was of
1998 no real use. The man-in-the-middle was only stopped by the fact that only after
1999 the ACK messages were encrypted with the symmetric cipher. Potentially, it
2000 could even send it's own symmetric key to the server (if it knew the server's
2001 public key) and read some of the metadata the server would send it (it was
2002 impossible for the mitm to read actual network packets though). The new scheme
2003 however prevents this.
2004
2005 This new scheme makes sure that first of all, symmetric keys are exchanged. The
2006 rest of the messages are then encrypted with the symmetric cipher. Then, each
2007 side can only read received messages if they have their private key. The
2008 challenge is there to let the other side know that the private key is really
2009 known, because a challenge reply can only be sent back if the challenge is
2010 decrypted correctly, and that can only be done with knowledge of the private
2011 key.
2012
2013 Fourth: the first thing that is sent via the symmetric cipher encrypted
2014 connection is a totally random string, so that there is no known plaintext (for
2015 an attacker) in the beginning of the encrypted stream.
2016
2017
2018 @c ==================================================================
2019 @node       Encryption of network packets,  , Authentication protocol, Security
2020 @subsection Encryption of network packet
2021 @cindex encryption
2022
2023 A data packet can only be sent if the encryption key is known to both
2024 parties, and the connection is  activated. If the encryption key is not
2025 known, a request is sent to the destination using the meta connection
2026 to retrieve it. The packet is stored in a queue while waiting for the
2027 key to arrive.
2028
2029 @cindex UDP
2030 The UDP packet containing the network packet from the VPN has the following layout:
2031
2032 @example
2033 ... | IP header | UDP header | seqno | VPN packet | MAC | UDP trailer
2034                              \___________________/\_____/
2035                                        |             |
2036                                        V             +---> digest algorithm
2037                          Encrypted with symmetric cipher
2038 @end example
2039
2040 So, the entire VPN packet is encrypted using a symmetric cipher, including a 32 bits
2041 sequence number that is added in front of the actual VPN packet, to act as a unique
2042 IV for each packet and to prevent replay attacks. A message authentication code
2043 is added to the UDP packet to prevent alteration of packets. By default the
2044 first 4 bytes of the digest are used for this, but this can be changed using
2045 the MACLength configuration variable.
2046
2047 @c ==================================================================
2048 @node    About us, Concept Index, Technical information, Top
2049 @chapter About us
2050
2051
2052 @menu
2053 * Contact Information::
2054 * Authors::
2055 @end menu
2056
2057
2058 @c ==================================================================
2059 @node    Contact Information, Authors, About us, About us
2060 @section Contact information
2061
2062 @cindex website
2063 tinc's website is at @url{http://tinc.nl.linux.org/},
2064 this server is located in the Netherlands.
2065
2066 @cindex IRC
2067 We have an IRC channel on the FreeNode and OFTC IRC networks. Connect to
2068 @uref{http://www.freenode.net/, irc.freenode.net}
2069 or
2070 @uref{http://www.oftc.net/, irc.oftc.net}
2071 and join channel #tinc.
2072
2073
2074 @c ==================================================================
2075 @node    Authors,  , Contact Information, About us
2076 @section Authors
2077
2078 @table @asis
2079 @item Ivo Timmermans (zarq) (@email{ivo@@o2w.nl})
2080 @item Guus Sliepen (guus) (@email{guus@@sliepen.eu.org})
2081 @end table
2082
2083 We have received a lot of valuable input from users.  With their help,
2084 tinc has become the flexible and robust tool that it is today.  We have
2085 composed a list of contributions, in the file called @file{THANKS} in
2086 the source distribution.
2087
2088
2089 @c ==================================================================
2090 @node    Concept Index,  , About us, Top
2091 @c        node-name,    next, previous,        up
2092 @unnumbered Concept Index
2093
2094 @c ==================================================================
2095 @printindex cp
2096
2097
2098 @c ==================================================================
2099 @contents
2100 @bye