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