Add the AutoConnect option.
[tinc] / doc / tinc.texi
1 \input texinfo   @c -*-texinfo-*-
2 @c %**start of header
3 @setfilename tinc.info
4 @settitle tinc Manual
5 @setchapternewpage odd
6 @c %**end of header
7
8 @include tincinclude.texi
9
10 @ifinfo
11 @dircategory Networking tools
12 @direntry
13 * tinc: (tinc).              The tinc Manual.
14 @end direntry
15
16 This is the info manual for @value{PACKAGE} version @value{VERSION}, a Virtual Private Network daemon.
17
18 Copyright @copyright{} 1998-2012 Ivo Timmermans,
19 Guus Sliepen <guus@@tinc-vpn.org> and
20 Wessel Dankers <wsl@@tinc-vpn.org>.
21
22 Permission is granted to make and distribute verbatim copies of this
23 manual provided the copyright notice and this permission notice are
24 preserved on all copies.
25
26 Permission is granted to copy and distribute modified versions of this
27 manual under the conditions for verbatim copying, provided that the
28 entire resulting derived work is distributed under the terms of a
29 permission notice identical to this one.
30
31 @end ifinfo
32
33 @titlepage
34 @title tinc Manual
35 @subtitle Setting up a Virtual Private Network with tinc
36 @author Ivo Timmermans and Guus Sliepen
37
38 @page
39 @vskip 0pt plus 1filll
40 This is the info manual for @value{PACKAGE} version @value{VERSION}, a Virtual Private Network daemon.
41
42 Copyright @copyright{} 1998-2012 Ivo Timmermans,
43 Guus Sliepen <guus@@tinc-vpn.org> and
44 Wessel Dankers <wsl@@tinc-vpn.org>.
45
46 Permission is granted to make and distribute verbatim copies of this
47 manual provided the copyright notice and this permission notice are
48 preserved on all copies.
49
50 Permission is granted to copy and distribute modified versions of this
51 manual under the conditions for verbatim copying, provided that the
52 entire resulting derived work is distributed under the terms of a
53 permission notice identical to this one.
54
55 @end titlepage
56
57 @ifnottex
58 @c ==================================================================
59 @node Top
60 @top Top
61
62 @menu
63 * Introduction::
64 * Preparations::
65 * Installation::
66 * Configuration::
67 * Running tinc::
68 * Controlling tinc::
69 * Technical information::
70 * Platform specific information::
71 * About us::
72 * Concept Index::               All used terms explained
73 @end menu
74 @end ifnottex
75
76 @c ==================================================================
77 @node    Introduction
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 * Virtual Private Networks::
96 * tinc::                        About tinc
97 * Supported platforms::
98 @end menu
99
100 @c ==================================================================
101 @node    Virtual Private Networks
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 single 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
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 "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
177 @section Supported platforms
178
179 @cindex platforms
180 Tinc has been verified to work under Linux, FreeBSD, OpenBSD, NetBSD, MacOS/X (Darwin), Solaris, and Windows (both natively and in a Cygwin environment),
181 with 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://www.tinc-vpn.org/platforms/}.
191
192 @c
193 @c
194 @c
195 @c
196 @c
197 @c
198 @c       Preparing your system
199 @c
200 @c
201 @c
202 @c
203 @c
204
205 @c ==================================================================
206 @node    Preparations
207 @chapter Preparations
208
209 This chapter contains information on how to prepare your system to
210 support tinc.
211
212 @menu
213 * Configuring the kernel::
214 * Libraries::
215 @end menu
216
217
218 @c ==================================================================
219 @node    Configuring the kernel
220 @section Configuring the kernel
221
222 @menu
223 * Configuration of Linux kernels::
224 * Configuration of FreeBSD kernels::
225 * Configuration of OpenBSD kernels::
226 * Configuration of NetBSD kernels::
227 * Configuration of Solaris kernels::
228 * Configuration of Darwin (MacOS/X) kernels::
229 * Configuration of Windows::
230 @end menu
231
232
233 @c ==================================================================
234 @node       Configuration of Linux kernels
235 @subsection Configuration of Linux kernels
236
237 @cindex Universal tun/tap
238 For tinc to work, you need a kernel that supports the Universal tun/tap device.
239 Most distributions come with kernels that already support this.
240 Here are the options you have to turn on when configuring a new kernel:
241
242 @example
243 Code maturity level options
244 [*] Prompt for development and/or incomplete code/drivers
245 Network device support
246 <M> Universal tun/tap device driver support
247 @end example
248
249 It's not necessary to compile this driver as a module, even if you are going to
250 run more than one instance of tinc.
251
252 If you decide to build the tun/tap driver as a kernel module, add these lines
253 to @file{/etc/modules.conf}:
254
255 @example
256 alias char-major-10-200 tun
257 @end example
258
259
260 @c ==================================================================
261 @node       Configuration of FreeBSD kernels
262 @subsection Configuration of FreeBSD kernels
263
264 For FreeBSD version 4.1 and higher, tun and tap drivers are included in the default kernel configuration.
265 The tap driver can be loaded with @code{kldload if_tap}, or by adding @code{if_tap_load="YES"} to @file{/boot/loader.conf}. 
266
267
268 @c ==================================================================
269 @node       Configuration of OpenBSD kernels
270 @subsection Configuration of OpenBSD kernels
271
272 For OpenBSD version 2.9 and higher,
273 the tun driver is included in the default kernel configuration.
274 There is also a kernel patch from @uref{http://diehard.n-r-g.com/stuff/openbsd/}
275 which adds a tap device to OpenBSD which should work with tinc,
276 but with recent versions of OpenBSD,
277 a tun device can act as a tap device by setting the link0 option with ifconfig.
278
279
280 @c ==================================================================
281 @node       Configuration of NetBSD kernels
282 @subsection Configuration of NetBSD kernels
283
284 For NetBSD version 1.5.2 and higher,
285 the tun driver is included in the default kernel configuration.
286
287 Tunneling IPv6 may not work on NetBSD's tun device.
288
289
290 @c ==================================================================
291 @node       Configuration of Solaris kernels
292 @subsection Configuration of Solaris kernels
293
294 For Solaris 8 (SunOS 5.8) and higher,
295 the tun driver may or may not be included in the default kernel configuration.
296 If it isn't, the source can be downloaded from @uref{http://vtun.sourceforge.net/tun/}.
297 For x86 and sparc64 architectures, precompiled versions can be found at @uref{http://www.monkey.org/~dugsong/fragroute/}.
298 If the @file{net/if_tun.h} header file is missing, install it from the source package.
299
300
301 @c ==================================================================
302 @node       Configuration of Darwin (MacOS/X) kernels
303 @subsection Configuration of Darwin (MacOS/X) kernels
304
305 Tinc on Darwin relies on a tunnel driver for its data acquisition from the kernel.
306 Tinc supports either the driver from @uref{http://tuntaposx.sourceforge.net/},
307 which supports both tun and tap style devices,
308 and also the driver from from @uref{http://chrisp.de/en/projects/tunnel.html}.
309 The former driver is recommended.
310 The tunnel driver must be loaded before starting tinc with the following command:
311
312 @example
313 kmodload tunnel
314 @end example
315
316
317 @c ==================================================================
318 @node       Configuration of Windows
319 @subsection Configuration of Windows
320
321 You will need to install the latest TAP-Win32 driver from OpenVPN.
322 You can download it from @uref{http://openvpn.sourceforge.net}.
323 Using the Network Connections control panel,
324 configure the TAP-Win32 network interface in the same way as you would do from the tinc-up script,
325 as explained in the rest of the documentation.
326
327
328 @c ==================================================================
329 @node    Libraries
330 @section Libraries
331
332 @cindex requirements
333 @cindex libraries
334 Before you can configure or build tinc, you need to have the OpenSSL,
335 zlib and lzo libraries installed on your system.  If you try to configure tinc without
336 having them installed, configure will give you an error message, and stop.
337
338 @menu
339 * OpenSSL::
340 * zlib::
341 * lzo::
342 * libevent::
343 @end menu
344
345
346 @c ==================================================================
347 @node       OpenSSL
348 @subsection OpenSSL
349
350 @cindex OpenSSL
351 For all cryptography-related functions, tinc uses the functions provided
352 by the OpenSSL library.
353
354 If this library is not installed, you wil get an error when configuring
355 tinc for build.  Support for running tinc without having OpenSSL
356 installed @emph{may} be added in the future.
357
358 You can use your operating system's package manager to install this if
359 available.  Make sure you install the development AND runtime versions
360 of this package.
361
362 If you have to install OpenSSL manually, you can get the source code
363 from @url{http://www.openssl.org/}.  Instructions on how to configure,
364 build and install this package are included within the package.  Please
365 make sure you build development and runtime libraries (which is the
366 default).
367
368 If you installed the OpenSSL libraries from source, it may be necessary
369 to let configure know where they are, by passing configure one of the
370 --with-openssl-* parameters.
371
372 @example
373 --with-openssl=DIR      OpenSSL library and headers prefix
374 --with-openssl-include=DIR OpenSSL headers directory
375                         (Default is OPENSSL_DIR/include)
376 --with-openssl-lib=DIR  OpenSSL library directory
377                         (Default is OPENSSL_DIR/lib)
378 @end example
379
380
381 @subsubheading License
382
383 @cindex license
384 The complete source code of tinc is covered by the GNU GPL version 2.
385 Since the license under which OpenSSL is distributed is not directly
386 compatible with the terms of the GNU GPL
387 @uref{http://www.openssl.org/support/faq.html#LEGAL2}, we
388 include an exemption to the GPL (see also the file COPYING.README) to allow
389 everyone to create a statically or dynamically linked executable:
390
391 @quotation
392 This program is released under the GPL with the additional exemption
393 that compiling, linking, and/or using OpenSSL is allowed.  You may
394 provide binary packages linked to the OpenSSL libraries, provided that
395 all other requirements of the GPL are met.
396 @end quotation
397
398 Since the LZO library used by tinc is also covered by the GPL,
399 we also present the following exemption:
400
401 @quotation
402 Hereby I grant a special exception to the tinc VPN project
403 (http://www.tinc-vpn.org/) to link the LZO library with the OpenSSL library
404 (http://www.openssl.org).
405
406 Markus F.X.J. Oberhumer
407 @end quotation
408
409
410 @c ==================================================================
411 @node       zlib
412 @subsection zlib
413
414 @cindex zlib
415 For the optional compression of UDP packets, tinc uses the functions provided
416 by the zlib library.
417
418 If this library is not installed, you wil get an error when configuring
419 tinc for build.  Support for running tinc without having zlib
420 installed @emph{may} be added in the future.
421
422 You can use your operating system's package manager to install this if
423 available.  Make sure you install the development AND runtime versions
424 of this package.
425
426 If you have to install zlib manually, you can get the source code
427 from @url{http://www.gzip.org/zlib/}.  Instructions on how to configure,
428 build and install this package are included within the package.  Please
429 make sure you build development and runtime libraries (which is the
430 default).
431
432
433 @c ==================================================================
434 @node       lzo
435 @subsection lzo
436
437 @cindex lzo
438 Another form of compression is offered using the lzo library.
439
440 If this library is not installed, you wil get an error when configuring
441 tinc for build.  Support for running tinc without having lzo
442 installed @emph{may} be added in the future.
443
444 You can use your operating system's package manager to install this if
445 available.  Make sure you install the development AND runtime versions
446 of this package.
447
448 If you have to install lzo manually, you can get the source code
449 from @url{http://www.oberhumer.com/opensource/lzo/}.  Instructions on how to configure,
450 build and install this package are included within the package.  Please
451 make sure you build development and runtime libraries (which is the
452 default).
453
454
455 @c ==================================================================
456 @node       libevent
457 @subsection libevent
458
459 @cindex libevent
460 For the main event loop, tinc uses the libevent library.
461
462 If this library is not installed, you wil get an error when configuring
463 tinc for build.
464
465 You can use your operating system's package manager to install this if
466 available.  Make sure you install the development AND runtime versions
467 of this package.
468
469 If you have to install libevent manually, you can get the source code
470 from @url{http://libevent.org/}. Instructions on how to configure,
471 build and install this package are included within the package.  Please
472 make sure you build development and runtime libraries (which is the
473 default).
474
475
476 @c
477 @c
478 @c
479 @c      Installing tinc
480 @c
481 @c
482 @c
483 @c
484
485 @c ==================================================================
486 @node    Installation
487 @chapter Installation
488
489 If you use Debian, you may want to install one of the
490 precompiled packages for your system.  These packages are equipped with
491 system startup scripts and sample configurations.
492
493 If you cannot use one of the precompiled packages, or you want to compile tinc
494 for yourself, you can use the source.  The source is distributed under
495 the GNU General Public License (GPL).  Download the source from the
496 @uref{http://www.tinc-vpn.org/download/, download page}, which has
497 the checksums of these files listed; you may wish to check these with
498 md5sum before continuing.
499
500 Tinc comes in a convenient autoconf/automake package, which you can just
501 treat the same as any other package.  Which is just untar it, type
502 `./configure' and then `make'.
503 More detailed instructions are in the file @file{INSTALL}, which is
504 included in the source distribution.
505
506 @menu
507 * Building and installing tinc::
508 * System files::
509 @end menu
510
511
512 @c ==================================================================
513 @node    Building and installing tinc
514 @section Building and installing tinc
515
516 Detailed instructions on configuring the source, building tinc and installing tinc
517 can be found in the file called @file{INSTALL}.
518
519 @cindex binary package
520 If you happen to have a binary package for tinc for your distribution,
521 you can use the package management tools of that distribution to install tinc.
522 The documentation that comes along with your distribution will tell you how to do that.
523
524 @menu
525 * Darwin (MacOS/X) build environment::
526 * Cygwin (Windows) build environment::
527 * MinGW (Windows) build environment::
528 @end menu
529
530
531 @c ==================================================================
532 @node       Darwin (MacOS/X) build environment
533 @subsection Darwin (MacOS/X) build environment
534
535 In order to build tinc on Darwin, you need to install the MacOS/X Developer Tools
536 from @uref{http://developer.apple.com/tools/macosxtools.html} and
537 a recent version of Fink from @uref{http://www.finkproject.org/}.
538
539 After installation use fink to download and install the following packages:
540 autoconf25, automake, dlcompat, m4, openssl, zlib and lzo.
541
542 @c ==================================================================
543 @node       Cygwin (Windows) build environment
544 @subsection Cygwin (Windows) build environment
545
546 If Cygwin hasn't already been installed, install it directly from
547 @uref{http://www.cygwin.com/}.
548
549 When tinc is compiled in a Cygwin environment, it can only be run in this environment,
550 but all programs, including those started outside the Cygwin environment, will be able to use the VPN.
551 It will also support all features.
552
553 @c ==================================================================
554 @node       MinGW (Windows) build environment
555 @subsection MinGW (Windows) build environment
556
557 You will need to install the MinGW environment from @uref{http://www.mingw.org}.
558
559 When tinc is compiled using MinGW it runs natively under Windows,
560 it is not necessary to keep MinGW installed.
561
562 When detaching, tinc will install itself as a service,
563 which will be restarted automatically after reboots.
564
565
566 @c ==================================================================
567 @node    System files
568 @section System files
569
570 Before you can run tinc, you must make sure you have all the needed
571 files on your system.
572
573 @menu
574 * Device files::
575 * Other files::
576 @end menu
577
578
579 @c ==================================================================
580 @node       Device files
581 @subsection Device files
582
583 @cindex device files
584 Most operating systems nowadays come with the necessary device files by default,
585 or they have a mechanism to create them on demand.
586
587 If you use Linux and do not have udev installed,
588 you may need to create the following device file if it does not exist:
589
590 @example
591 mknod -m 600 /dev/net/tun c 10 200
592 @end example
593
594
595 @c ==================================================================
596 @node       Other files
597 @subsection Other files
598
599 @subsubheading @file{/etc/networks}
600
601 You may add a line to @file{/etc/networks} so that your VPN will get a
602 symbolic name.  For example:
603
604 @example
605 myvpn 10.0.0.0
606 @end example
607
608 @subsubheading @file{/etc/services}
609
610 @cindex port numbers
611 You may add this line to @file{/etc/services}.  The effect is that you
612 may supply a @samp{tinc} as a valid port number to some programs.  The
613 number 655 is registered with the IANA.
614
615 @example
616 tinc            655/tcp    TINC
617 tinc            655/udp    TINC
618 #                          Ivo Timmermans <ivo@@tinc-vpn.org>
619 @end example
620
621
622 @c
623 @c
624 @c
625 @c
626 @c         Configuring tinc
627 @c
628 @c
629 @c
630 @c
631
632
633 @c ==================================================================
634 @node    Configuration
635 @chapter Configuration
636
637 @menu
638 * Configuration introduction::
639 * Multiple networks::
640 * How connections work::
641 * Configuration files::
642 * Network interfaces::
643 * Example configuration::
644 @end menu
645
646 @c ==================================================================
647 @node    Configuration introduction
648 @section Configuration introduction
649
650 Before actually starting to configure tinc and editing files,
651 make sure you have read this entire section so you know what to expect.
652 Then, make it clear to yourself how you want to organize your VPN:
653 What are the nodes (computers running tinc)?
654 What IP addresses/subnets do they have?
655 What is the network mask of the entire VPN?
656 Do you need special firewall rules?
657 Do you have to set up masquerading or forwarding rules?
658 Do you want to run tinc in router mode or switch mode?
659 These questions can only be answered by yourself,
660 you will not find the answers in this documentation.
661 Make sure you have an adequate understanding of networks in general.
662 @cindex Network Administrators Guide
663 A good resource on networking is the
664 @uref{http://www.tldp.org/LDP/nag2/, Linux Network Administrators Guide}.
665
666 If you have everything clearly pictured in your mind,
667 proceed in the following order:
668 First, create the initial configuration files and public/private keypairs using the following command:
669 @example
670 tincctl -n @var{NETNAME} init @var{NAME}
671 @end example
672 Second, use @samp{tincctl -n @var{NETNAME} config ...} to further configure tinc.
673 Finally, export your host configuration file using @samp{tincctl -n @var{NETNAME} export} and send it to those
674 people or computers you want tinc to connect to.
675 They should send you their host configuration file back, which you can import using @samp{tincctl -n @var{NETNAME} import}.
676
677 These steps are described in the subsections below.
678
679
680 @c ==================================================================
681 @node    Multiple networks
682 @section Multiple networks
683
684 @cindex multiple networks
685 @cindex netname
686
687 In order to allow you to run more than one tinc daemon on one computer,
688 for instance if your computer is part of more than one VPN,
689 you can assign a @var{netname} to your VPN.
690 It is not required if you only run one tinc daemon,
691 it doesn't even have to be the same on all the nodes of your VPN,
692 but it is recommended that you choose one anyway.
693
694 We will asume you use a netname throughout this document.
695 This means that you call tincctl with the -n argument,
696 which will specify the netname.
697
698 The effect of this option is that tinc will set its configuration
699 root to @file{@value{sysconfdir}/tinc/@var{netname}/}, where @var{netname} is your argument to the -n option.
700 You will also notice that log messages it appears in syslog as coming from @file{tinc.@var{netname}},
701 and on Linux, unless specified otherwise, the name of the virtual network interface will be the same as the network name.
702
703 However, it is not strictly necessary that you call tinc with the -n
704 option. If you don not use it, the network name will just be empty, and
705 tinc will look for files in @file{@value{sysconfdir}/tinc/} instead of
706 @file{@value{sysconfdir}/tinc/@var{netname}/};
707 the configuration file will then be @file{@value{sysconfdir}/tinc/tinc.conf},
708 and the host configuration files are expected to be in @file{@value{sysconfdir}/tinc/hosts/}.
709
710
711 @c ==================================================================
712 @node    How connections work
713 @section How connections work
714
715 When tinc starts up, it parses the command-line options and then
716 reads in the configuration file tinc.conf.
717 If it sees one or more  `ConnectTo' values pointing to other tinc daemons in that file,
718 it will try to connect to those other daemons.
719 Whether this succeeds or not and whether `ConnectTo' is specified or not,
720 tinc will listen for incoming connection from other deamons.
721 If you did specify a `ConnectTo' value and the other side is not responding,
722 tinc will keep retrying.
723 This means that once started, tinc will stay running until you tell it to stop,
724 and failures to connect to other tinc daemons will not stop your tinc daemon
725 for trying again later.
726 This means you don't have to intervene if there are temporary network problems.
727
728 @cindex client
729 @cindex server
730 There is no real distinction between a server and a client in tinc.
731 If you wish, you can view a tinc daemon without a `ConnectTo' value as a server,
732 and one which does specify such a value as a client.
733 It does not matter if two tinc daemons have a `ConnectTo' value pointing to each other however.
734
735 Connections specified using `ConnectTo' are so-called meta-connections.
736 Tinc daemons exchange information about all other daemon they know about via these meta-connections.
737 After learning about all the daemons in the VPN,
738 tinc will create other connections as necessary in order to communicate with them.
739 For example, if there are three daemons named A, B and C, and A has @samp{ConnectTo = B} in its tinc.conf file,
740 and C has @samp{ConnectTo = B} in its tinc.conf file, then A will learn about C from B,
741 and will be able to exchange VPN packets with C without the need to have @samp{ConnectTo = C} in its tinc.conf file.
742
743 It could be that some daemons are located behind a Network Address Translation (NAT) device, or behind a firewall.
744 In the above scenario with three daemons, if A and C are behind a NAT,
745 B will automatically help A and C punch holes through their NAT,
746 in a way similar to the STUN protocol, so that A and C can still communicate with each other directly.
747 It is not always possible to do this however, and firewalls might also prevent direct communication.
748 In that case, VPN packets between A and C will be forwarded by B.
749
750 In effect, all nodes in the VPN will be able to talk to each other, as long as
751 their is a path of meta-connections between them, and whenever possible, two
752 nodes will communicate with each other directly.
753
754
755 @c ==================================================================
756 @node    Configuration files
757 @section Configuration files
758
759 The actual configuration of the daemon is done in the file
760 @file{@value{sysconfdir}/tinc/@var{netname}/tinc.conf} and at least one other file in the directory
761 @file{@value{sysconfdir}/tinc/@var{netname}/hosts/}.
762
763 These file consists of comments (lines started with a #) or assignments
764 in the form of
765
766 @example
767 Variable = Value.
768 @end example
769
770 The variable names are case insensitive, and any spaces, tabs, newlines
771 and carriage returns are ignored.  Note: it is not required that you put
772 in the `=' sign, but doing so improves readability.  If you leave it
773 out, remember to replace it with at least one space character.
774
775 The server configuration is complemented with host specific configuration (see
776 the next section). Although all host configuration options for the local node
777 listed in this document can also be put in
778 @file{@value{sysconfdir}/tinc/@var{netname}/tinc.conf}, it is recommended to
779 put host specific configuration options in the host configuration file, as this
780 makes it easy to exchange with other nodes.
781
782 You can edit the config file manually, but it is recommended that you use
783 tincctl to change configuration variables for you.
784
785 In the following two subsections all valid variables are listed in alphabetical order.
786 The default value is given between parentheses,
787 other comments are between square brackets.
788
789 @menu
790 * Main configuration variables::
791 * Host configuration variables::
792 * Scripts::
793 * How to configure::
794 @end menu
795
796
797 @c ==================================================================
798 @node       Main configuration variables
799 @subsection Main configuration variables
800
801 @table @asis
802 @cindex AddressFamily
803 @item AddressFamily = <ipv4|ipv6|any> (any)
804 This option affects the address family of listening and outgoing sockets.
805 If any is selected, then depending on the operating system
806 both IPv4 and IPv6 or just IPv6 listening sockets will be created.
807
808 @cindex AutoConnect
809 @item AutoConnect = <count> (0) [experimental]
810 If set to a non-zero value,
811 tinc will try to only have count meta connections to other nodes,
812 by automatically making or breaking connections to known nodes.
813 Higher values increase redundancy but also increase meta data overhead.
814 When using this option, a good value is 3.
815
816 @cindex BindToAddress
817 @item BindToAddress = <@var{address}> [<@var{port}>]
818 If your computer has more than one IPv4 or IPv6 address, tinc
819 will by default listen on all of them for incoming connections.
820 Multiple BindToAddress variables may be specified,
821 in which case listening sockets for each specified address are made.
822
823 If no @var{port} is specified, the socket will be bound to the port specified by the Port option,
824 or to port 655 if neither is given.
825 To only bind to a specific port but not to a specific address, use "*" for the @var{address}.
826
827 @cindex BindToInterface
828 @item BindToInterface = <@var{interface}> [experimental]
829 If you have more than one network interface in your computer, tinc will
830 by default listen on all of them for incoming connections.  It is
831 possible to bind tinc to a single interface like eth0 or ppp0 with this
832 variable.
833
834 This option may not work on all platforms.
835 Also, on some platforms it will not actually bind to an interface,
836 but rather to the address that the interface has at the moment a socket is created.
837
838 @cindex Broadcast
839 @item Broadcast = <no | mst | direct> (mst) [experimental]
840 This option selects the way broadcast packets are sent to other daemons.
841 @emph{NOTE: all nodes in a VPN must use the same Broadcast mode, otherwise routing loops can form.}
842
843 @table @asis
844 @item no
845 Broadcast packets are never sent to other nodes.
846
847 @item mst
848 Broadcast packets are sent and forwarded via the VPN's Minimum Spanning Tree.
849 This ensures broadcast packets reach all nodes.
850
851 @item direct
852 Broadcast packets are sent directly to all nodes that can be reached directly.
853 Broadcast packets received from other nodes are never forwarded.
854 If the IndirectData option is also set, broadcast packets will only be sent to nodes which we have a meta connection to.
855 @end table
856
857 @cindex ConnectTo
858 @item ConnectTo = <@var{name}>
859 Specifies which other tinc daemon to connect to on startup.
860 Multiple ConnectTo variables may be specified,
861 in which case outgoing connections to each specified tinc daemon are made.
862 The names should be known to this tinc daemon
863 (i.e., there should be a host configuration file for the name on the ConnectTo line).
864
865 If you don't specify a host with ConnectTo,
866 tinc won't try to connect to other daemons at all,
867 and will instead just listen for incoming connections.
868
869 @cindex DecrementTTL
870 @item DecrementTTL = <yes | no> (no) [experimental]
871 When enabled, tinc will decrement the Time To Live field in IPv4 packets, or the Hop Limit field in IPv6 packets,
872 before forwarding a received packet to the virtual network device or to another node,
873 and will drop packets that have a TTL value of zero,
874 in which case it will send an ICMP Time Exceeded packet back.
875
876 Do not use this option if you use switch mode and want to use IPv6.
877
878 @cindex Device
879 @item Device = <@var{device}> (@file{/dev/tap0}, @file{/dev/net/tun} or other depending on platform)
880 The virtual network device to use.
881 Tinc will automatically detect what kind of device it is.
882 Note that you can only use one device per daemon.
883 Under Windows, use @var{Interface} instead of @var{Device}.
884 Note that you can only use one device per daemon.
885 See also @ref{Device files}.
886
887 @cindex DeviceType
888 @item DeviceType = <@var{type}> (platform dependent)
889 The type of the virtual network device.
890 Tinc will normally automatically select the right type of tun/tap interface, and this option should not be used.
891 However, this option can be used to select one of the special interface types, if support for them is compiled in.
892
893 @table @asis
894 @cindex dummy
895 @item dummy
896 Use a dummy interface.
897 No packets are ever read or written to a virtual network device.
898 Useful for testing, or when setting up a node that only forwards packets for other nodes.
899
900 @cindex raw_socket
901 @item raw_socket
902 Open a raw socket, and bind it to a pre-existing
903 @var{Interface} (eth0 by default).
904 All packets are read from this interface.
905 Packets received for the local node are written to the raw socket.
906 However, at least on Linux, the operating system does not process IP packets destined for the local host.
907
908 @cindex multicast
909 @item multicast
910 Open a multicast UDP socket and bind it to the address and port (separated by spaces) and optionally a TTL value specified using @var{Device}.
911 Packets are read from and written to this multicast socket.
912 This can be used to connect to UML, QEMU or KVM instances listening on the same multicast address.
913 Do NOT connect multiple tinc daemons to the same multicast address, this will very likely cause routing loops.
914 Also note that this can cause decrypted VPN packets to be sent out on a real network if misconfigured.
915
916 @cindex UML
917 @item uml (not compiled in by default)
918 Create a UNIX socket with the filename specified by
919 @var{Device}, or @file{@value{localstatedir}/run/@var{netname}.umlsocket}
920 if not specified.
921 Tinc will wait for a User Mode Linux instance to connect to this socket.
922
923 @cindex VDE
924 @item vde (not compiled in by default)
925 Uses the libvdeplug library to connect to a Virtual Distributed Ethernet switch,
926 using the UNIX socket specified by
927 @var{Device}, or @file{@value{localstatedir}/run/vde.ctl}
928 if not specified.
929 @end table
930
931 Also, in case tinc does not seem to correctly interpret packets received from the virtual network device,
932 it can be used to change the way packets are interpreted:
933
934 @table @asis
935 @item tun (BSD and Linux)
936 Set type to tun.
937 Depending on the platform, this can either be with or without an address family header (see below).
938
939 @cindex tunnohead
940 @item tunnohead (BSD)
941 Set type to tun without an address family header.
942 Tinc will expect packets read from the virtual network device to start with an IP header.
943 On some platforms IPv6 packets cannot be read from or written to the device in this mode.
944
945 @cindex tunifhead
946 @item tunifhead (BSD)
947 Set type to tun with an address family header.
948 Tinc will expect packets read from the virtual network device
949 to start with a four byte header containing the address family,
950 followed by an IP header.
951 This mode should support both IPv4 and IPv6 packets.
952
953 @item tap (BSD and Linux)
954 Set type to tap.
955 Tinc will expect packets read from the virtual network device
956 to start with an Ethernet header.
957 @end table
958
959 @cindex DirectOnly
960 @item DirectOnly = <yes|no> (no) [experimental]
961 When this option is enabled, packets that cannot be sent directly to the destination node,
962 but which would have to be forwarded by an intermediate node, are dropped instead.
963 When combined with the IndirectData option,
964 packets for nodes for which we do not have a meta connection with are also dropped.
965
966 @cindex ECDSAPrivateKeyFile
967 @item ECDSAPrivateKeyFile = <@var{path}> (@file{@value{sysconfdir}/tinc/@var{netname}/ecdsa_key.priv})
968 The file in which the private ECDSA key of this tinc daemon resides.
969 This is only used if ExperimentalProtocol is enabled.
970
971 @cindex ExperimentalProtocol
972 @item ExperimentalProtocol = <yes|no> (no) [experimental]
973 When this option is enabled, experimental protocol enhancements will be used.
974 Ephemeral ECDH will be used for key exchanges,
975 and ECDSA will be used instead of RSA for authentication.
976 When enabled, an ECDSA key must have been generated before with
977 @samp{tincctl generate-ecdsa-keys}.
978 The experimental protocol may change at any time,
979 and there is no guarantee that tinc will run stable when it is used.
980
981 @cindex Forwarding
982 @item Forwarding = <off|internal|kernel> (internal) [experimental]
983 This option selects the way indirect packets are forwarded.
984
985 @table @asis
986 @item off
987 Incoming packets that are not meant for the local node,
988 but which should be forwarded to another node, are dropped.
989
990 @item internal
991 Incoming packets that are meant for another node are forwarded by tinc internally.
992
993 This is the default mode, and unless you really know you need another forwarding mode, don't change it.
994
995 @item kernel
996 Incoming packets are always sent to the TUN/TAP device, even if the packets are not for the local node.
997 This is less efficient, but allows the kernel to apply its routing and firewall rules on them,
998 and can also help debugging.
999 @end table
1000
1001 @cindex GraphDumpFile
1002 @item GraphDumpFile = <@var{filename}>
1003 If this option is present,
1004 tinc will dump the current network graph to the file @var{filename}
1005 every minute, unless there were no changes to the graph.
1006 The file is in a format that can be read by graphviz tools.
1007 If @var{filename} starts with a pipe symbol |,
1008 then the rest of the filename is interpreted as a shell command
1009 that is executed, the graph is then sent to stdin.
1010
1011 @cindex Hostnames
1012 @item Hostnames = <yes|no> (no)
1013 This option selects whether IP addresses (both real and on the VPN)
1014 should be resolved.  Since DNS lookups are blocking, it might affect
1015 tinc's efficiency, even stopping the daemon for a few seconds everytime
1016 it does a lookup if your DNS server is not responding.
1017
1018 This does not affect resolving hostnames to IP addresses from the
1019 configuration file, but whether hostnames should be resolved while logging.
1020
1021 @cindex Interface
1022 @item Interface = <@var{interface}>
1023 Defines the name of the interface corresponding to the virtual network device.
1024 Depending on the operating system and the type of device this may or may not actually set the name of the interface.
1025 Under Windows, this variable is used to select which network interface will be used.
1026 If you specified a Device, this variable is almost always already correctly set.
1027
1028 @cindex LocalDiscovery
1029 @item LocalDiscovery = <yes | no> (no)
1030 When enabled, tinc will try to detect peers that are on the same local network.
1031 This will allow direct communication using LAN addresses, even if both peers are behind a NAT
1032 and they only ConnectTo a third node outside the NAT,
1033 which normally would prevent the peers from learning each other's LAN address.
1034
1035 Currently, local discovery is implemented by sending broadcast packets to the LAN during path MTU discovery.
1036 This feature may not work in all possible situations.
1037
1038 @cindex Mode
1039 @item Mode = <router|switch|hub> (router)
1040 This option selects the way packets are routed to other daemons.
1041
1042 @table @asis
1043 @cindex router
1044 @item router
1045 In this mode Subnet
1046 variables in the host configuration files will be used to form a routing table.
1047 Only unicast packets of routable protocols (IPv4 and IPv6) are supported in this mode.
1048
1049 This is the default mode, and unless you really know you need another mode, don't change it.
1050
1051 @cindex switch
1052 @item switch
1053 In this mode the MAC addresses of the packets on the VPN will be used to
1054 dynamically create a routing table just like an Ethernet switch does.
1055 Unicast, multicast and broadcast packets of every protocol that runs over Ethernet are supported in this mode
1056 at the cost of frequent broadcast ARP requests and routing table updates.
1057
1058 This mode is primarily useful if you want to bridge Ethernet segments.
1059
1060 @cindex hub
1061 @item hub
1062 This mode is almost the same as the switch mode, but instead
1063 every packet will be broadcast to the other daemons
1064 while no routing table is managed.
1065 @end table
1066
1067 @cindex KeyExpire
1068 @item KeyExpire = <@var{seconds}> (3600)
1069 This option controls the time the encryption keys used to encrypt the data
1070 are valid.  It is common practice to change keys at regular intervals to
1071 make it even harder for crackers, even though it is thought to be nearly
1072 impossible to crack a single key.
1073
1074 @cindex MACExpire
1075 @item MACExpire = <@var{seconds}> (600)
1076 This option controls the amount of time MAC addresses are kept before they are removed.
1077 This only has effect when Mode is set to "switch".
1078
1079 @cindex Name
1080 @item Name = <@var{name}> [required]
1081 This is a symbolic name for this connection.
1082 The name should consist only of alfanumeric and underscore characters (a-z, A-Z, 0-9 and _).
1083
1084 If Name starts with a $, then the contents of the environment variable that follows will be used.
1085 In that case, invalid characters will be converted to underscores.
1086 If Name is $HOST, but no such environment variable exist,
1087 the hostname will be read using the gethostnname() system call.
1088
1089 @cindex PingInterval
1090 @item PingInterval = <@var{seconds}> (60)
1091 The number of seconds of inactivity that tinc will wait before sending a
1092 probe to the other end.
1093
1094 @cindex PingTimeout
1095 @item PingTimeout = <@var{seconds}> (5)
1096 The number of seconds to wait for a response to pings or to allow meta
1097 connections to block. If the other end doesn't respond within this time,
1098 the connection is terminated, and the others will be notified of this.
1099
1100 @cindex PriorityInheritance
1101 @item PriorityInheritance = <yes|no> (no) [experimental]
1102 When this option is enabled the value of the TOS field of tunneled IPv4 packets
1103 will be inherited by the UDP packets that are sent out.
1104
1105 @cindex PrivateKey
1106 @item PrivateKey = <@var{key}> [obsolete]
1107 This is the RSA private key for tinc. However, for safety reasons it is
1108 advised to store private keys of any kind in separate files. This prevents
1109 accidental eavesdropping if you are editting the configuration file.
1110
1111 @cindex PrivateKeyFile
1112 @item PrivateKeyFile = <@var{path}> (@file{@value{sysconfdir}/tinc/@var{netname}/rsa_key.priv})
1113 This is the full path name of the RSA private key file that was
1114 generated by @samp{tincctl generate-keys}.  It must be a full path, not a
1115 relative directory.
1116
1117 Note that there must be exactly one of PrivateKey
1118 or PrivateKeyFile
1119 specified in the configuration file.
1120
1121 @cindex ProcessPriority
1122 @item ProcessPriority = <low|normal|high>
1123 When this option is used the priority of the tincd process will be adjusted.
1124 Increasing the priority may help to reduce latency and packet loss on the VPN.
1125
1126 @cindex Proxy
1127 @item Proxy = socks4 | socks4 | http | exec @var{...} [experimental]
1128 Use a proxy when making outgoing connections.
1129 The following proxy types are currently supported:
1130
1131 @table @asis
1132 @cindex socks4
1133 @item socks4 <@var{address}> <@var{port}> [<@var{username}>]
1134 Connects to the proxy using the SOCKS version 4 protocol.
1135 Optionally, a @var{username} can be supplied which will be passed on to the proxy server.
1136
1137 @cindex socks5
1138 @item socks4 <@var{address}> <@var{port}> [<@var{username}> <@var{password}>]
1139 Connect to the proxy using the SOCKS version 5 protocol.
1140 If a @var{username} and @var{password} are given, basic username/password authentication will be used,
1141 otherwise no authentication will be used.
1142
1143 @cindex http
1144 @item http <@var{address}> <@var{port}>
1145 Connects to the proxy and sends a HTTP CONNECT request.
1146
1147 @cindex exec
1148 @item exec <@var{command}>
1149 Executes the given command which should set up the outgoing connection.
1150 The environment variables @env{NAME}, @env{NODE}, @env{REMOTEADDRES} and @env{REMOTEPORT} are available.
1151 @end table
1152
1153 @cindex ReplayWindow
1154 @item ReplayWindow = <bytes> (16)
1155 This is the size of the replay tracking window for each remote node, in bytes.
1156 The window is a bitfield which tracks 1 packet per bit, so for example
1157 the default setting of 16 will track up to 128 packets in the window. In high
1158 bandwidth scenarios, setting this to a higher value can reduce packet loss from
1159 the interaction of replay tracking with underlying real packet loss and/or
1160 reordering. Setting this to zero will disable replay tracking completely and
1161 pass all traffic, but leaves tinc vulnerable to replay-based attacks on your
1162 traffic.
1163
1164
1165 @cindex StrictSubnets
1166 @item StrictSubnets <yes|no> (no) [experimental]
1167 When this option is enabled tinc will only use Subnet statements which are
1168 present in the host config files in the local
1169 @file{@value{sysconfdir}/tinc/@var{netname}/hosts/} directory.
1170
1171 @cindex TunnelServer
1172 @item TunnelServer = <yes|no> (no) [experimental]
1173 When this option is enabled tinc will no longer forward information between other tinc daemons,
1174 and will only allow connections with nodes for which host config files are present in the local
1175 @file{@value{sysconfdir}/tinc/@var{netname}/hosts/} directory.
1176 Setting this options also implicitly sets StrictSubnets.
1177
1178 @cindex UDPRcvBuf
1179 @item UDPRcvBuf = <bytes> (OS default)
1180 Sets the socket receive buffer size for the UDP socket, in bytes.
1181 If unset, the default buffer size will be used by the operating system.
1182
1183 @cindex UDPSndBuf
1184 @item UDPSndBuf = <bytes> Pq OS default
1185 Sets the socket send buffer size for the UDP socket, in bytes.
1186 If unset, the default buffer size will be used by the operating system.
1187
1188 @end table
1189
1190
1191 @c ==================================================================
1192 @node       Host configuration variables
1193 @subsection Host configuration variables
1194
1195 @table @asis
1196 @cindex Address
1197 @item Address = <@var{IP address}|@var{hostname}> [<port>] [recommended]
1198 This variable is only required if you want to connect to this host.  It
1199 must resolve to the external IP address where the host can be reached,
1200 not the one that is internal to the VPN.
1201 If no port is specified, the default Port is used.
1202
1203 @cindex Cipher
1204 @item Cipher = <@var{cipher}> (blowfish)
1205 The symmetric cipher algorithm used to encrypt UDP packets.
1206 Any cipher supported by OpenSSL is recognized.
1207 Furthermore, specifying "none" will turn off packet encryption.
1208 It is best to use only those ciphers which support CBC mode.
1209
1210 @cindex ClampMSS
1211 @item ClampMSS = <yes|no> (yes)
1212 This option specifies whether tinc should clamp the maximum segment size (MSS)
1213 of TCP packets to the path MTU. This helps in situations where ICMP
1214 Fragmentation Needed or Packet too Big messages are dropped by firewalls.
1215
1216 @cindex Compression
1217 @item Compression = <@var{level}> (0)
1218 This option sets the level of compression used for UDP packets.
1219 Possible values are 0 (off), 1 (fast zlib) and any integer up to 9 (best zlib),
1220 10 (fast lzo) and 11 (best lzo).
1221
1222 @cindex Digest
1223 @item Digest = <@var{digest}> (sha1)
1224 The digest algorithm used to authenticate UDP packets.
1225 Any digest supported by OpenSSL is recognized.
1226 Furthermore, specifying "none" will turn off packet authentication.
1227
1228 @cindex IndirectData
1229 @item IndirectData = <yes|no> (no)
1230 This option specifies whether other tinc daemons besides the one you
1231 specified with ConnectTo can make a direct connection to you.  This is
1232 especially useful if you are behind a firewall and it is impossible to
1233 make a connection from the outside to your tinc daemon.  Otherwise, it
1234 is best to leave this option out or set it to no.
1235
1236 @cindex MACLength
1237 @item MACLength = <@var{bytes}> (4)
1238 The length of the message authentication code used to authenticate UDP packets.
1239 Can be anything from 0
1240 up to the length of the digest produced by the digest algorithm.
1241
1242 @cindex PMTU
1243 @item PMTU = <@var{mtu}> (1514)
1244 This option controls the initial path MTU to this node.
1245
1246 @cindex PMTUDiscovery
1247 @item PMTUDiscovery = <yes|no> (yes)
1248 When this option is enabled, tinc will try to discover the path MTU to this node.
1249 After the path MTU has been discovered, it will be enforced on the VPN.
1250
1251 @cindex Port
1252 @item Port = <@var{port}> (655)
1253 This is the port this tinc daemon listens on.
1254 You can use decimal portnumbers or symbolic names (as listed in @file{/etc/services}).
1255
1256 @cindex PublicKey
1257 @item PublicKey = <@var{key}> [obsolete]
1258 This is the RSA public key for this host.
1259
1260 @cindex PublicKeyFile
1261 @item PublicKeyFile = <@var{path}> [obsolete]
1262 This is the full path name of the RSA public key file that was generated
1263 by @samp{tincctl generate-keys}.  It must be a full path, not a relative
1264 directory.
1265
1266 @cindex PEM format
1267 From version 1.0pre4 on tinc will store the public key directly into the
1268 host configuration file in PEM format, the above two options then are not
1269 necessary. Either the PEM format is used, or exactly
1270 @strong{one of the above two options} must be specified
1271 in each host configuration file, if you want to be able to establish a
1272 connection with that host.
1273
1274 @cindex Subnet
1275 @item Subnet = <@var{address}[/@var{prefixlength}[#@var{weight}]]>
1276 The subnet which this tinc daemon will serve.
1277 Tinc tries to look up which other daemon it should send a packet to by searching the appropiate subnet.
1278 If the packet matches a subnet,
1279 it will be sent to the daemon who has this subnet in his host configuration file.
1280 Multiple subnet lines can be specified for each daemon.
1281
1282 Subnets can either be single MAC, IPv4 or IPv6 addresses,
1283 in which case a subnet consisting of only that single address is assumed,
1284 or they can be a IPv4 or IPv6 network address with a prefixlength.
1285 For example, IPv4 subnets must be in a form like 192.168.1.0/24,
1286 where 192.168.1.0 is the network address and 24 is the number of bits set in the netmask.
1287 Note that subnets like 192.168.1.1/24 are invalid!
1288 Read a networking HOWTO/FAQ/guide if you don't understand this.
1289 IPv6 subnets are notated like fec0:0:0:1::/64.
1290 MAC addresses are notated like 0:1a:2b:3c:4d:5e.
1291
1292 @cindex CIDR notation
1293 Prefixlength is the number of bits set to 1 in the netmask part; for
1294 example: netmask 255.255.255.0 would become /24, 255.255.252.0 becomes
1295 /22. This conforms to standard CIDR notation as described in
1296 @uref{http://www.ietf.org/rfc/rfc1519.txt, RFC1519}
1297
1298 A Subnet can be given a weight to indicate its priority over identical Subnets
1299 owned by different nodes. The default weight is 10. Lower values indicate
1300 higher priority. Packets will be sent to the node with the highest priority,
1301 unless that node is not reachable, in which case the node with the next highest
1302 priority will be tried, and so on.
1303
1304 @cindex TCPonly
1305 @item TCPonly = <yes|no> (no)
1306 If this variable is set to yes, then the packets are tunnelled over a
1307 TCP connection instead of a UDP connection.  This is especially useful
1308 for those who want to run a tinc daemon from behind a masquerading
1309 firewall, or if UDP packet routing is disabled somehow.
1310 Setting this options also implicitly sets IndirectData.
1311 @end table
1312
1313
1314 @c ==================================================================
1315 @node       Scripts
1316 @subsection Scripts
1317
1318 @cindex scripts
1319 Apart from reading the server and host configuration files,
1320 tinc can also run scripts at certain moments.
1321 Under Windows (not Cygwin), the scripts should have the extension .bat.
1322
1323 @table @file
1324 @cindex tinc-up
1325 @item @value{sysconfdir}/tinc/@var{netname}/tinc-up
1326 This is the most important script.
1327 If it is present it will be executed right after the tinc daemon has been
1328 started and has connected to the virtual network device.
1329 It should be used to set up the corresponding network interface,
1330 but can also be used to start other things.
1331 Under Windows you can use the Network Connections control panel instead of creating this script.
1332
1333 @cindex tinc-down
1334 @item @value{sysconfdir}/tinc/@var{netname}/tinc-down
1335 This script is started right before the tinc daemon quits.
1336
1337 @item @value{sysconfdir}/tinc/@var{netname}/hosts/@var{host}-up
1338 This script is started when the tinc daemon with name @var{host} becomes reachable.
1339
1340 @item @value{sysconfdir}/tinc/@var{netname}/hosts/@var{host}-down
1341 This script is started when the tinc daemon with name @var{host} becomes unreachable.
1342
1343 @item @value{sysconfdir}/tinc/@var{netname}/host-up
1344 This script is started when any host becomes reachable.
1345
1346 @item @value{sysconfdir}/tinc/@var{netname}/host-down
1347 This script is started when any host becomes unreachable.
1348
1349 @item @value{sysconfdir}/tinc/@var{netname}/subnet-up
1350 This script is started when a Subnet becomes reachable.
1351 The Subnet and the node it belongs to are passed in environment variables.
1352
1353 @item @value{sysconfdir}/tinc/@var{netname}/subnet-down
1354 This script is started when a Subnet becomes unreachable.
1355 @end table
1356
1357 @cindex environment variables
1358 The scripts are started without command line arguments,
1359 but can make use of certain environment variables.
1360 Under UNIX like operating systems the names of environment variables must be preceded by a $ in scripts.
1361 Under Windows, in @file{.bat} files, they have to be put between % signs.
1362
1363 @table @env
1364 @cindex NETNAME
1365 @item NETNAME
1366 If a netname was specified, this environment variable contains it.
1367
1368 @cindex NAME
1369 @item NAME
1370 Contains the name of this tinc daemon.
1371
1372 @cindex DEVICE
1373 @item DEVICE
1374 Contains the name of the virtual network device that tinc uses.
1375
1376 @cindex INTERFACE
1377 @item INTERFACE
1378 Contains the name of the virtual network interface that tinc uses.
1379 This should be used for commands like ifconfig.
1380
1381 @cindex NODE
1382 @item NODE
1383 When a host becomes (un)reachable, this is set to its name.
1384 If a subnet becomes (un)reachable, this is set to the owner of that subnet.
1385
1386 @cindex REMOTEADDRESS
1387 @item REMOTEADDRESS
1388 When a host becomes (un)reachable, this is set to its real address.
1389
1390 @cindex REMOTEPORT
1391 @item REMOTEPORT
1392 When a host becomes (un)reachable,
1393 this is set to the port number it uses for communication with other tinc daemons.
1394
1395 @cindex SUBNET
1396 @item SUBNET
1397 When a subnet becomes (un)reachable, this is set to the subnet.
1398
1399 @end table
1400
1401
1402 @c ==================================================================
1403 @node       How to configure
1404 @subsection How to configure
1405
1406 @subsubheading Step 1.  Creating initial configuration files.
1407
1408 The initial directory structure, configuration files and public/private keypairs are created using the following command:
1409
1410 @example
1411 tincctl -n @var{netname} init @var{name}
1412 @end example
1413
1414 (You will need to run this as root, or use "sudo".)
1415 This will create the configuration directory @file{@value{sysconfdir}/tinc/@var{netname}.},
1416 and inside it will create another directory named @file{hosts/}.
1417 In the configuration directory, it will create the file @file{tinc.conf} with the following contents:
1418
1419 @example
1420 Name = @var{name}
1421 @end example
1422
1423 It will also create private RSA and ECDSA keys, which will be stored in the files @file{rsa_key.priv} and @file{ecdsa_key.priv}.
1424 It will also create a host configuration file @file{hosts/@var{name}},
1425 which will contain the corresponding public RSA and ECDSA keys.
1426
1427 Finally, on UNIX operating systems, it will create an executable script @file{tinc-up},
1428 which will initially not do anything except warning that you should edit it.
1429
1430 @subsubheading Step 2.  Modifying the initial configuration.
1431
1432 Unless you want to use tinc in switch mode,
1433 you should now configure which range of addresses you will use on the VPN.
1434 Let's assume you will be part of a VPN which uses the address range 192.168.0.0/16,
1435 and you yourself have a smaller portion of that range: 192.168.2.0/24.
1436 Then you should run the following command:
1437
1438 @example
1439 tincctl -n @var{netname} config add subnet 192.168.2.0/24
1440 @end example
1441
1442 This will add a Subnet statement to your host configuration file.
1443 Try opening the file @file{@value{sysconfdir}/tinc/@var{netname}/hosts/@var{name}} in an editor.
1444 You should now see a file containing the public RSA and ECDSA keys (which looks like a bunch of random characters),
1445 and the following line at the bottom:
1446
1447 @example
1448 Subnet = 192.168.2.0/24
1449 @end example
1450
1451 If you will use more than one address range, you can add more Subnets.
1452 For example, if you also use the IPv6 subnet fec0:0:0:2::/64, you can add it as well:
1453
1454 @example
1455 tincctl -n @var{netname} config add subnet fec0:0:0:2::/24
1456 @end example
1457
1458 This will add another line to the file @file{hosts/@var{name}}.
1459 If you make a mistake, you can undo it by simply using @samp{config del} instead of @samp{config add}.
1460
1461 If you want other tinc daemons to create meta-connections to your daemon,
1462 you should add your public IP address or hostname to your host configuration file.
1463 For example, if your hostname is foo.example.org, run:
1464
1465 @example
1466 tincctl -n @var{netname} config add address foo.example.org
1467 @end example
1468
1469 If you already know to which daemons your daemon should make meta-connections,
1470 you should configure that now as well.
1471 Suppose you want to connect to a daemon named "bar", run:
1472
1473 @example
1474 tincctl -n @var{netname} config add connectto bar
1475 @end example
1476
1477 Note that you specify the Name of the other daemon here, not an IP address or hostname!
1478 When you start tinc, and it tries to make a connection to "bar",
1479 it will look for a host configuration file named @file{hosts/bar},
1480 and will read Address statements and public keys from that file.
1481
1482 @subsubheading Step 2.  Exchanging configuration files.
1483
1484 If your daemon has a ConnectTo = bar statement in its @file{tinc.conf} file,
1485 or if bar has a ConnectTo your daemon, then you both need each other's host configuration files.
1486 You should send @file{hosts/@var{name}} to bar, and bar should send you his file which you should move to @file{hosts/bar}.
1487 If you are on a UNIX platform, you can easily send an email containing the necessary information using the following command
1488 (assuming the owner of bar has the email address bar@@example.org):
1489
1490 @example
1491 tincctl -n @var{netname} export | mail -s "My config file" bar@@example.org
1492 @end example
1493
1494 If the owner of bar does the same to send his host configuration file to you,
1495 you can probably pipe his email through the following command,
1496 or you can just start this command in a terminal and copy&paste the email:
1497
1498 @example
1499 tincctl -n @var{netname} import
1500 @end example
1501
1502 If you are the owner of bar yourself, and you have SSH access to that computer,
1503 you can also swap the host configuration files using the following commands:
1504
1505 @example
1506 tincctl -n @var{netname} export | ssh bar.example.org tincctl -n @var{netname} import
1507 ssh bar.example.org tincctl -n @var{netname} export | tincctl -n @var{netname} import
1508 @end example
1509
1510 You should repeat this for all nodes you ConnectTo, or which ConnectTo you.
1511 However, remember that you do not need to ConnectTo all nodes in the VPN;
1512 it is only necessary to create one or a few meta-connections,
1513 after the connections are made tinc will learn about all the other nodes in the VPN,
1514 and will automatically make other connections as necessary.
1515
1516
1517 @c ==================================================================
1518 @node    Network interfaces
1519 @section Network interfaces
1520
1521 Before tinc can start transmitting data over the tunnel, it must
1522 set up the virtual network interface.
1523
1524 First, decide which IP addresses you want to have associated with these
1525 devices, and what network mask they must have.
1526
1527 Tinc will open a virtual network device (@file{/dev/tun}, @file{/dev/tap0} or similar),
1528 which will also create a network interface called something like @samp{tun0}, @samp{tap0}.
1529 If you are using the Linux tun/tap driver, the network interface will by default have the same name as the @var{netname}.
1530 Under Windows you can change the name of the network interface from the Network Connections control panel.
1531
1532 @cindex tinc-up
1533 You can configure the network interface by putting ordinary ifconfig, route, and other commands
1534 to a script named @file{@value{sysconfdir}/tinc/@var{netname}/tinc-up}.
1535 When tinc starts, this script will be executed. When tinc exits, it will execute the script named
1536 @file{@value{sysconfdir}/tinc/@var{netname}/tinc-down}, but normally you don't need to create that script.
1537 You can manually open the script in an editor, or use the following command:
1538
1539 @example
1540 tincctl -n @var{netname} edit tinc-up
1541 @end example
1542
1543 An example @file{tinc-up} script, that would be appropriate for the scenario in the previous section, is:
1544
1545 @example
1546 #!/bin/sh
1547 ifconfig $INTERFACE 192.168.2.1 netmask 255.255.0.0
1548 ip addr add fec0:0:0:2::/48 dev $INTERFACE
1549 @end example
1550
1551 The first command gives the interface an IPv4 address and a netmask.
1552 The kernel will also automatically add an IPv4 route to this interface, so normally you don't need
1553 to add route commands to the @file{tinc-up} script.
1554 The kernel will also bring the interface up after this command.
1555 @cindex netmask
1556 The netmask is the mask of the @emph{entire} VPN network, not just your
1557 own subnet.
1558 The second command gives the interface an IPv6 address and netmask,
1559 which will also automatically add an IPv6 route.
1560 If you only want to use "ip addr" commands on Linux, don't forget that it doesn't bring the interface up, unlike ifconfig,
1561 so you need to add @samp{ip link set $INTERFACE up} in that case.
1562
1563 The exact syntax of the ifconfig and route commands differs from platform to platform.
1564 You can look up the commands for setting addresses and adding routes in @ref{Platform specific information},
1565 but it is best to consult the manpages of those utilities on your platform.
1566
1567
1568 @c ==================================================================
1569 @node    Example configuration
1570 @section Example configuration
1571
1572
1573 @cindex example
1574 Imagine the following situation.  Branch A of our example `company' wants to connect
1575 three branch offices in B, C and D using the Internet.  All four offices
1576 have a 24/7 connection to the Internet.
1577
1578 A is going to serve as the center of the network.  B and C will connect
1579 to A, and D will connect to C.  Each office will be assigned their own IP
1580 network, 10.x.0.0.
1581
1582 @example
1583 A: net 10.1.0.0 mask 255.255.0.0 gateway 10.1.54.1 internet IP 1.2.3.4
1584 B: net 10.2.0.0 mask 255.255.0.0 gateway 10.2.1.12 internet IP 2.3.4.5
1585 C: net 10.3.0.0 mask 255.255.0.0 gateway 10.3.69.254 internet IP 3.4.5.6
1586 D: net 10.4.0.0 mask 255.255.0.0 gateway 10.4.3.32 internet IP 4.5.6.7
1587 @end example
1588
1589 Here, ``gateway'' is the VPN IP address of the machine that is running the
1590 tincd, and ``internet IP'' is the IP address of the firewall, which does not
1591 need to run tincd, but it must do a port forwarding of TCP and UDP on port
1592 655 (unless otherwise configured).
1593
1594 In this example, it is assumed that eth0 is the interface that points to
1595 the inner (physical) LAN of the office, although this could also be the
1596 same as the interface that leads to the Internet.  The configuration of
1597 the real interface is also shown as a comment, to give you an idea of
1598 how these example host is set up. All branches use the netname `company'
1599 for this particular VPN.
1600
1601 Each branch is set up using the @samp{tincctl init} and @samp{tincctl config} commands,
1602 here we just show the end results:
1603
1604 @subsubheading For Branch A
1605
1606 @emph{BranchA} would be configured like this:
1607
1608 In @file{@value{sysconfdir}/tinc/company/tinc-up}:
1609
1610 @example
1611 #!/bin/sh
1612
1613 # Real interface of internal network:
1614 # ifconfig eth0 10.1.54.1 netmask 255.255.0.0
1615
1616 ifconfig $INTERFACE 10.1.54.1 netmask 255.0.0.0
1617 @end example
1618
1619 and in @file{@value{sysconfdir}/tinc/company/tinc.conf}:
1620
1621 @example
1622 Name = BranchA
1623 @end example
1624
1625 On all hosts, @file{@value{sysconfdir}/tinc/company/hosts/BranchA} contains:
1626
1627 @example
1628 Subnet = 10.1.0.0/16
1629 Address = 1.2.3.4
1630
1631 -----BEGIN RSA PUBLIC KEY-----
1632 ...
1633 -----END RSA PUBLIC KEY-----
1634 @end example
1635
1636 Note that the IP addresses of eth0 and the VPN interface are the same.
1637 This is quite possible, if you make sure that the netmasks of the interfaces are different.
1638 It is in fact recommended to give both real internal network interfaces and VPN interfaces the same IP address,
1639 since that will make things a lot easier to remember and set up.
1640
1641
1642 @subsubheading For Branch B
1643
1644 In @file{@value{sysconfdir}/tinc/company/tinc-up}:
1645
1646 @example
1647 #!/bin/sh
1648
1649 # Real interface of internal network:
1650 # ifconfig eth0 10.2.43.8 netmask 255.255.0.0
1651
1652 ifconfig $INTERFACE 10.2.1.12 netmask 255.0.0.0
1653 @end example
1654
1655 and in @file{@value{sysconfdir}/tinc/company/tinc.conf}:
1656
1657 @example
1658 Name = BranchB
1659 ConnectTo = BranchA
1660 @end example
1661
1662 Note here that the internal address (on eth0) doesn't have to be the
1663 same as on the VPN interface.  Also, ConnectTo is given so that this node will
1664 always try to connect to BranchA.
1665
1666 On all hosts, in @file{@value{sysconfdir}/tinc/company/hosts/BranchB}:
1667
1668 @example
1669 Subnet = 10.2.0.0/16
1670 Address = 2.3.4.5
1671
1672 -----BEGIN RSA PUBLIC KEY-----
1673 ...
1674 -----END RSA PUBLIC KEY-----
1675 @end example
1676
1677
1678 @subsubheading For Branch C
1679
1680 In @file{@value{sysconfdir}/tinc/company/tinc-up}:
1681
1682 @example
1683 #!/bin/sh
1684
1685 # Real interface of internal network:
1686 # ifconfig eth0 10.3.69.254 netmask 255.255.0.0
1687
1688 ifconfig $INTERFACE 10.3.69.254 netmask 255.0.0.0
1689 @end example
1690
1691 and in @file{@value{sysconfdir}/tinc/company/tinc.conf}:
1692
1693 @example
1694 Name = BranchC
1695 ConnectTo = BranchA
1696 @end example
1697
1698 C already has another daemon that runs on port 655, so they have to
1699 reserve another port for tinc. It knows the portnumber it has to listen on
1700 from it's own host configuration file.
1701
1702 On all hosts, in @file{@value{sysconfdir}/tinc/company/hosts/BranchC}:
1703
1704 @example
1705 Address = 3.4.5.6
1706 Subnet = 10.3.0.0/16
1707 Port = 2000
1708
1709 -----BEGIN RSA PUBLIC KEY-----
1710 ...
1711 -----END RSA PUBLIC KEY-----
1712 @end example
1713
1714
1715 @subsubheading For Branch D
1716
1717 In @file{@value{sysconfdir}/tinc/company/tinc-up}:
1718
1719 @example
1720 #!/bin/sh
1721
1722 # Real interface of internal network:
1723 # ifconfig eth0 10.4.3.32 netmask 255.255.0.0
1724
1725 ifconfig $INTERFACE 10.4.3.32 netmask 255.0.0.0
1726 @end example
1727
1728 and in @file{@value{sysconfdir}/tinc/company/tinc.conf}:
1729
1730 @example
1731 Name = BranchD
1732 ConnectTo = BranchC
1733 @end example
1734
1735 D will be connecting to C, which has a tincd running for this network on
1736 port 2000. It knows the port number from the host configuration file.
1737
1738 On all hosts, in @file{@value{sysconfdir}/tinc/company/hosts/BranchD}:
1739
1740 @example
1741 Subnet = 10.4.0.0/16
1742 Address = 4.5.6.7
1743
1744 -----BEGIN RSA PUBLIC KEY-----
1745 ...
1746 -----END RSA PUBLIC KEY-----
1747 @end example
1748
1749 @subsubheading Key files
1750
1751 A, B, C and D all have their own public/private keypairs:
1752
1753 The private RSA key is stored in @file{@value{sysconfdir}/tinc/company/rsa_key.priv},
1754 the private ECDSA key is stored in @file{@value{sysconfdir}/tinc/company/ecdsa_key.priv},
1755 and the public RSA and ECDSA keys are put into the host configuration file in the @file{@value{sysconfdir}/tinc/company/hosts/} directory.
1756
1757 @subsubheading Starting
1758
1759 After each branch has finished configuration and they have distributed
1760 the host configuration files amongst them, they can start their tinc daemons.
1761 They don't necessarily have to wait for the other branches to have started
1762 their daemons, tinc will try connecting until they are available.
1763
1764
1765 @c ==================================================================
1766 @node    Running tinc
1767 @chapter Running tinc
1768
1769 If everything else is done, you can start tinc by typing the following command:
1770
1771 @example
1772 tincctl -n @var{netname} start
1773 @end example
1774
1775 @cindex daemon
1776 Tinc will detach from the terminal and continue to run in the background like a good daemon.
1777 If there are any problems however you can try to increase the debug level
1778 and look in the syslog to find out what the problems are.
1779
1780 @menu
1781 * Runtime options::
1782 * Signals::
1783 * Debug levels::
1784 * Solving problems::
1785 * Error messages::
1786 * Sending bug reports::
1787 @end menu
1788
1789
1790 @c ==================================================================
1791 @node    Runtime options
1792 @section Runtime options
1793
1794 Besides the settings in the configuration file, tinc also accepts some
1795 command line options.
1796
1797 @cindex command line
1798 @cindex runtime options
1799 @cindex options
1800 @c from the manpage
1801 @table @option
1802 @item -c, --config=@var{path}
1803 Read configuration options from the directory @var{path}.  The default is
1804 @file{@value{sysconfdir}/tinc/@var{netname}/}.
1805
1806 @item -D, --no-detach
1807 Don't fork and detach.
1808 This will also disable the automatic restart mechanism for fatal errors.
1809
1810 @cindex debug level
1811 @item -d, --debug=@var{level}
1812 Set debug level to @var{level}.  The higher the debug level, the more gets
1813 logged.  Everything goes via syslog.
1814
1815 @item -n, --net=@var{netname}
1816 Use configuration for net @var{netname}.
1817 This will let tinc read all configuration files from
1818 @file{@value{sysconfdir}/tinc/@var{netname}/}.
1819 Specifying . for @var{netname} is the same as not specifying any @var{netname}.
1820 @xref{Multiple networks}.
1821
1822 @item --pidfile=@var{filename}
1823 Store a cookie in @var{filename} which allows tincctl to authenticate.
1824 If unspecified, the default is
1825 @file{@value{localstatedir}/run/tinc.@var{netname}.pid}.
1826
1827 @item -o, --option=[@var{HOST}.]@var{KEY}=@var{VALUE}
1828 Without specifying a @var{HOST}, this will set server configuration variable @var{KEY} to @var{VALUE}.
1829 If specified as @var{HOST}.@var{KEY}=@var{VALUE},
1830 this will set the host configuration variable @var{KEY} of the host named @var{HOST} to @var{VALUE}.
1831 This option can be used more than once to specify multiple configuration variables.
1832
1833 @item -L, --mlock
1834 Lock tinc into main memory.
1835 This will prevent sensitive data like shared private keys to be written to the system swap files/partitions.
1836
1837 @item --logfile[=@var{file}]
1838 Write log entries to a file instead of to the system logging facility.
1839 If @var{file} is omitted, the default is @file{@value{localstatedir}/log/tinc.@var{netname}.log}.
1840
1841 @item --bypass-security
1842 Disables encryption and authentication.
1843 Only useful for debugging.
1844
1845 @item -R, --chroot
1846 Change process root directory to the directory where the config file is
1847 located (@file{@value{sysconfdir}/tinc/@var{netname}/} as determined by
1848 -n/--net option or as given by -c/--config option), for added security.
1849 The chroot is performed after all the initialization is done, after
1850 writing pid files and opening network sockets.
1851
1852 Note that this option alone does not do any good without -U/--user, below.
1853
1854 Note also that tinc can't run scripts anymore (such as tinc-down or host-up),
1855 unless it's setup to be runnable inside chroot environment.
1856
1857 @item -U, --user=@var{user}
1858 Switch to the given @var{user} after initialization, at the same time as
1859 chroot is performed (see --chroot above).  With this option tinc drops
1860 privileges, for added security.
1861
1862 @item --help
1863 Display a short reminder of these runtime options and terminate.
1864
1865 @item --version
1866 Output version information and exit.
1867
1868 @end table
1869
1870 @c ==================================================================
1871 @node    Signals
1872 @section Signals
1873
1874 @cindex signals
1875 You can also send the following signals to a running tincd process:
1876
1877 @c from the manpage
1878 @table @samp
1879
1880 @item ALRM
1881 Forces tinc to try to connect to all uplinks immediately.
1882 Usually tinc attempts to do this itself,
1883 but increases the time it waits between the attempts each time it failed,
1884 and if tinc didn't succeed to connect to an uplink the first time after it started,
1885 it defaults to the maximum time of 15 minutes.
1886
1887 @item HUP
1888 Partially rereads configuration files.
1889 Connections to hosts whose host config file are removed are closed.
1890 New outgoing connections specified in @file{tinc.conf} will be made.
1891 If the --logfile option is used, this will also close and reopen the log file,
1892 useful when log rotation is used.
1893
1894 @end table
1895
1896 @c ==================================================================
1897 @node    Debug levels
1898 @section Debug levels
1899
1900 @cindex debug levels
1901 The tinc daemon can send a lot of messages to the syslog.
1902 The higher the debug level, the more messages it will log.
1903 Each level inherits all messages of the previous level:
1904
1905 @c from the manpage
1906 @table @samp
1907
1908 @item 0
1909 This will log a message indicating tinc has started along with a version number.
1910 It will also log any serious error.
1911
1912 @item 1
1913 This will log all connections that are made with other tinc daemons.
1914
1915 @item 2
1916 This will log status and error messages from scripts and other tinc daemons.
1917
1918 @item 3
1919 This will log all requests that are exchanged with other tinc daemons. These include
1920 authentication, key exchange and connection list updates.
1921
1922 @item 4
1923 This will log a copy of everything received on the meta socket.
1924
1925 @item 5
1926 This will log all network traffic over the virtual private network.
1927
1928 @end table
1929
1930 @c ==================================================================
1931 @node    Solving problems
1932 @section Solving problems
1933
1934 If tinc starts without problems, but if the VPN doesn't work, you will have to find the cause of the problem.
1935 The first thing to do is to start tinc with a high debug level in the foreground,
1936 so you can directly see everything tinc logs:
1937
1938 @example
1939 tincd -n @var{netname} -d5 -D
1940 @end example
1941
1942 If tinc does not log any error messages, then you might want to check the following things:
1943
1944 @itemize
1945 @item @file{tinc-up} script
1946 Does this script contain the right commands?
1947 Normally you must give the interface the address of this host on the VPN, and the netmask must be big enough so that the entire VPN is covered.
1948
1949 @item Subnet
1950 Does the Subnet (or Subnets) in the host configuration file of this host match the portion of the VPN that belongs to this host?
1951
1952 @item Firewalls and NATs
1953 Do you have a firewall or a NAT device (a masquerading firewall or perhaps an ADSL router that performs masquerading)?
1954 If so, check that it allows TCP and UDP traffic on port 655.
1955 If it masquerades and the host running tinc is behind it, make sure that it forwards TCP and UDP traffic to port 655 to the host running tinc.
1956 You can add @samp{TCPOnly = yes} to your host config file to force tinc to only use a single TCP connection,
1957 this works through most firewalls and NATs.
1958
1959 @end itemize
1960
1961
1962 @c ==================================================================
1963 @node    Error messages
1964 @section Error messages
1965
1966 What follows is a list of the most common error messages you might find in the logs.
1967 Some of them will only be visible if the debug level is high enough.
1968
1969 @table @samp
1970 @item Could not open /dev/tap0: No such device
1971
1972 @itemize
1973 @item You forgot to `modprobe netlink_dev' or `modprobe ethertap'.
1974 @item You forgot to compile `Netlink device emulation' in the kernel.
1975 @end itemize
1976
1977 @item Can't write to /dev/net/tun: No such device
1978
1979 @itemize
1980 @item You forgot to `modprobe tun'.
1981 @item You forgot to compile `Universal TUN/TAP driver' in the kernel.
1982 @item The tun device is located somewhere else in @file{/dev/}.
1983 @end itemize
1984
1985 @item Network address and prefix length do not match!
1986
1987 @itemize
1988 @item The Subnet field must contain a @emph{network} address, trailing bits should be 0.
1989 @item If you only want to use one IP address, set the netmask to /32.
1990 @end itemize
1991
1992 @item Error reading RSA key file `rsa_key.priv': No such file or directory
1993
1994 @itemize
1995 @item You forgot to create a public/private keypair.
1996 @item Specify the complete pathname to the private key file with the @samp{PrivateKeyFile} option.
1997 @end itemize
1998
1999 @item Warning: insecure file permissions for RSA private key file `rsa_key.priv'!
2000
2001 @itemize
2002 @item The private key file is readable by users other than root.
2003 Use chmod to correct the file permissions.
2004 @end itemize
2005
2006 @item Creating metasocket failed: Address family not supported
2007
2008 @itemize
2009 @item By default tinc tries to create both IPv4 and IPv6 sockets.
2010 On some platforms this might not be implemented.
2011 If the logs show @samp{Ready} later on, then at least one metasocket was created,
2012 and you can ignore this message.
2013 You can add @samp{AddressFamily = ipv4} to @file{tinc.conf} to prevent this from happening.
2014 @end itemize
2015
2016 @item Cannot route packet: unknown IPv4 destination 1.2.3.4
2017
2018 @itemize
2019 @item You try to send traffic to a host on the VPN for which no Subnet is known.
2020 @item If it is a broadcast address (ending in .255), it probably is a samba server or a Windows host sending broadcast packets.
2021 You can ignore it.
2022 @end itemize
2023
2024 @item Cannot route packet: ARP request for unknown address 1.2.3.4
2025
2026 @itemize
2027 @item You try to send traffic to a host on the VPN for which no Subnet is known.
2028 @end itemize
2029
2030 @item Packet with destination 1.2.3.4 is looping back to us!
2031
2032 @itemize
2033 @item Something is not configured right. Packets are being sent out to the
2034 virtual network device, but according to the Subnet directives in your host configuration
2035 file, those packets should go to your own host. Most common mistake is that
2036 you have a Subnet line in your host configuration file with a prefix length which is
2037 just as large as the prefix of the virtual network interface. The latter should in almost all
2038 cases be larger. Rethink your configuration.
2039 Note that you will only see this message if you specified a debug
2040 level of 5 or higher!
2041 @item Chances are that a @samp{Subnet = ...} line in the host configuration file of this tinc daemon is wrong.
2042 Change it to a subnet that is accepted locally by another interface,
2043 or if that is not the case, try changing the prefix length into /32. 
2044 @end itemize
2045
2046 @item Node foo (1.2.3.4) is not reachable
2047
2048 @itemize
2049 @item Node foo does not have a connection anymore, its tinc daemon is not running or its connection to the Internet is broken.
2050 @end itemize
2051
2052 @item Received UDP packet from unknown source 1.2.3.4 (port 12345)
2053
2054 @itemize
2055 @item If you see this only sporadically, it is harmless and caused by a node sending packets using an old key.
2056 @item If you see this often and another node is not reachable anymore, then a NAT (masquerading firewall) is changing the source address of UDP packets.
2057 You can add @samp{TCPOnly = yes} to host configuration files to force all VPN traffic to go over a TCP connection.
2058 @end itemize
2059
2060 @item Got bad/bogus/unauthorized REQUEST from foo (1.2.3.4 port 12345)
2061
2062 @itemize
2063 @item Node foo does not have the right public/private keypair.
2064 Generate new keypairs and distribute them again.
2065 @item An attacker tries to gain access to your VPN.
2066 @item A network error caused corruption of metadata sent from foo.
2067 @end itemize
2068
2069 @end table
2070
2071 @c ==================================================================
2072 @node    Sending bug reports
2073 @section Sending bug reports
2074
2075 If you really can't find the cause of a problem, or if you suspect tinc is not working right,
2076 you can send us a bugreport, see @ref{Contact information}.
2077 Be sure to include the following information in your bugreport:
2078
2079 @itemize
2080 @item A clear description of what you are trying to achieve and what the problem is.
2081 @item What platform (operating system, version, hardware architecture) and which version of tinc you use.
2082 @item If compiling tinc fails, a copy of @file{config.log} and the error messages you get.
2083 @item Otherwise, a copy of @file{tinc.conf}, @file{tinc-up} and all files in the @file{hosts/} directory.
2084 @item The output of the commands @samp{ifconfig -a} and @samp{route -n} (or @samp{netstat -rn} if that doesn't work).
2085 @item The output of any command that fails to work as it should (like ping or traceroute).
2086 @end itemize
2087
2088 @c ==================================================================
2089 @node    Controlling tinc
2090 @chapter Controlling tinc
2091
2092 You can control and inspect a running tincd through the tincctl
2093 command. A quick example:
2094
2095 @example
2096 tincctl -n @var{netname} reload
2097 @end example
2098
2099 @menu
2100 * tincctl runtime options::
2101 * tincctl environment variables::
2102 * tincctl commands::
2103 * tincctl examples::
2104 * tincctl top::
2105 @end menu
2106
2107
2108 @c ==================================================================
2109 @node    tincctl runtime options
2110 @section tincctl runtime options
2111
2112 @c from the manpage
2113 @table @option
2114 @item -c, --config=@var{path}
2115 Read configuration options from the directory @var{path}.  The default is
2116 @file{@value{sysconfdir}/tinc/@var{netname}/}.
2117
2118 @item -n, --net=@var{netname}
2119 Use configuration for net @var{netname}. @xref{Multiple networks}.
2120
2121 @item --pidfile=@var{filename}
2122 Use the cookie from @var{filename} to authenticate with a running tinc daemon.
2123 If unspecified, the default is
2124 @file{@value{localstatedir}/run/tinc.@var{netname}.pid}.
2125
2126 @item --help
2127 Display a short reminder of runtime options and commands, then terminate.
2128
2129 @item --version
2130 Output version information and exit.
2131
2132 @end table
2133
2134 @c ==================================================================
2135 @node    tincctl environment variables
2136 @section tincctl environment variables
2137
2138 @table @env
2139 @cindex NETNAME
2140 @item NETNAME
2141 If no netname is specified on the command line with the @option{-n} option,
2142 the value of this environment variable is used.
2143 @end table
2144
2145 @c ==================================================================
2146 @node    tincctl commands
2147 @section tincctl commands
2148
2149 @c from the manpage
2150 @table @code
2151
2152 @item init [@var{name}]
2153 Create initial configuration files and RSA and ECDSA keypairs with default length.
2154 If no @var{name} for this node is given, it will be asked for.
2155
2156 @item config [get] @var{variable}
2157 Print the current value of configuration variable @var{variable}.
2158 If more than one variable with the same name exists,
2159 the value of each of them will be printed on a separate line.
2160
2161 @item config [set] @var{variable} @var{value}
2162 Set configuration variable @var{variable} to the given @var{value}.
2163 All previously existing configuration variables with the same name are removed.
2164 To set a variable for a specific host, use the notation @var{host}.@var{variable}.
2165
2166 @item config add @var{variable} @var{value}
2167 As above, but without removing any previously existing configuration variables.
2168
2169 @item config del @var{variable} [@var{value}]
2170 Remove configuration variables with the same name and @var{value}.
2171 If no @var{value} is given, all configuration variables with the same name will be removed.
2172
2173 @item edit @var{filename}
2174 Start an editor for the given configuration file.
2175 You do not need to specify the full path to the file.
2176
2177 @item export
2178 Export the host configuration file of the local node to standard output.
2179
2180 @item export-all
2181 Export all host configuration files to standard output.
2182
2183 @item import [--force]
2184 Import host configuration file(s) from standard input.
2185 Already existing host configuration files are not overwritten unless the option --force is used.
2186
2187 @item start [tincd options]
2188 Start @samp{tincd}, optionally with the given extra options.
2189
2190 @item stop
2191 Stop @samp{tincd}.
2192
2193 @item restart
2194 Restart @samp{tincd}.
2195
2196 @item reload
2197 Partially rereads configuration files. Connections to hosts whose host
2198 config files are removed are closed. New outgoing connections specified
2199 in @file{tinc.conf} will be made.
2200
2201 @item pid
2202 Shows the PID of the currently running @samp{tincd}.
2203
2204 @item generate-keys [@var{bits}]
2205 Generate public/private keypair of @var{bits} length. If @var{bits} is not specified,
2206 1024 is the default. tinc will ask where you want to store the files,
2207 but will default to the configuration directory (you can use the -c or -n
2208 option).
2209
2210 @item dump nodes
2211 Dump a list of all known nodes in the VPN.
2212
2213 @item dump edges
2214 Dump a list of all known connections in the VPN.
2215
2216 @item dump subnets
2217 Dump a list of all known subnets in the VPN.
2218
2219 @item dump connections
2220 Dump a list of all meta connections with ourself.
2221
2222 @item dump graph | digraph
2223 Dump a graph of the VPN in dotty format.
2224 Nodes are colored according to their reachability:
2225 red nodes are unreachable, orange nodes are indirectly reachable, green nodes are directly reachable.
2226 Black nodes are either directly or indirectly reachable, but direct reachability has not been tried yet.
2227
2228 @item info @var{node} | @var{subnet} | @var{address}
2229 Show information about a particular @var{node}, @var{subnet} or @var{address}.
2230 If an @var{address} is given, any matching subnet will be shown.
2231
2232 @item purge
2233 Purges all information remembered about unreachable nodes.
2234
2235 @item debug @var{level}
2236 Sets debug level to @var{level}.
2237
2238 @item log [@var{level}]
2239 Capture log messages from a running tinc daemon.
2240 An optional debug level can be given that will be applied only for log messages sent to tincctl.
2241
2242 @item retry
2243 Forces tinc to try to connect to all uplinks immediately.
2244 Usually tinc attempts to do this itself,
2245 but increases the time it waits between the attempts each time it failed,
2246 and if tinc didn't succeed to connect to an uplink the first time after it started,
2247 it defaults to the maximum time of 15 minutes.
2248
2249 @item disconnect @var{node}
2250 Closes the meta connection with the given @var{node}.
2251
2252 @item top
2253 If tincctl is compiled with libcurses support, this will display live traffic statistics for all the known nodes,
2254 similar to the UNIX top command.
2255 See below for more information.
2256
2257 @item pcap
2258 Dump VPN traffic going through the local tinc node in pcap-savefile format to standard output,
2259 from where it can be redirected to a file or piped through a program that can parse it directly,
2260 such as tcpdump.
2261
2262 @end table
2263
2264 @c ==================================================================
2265 @node    tincctl examples
2266 @section tincctl examples
2267
2268 Examples of some commands:
2269
2270 @example
2271 tincctl -n vpn dump graph | circo -Txlib
2272 tincctl -n vpn pcap | tcpdump -r -
2273 tincctl -n vpn top
2274 @end example
2275
2276 Example of configuring tinc using tincctl:
2277
2278 @example
2279 tincctl -n vpn init foo
2280 tincctl -n vpn config Subnet 192.168.1.0/24
2281 tincctl -n vpn config bar.Address bar.example.com
2282 tincctl -n vpn config ConnectTo bar
2283 tincctl -n vpn export | gpg --clearsign | mail -s "My config" vpnmaster@@example.com
2284 @end example
2285
2286 @c ==================================================================
2287 @node    tincctl top
2288 @section tincctl top
2289
2290 The top command connects to a running tinc daemon and repeatedly queries its per-node traffic counters.
2291 It displays a list of all the known nodes in the left-most column,
2292 and the amount of bytes and packets read from and sent to each node in the other columns.
2293 By default, the information is updated every second.
2294 The behaviour of the top command can be changed using the following keys:
2295
2296 @table @key
2297
2298 @item s
2299 Change the interval between updates.
2300 After pressing the @key{s} key, enter the desired interval in seconds, followed by enter.
2301 Fractional seconds are honored.
2302 Intervals lower than 0.1 seconds are not allowed.
2303
2304 @item c
2305 Toggle between displaying current traffic rates (in packets and bytes per second)
2306 and cummulative traffic (total packets and bytes since the tinc daemon started).
2307
2308 @item n
2309 Sort the list of nodes by name.
2310
2311 @item i
2312 Sort the list of nodes by incoming amount of bytes.
2313
2314 @item I
2315 Sort the list of nodes by incoming amount of packets.
2316
2317 @item o
2318 Sort the list of nodes by outgoing amount of bytes.
2319
2320 @item O
2321 Sort the list of nodes by outgoing amount of packets.
2322
2323 @item t
2324 Sort the list of nodes by sum of incoming and outgoing amount of bytes.
2325
2326 @item T
2327 Sort the list of nodes by sum of incoming and outgoing amount of packets.
2328
2329 @item b
2330 Show amount of traffic in bytes.
2331
2332 @item k
2333 Show amount of traffic in kilobytes.
2334
2335 @item M
2336 Show amount of traffic in megabytes.
2337
2338 @item G
2339 Show amount of traffic in gigabytes.
2340
2341 @item q
2342 Quit.
2343
2344 @end table
2345
2346
2347 @c ==================================================================
2348 @node    Technical information
2349 @chapter Technical information
2350
2351
2352 @menu
2353 * The connection::
2354 * The meta-protocol::
2355 * Security::
2356 @end menu
2357
2358
2359 @c ==================================================================
2360 @node    The connection
2361 @section The connection
2362
2363 @cindex connection
2364 Tinc is a daemon that takes VPN data and transmit that to another host
2365 computer over the existing Internet infrastructure.
2366
2367 @menu
2368 * The UDP tunnel::
2369 * The meta-connection::
2370 @end menu
2371
2372
2373 @c ==================================================================
2374 @node    The UDP tunnel
2375 @subsection The UDP tunnel
2376
2377 @cindex virtual network device
2378 @cindex frame type
2379 The data itself is read from a character device file, the so-called
2380 @emph{virtual network device}.  This device is associated with a network
2381 interface.  Any data sent to this interface can be read from the device,
2382 and any data written to the device gets sent from the interface.
2383 There are two possible types of virtual network devices:
2384 `tun' style, which are point-to-point devices which can only handle IPv4 and/or IPv6 packets,
2385 and `tap' style, which are Ethernet devices and handle complete Ethernet frames.
2386
2387 So when tinc reads an Ethernet frame from the device, it determines its
2388 type. When tinc is in it's default routing mode, it can handle IPv4 and IPv6
2389 packets. Depending on the Subnet lines, it will send the packets off to their destination IP address.
2390 In the `switch' and `hub' mode, tinc will use broadcasts and MAC address discovery
2391 to deduce the destination of the packets.
2392 Since the latter modes only depend on the link layer information,
2393 any protocol that runs over Ethernet is supported (for instance IPX and Appletalk).
2394 However, only `tap' style devices provide this information.
2395
2396 After the destination has been determined,
2397 the packet will be compressed (optionally),
2398 a sequence number will be added to the packet,
2399 the packet will then be encrypted
2400 and a message authentication code will be appended.
2401
2402 @cindex encapsulating
2403 @cindex UDP
2404 When that is done, time has come to actually transport the
2405 packet to the destination computer.  We do this by sending the packet
2406 over an UDP connection to the destination host.  This is called
2407 @emph{encapsulating}, the VPN packet (though now encrypted) is
2408 encapsulated in another IP datagram.
2409
2410 When the destination receives this packet, the same thing happens, only
2411 in reverse.  So it checks the message authentication code, decrypts the contents of the UDP datagram,
2412 checks the sequence number
2413 and writes the decrypted information to its own virtual network device.
2414
2415 If the virtual network device is a `tun' device (a point-to-point tunnel),
2416 there is no problem for the kernel to accept a packet.
2417 However, if it is a `tap' device (this is the only available type on FreeBSD),
2418 the destination MAC address must match that of the virtual network interface.
2419 If tinc is in it's default routing mode, ARP does not work, so the correct destination MAC 
2420 can not be known by the sending host.
2421 Tinc solves this by letting the receiving end detect the MAC address of its own virtual network interface
2422 and overwriting the destination MAC address of the received packet.
2423
2424 In switch or hub modes ARP does work so the sender already knows the correct destination MAC address.
2425 In those modes every interface should have a unique MAC address, so make sure they are not the same.
2426 Because switch and hub modes rely on MAC addresses to function correctly,
2427 these modes cannot be used on the following operating systems which don't have a `tap' style virtual network device:
2428 OpenBSD, NetBSD, Darwin and Solaris.
2429
2430
2431 @c ==================================================================
2432 @node    The meta-connection
2433 @subsection The meta-connection
2434
2435 Having only a UDP connection available is not enough.  Though suitable
2436 for transmitting data, we want to be able to reliably send other
2437 information, such as routing and session key information to somebody.
2438
2439 @cindex TCP
2440 TCP is a better alternative, because it already contains protection
2441 against information being lost, unlike UDP.
2442
2443 So we establish two connections.  One for the encrypted VPN data, and one
2444 for other information, the meta-data.  Hence, we call the second
2445 connection the meta-connection.  We can now be sure that the
2446 meta-information doesn't get lost on the way to another computer.
2447
2448 @cindex data-protocol
2449 @cindex meta-protocol
2450 Like with any communication, we must have a protocol, so that everybody
2451 knows what everything stands for, and how she should react.  Because we
2452 have two connections, we also have two protocols.  The protocol used for
2453 the UDP data is the ``data-protocol,'' the other one is the
2454 ``meta-protocol.''
2455
2456 The reason we don't use TCP for both protocols is that UDP is much
2457 better for encapsulation, even while it is less reliable.  The real
2458 problem is that when TCP would be used to encapsulate a TCP stream
2459 that's on the private network, for every packet sent there would be
2460 three ACKs sent instead of just one.  Furthermore, if there would be
2461 a timeout, both TCP streams would sense the timeout, and both would
2462 start re-sending packets.
2463
2464
2465 @c ==================================================================
2466 @node    The meta-protocol
2467 @section The meta-protocol
2468
2469 The meta protocol is used to tie all tinc daemons together, and
2470 exchange information about which tinc daemon serves which virtual
2471 subnet.
2472
2473 The meta protocol consists of requests that can be sent to the other
2474 side.  Each request has a unique number and several parameters.  All
2475 requests are represented in the standard ASCII character set.  It is
2476 possible to use tools such as telnet or netcat to connect to a tinc
2477 daemon started with the --bypass-security option
2478 and to read and write requests by hand, provided that one
2479 understands the numeric codes sent.
2480
2481 The authentication scheme is described in @ref{Authentication protocol}. After a
2482 successful authentication, the server and the client will exchange all the
2483 information about other tinc daemons and subnets they know of, so that both
2484 sides (and all the other tinc daemons behind them) have their information
2485 synchronised.
2486
2487 @cindex ADD_EDGE
2488 @cindex ADD_SUBNET
2489 @example
2490 message
2491 ------------------------------------------------------------------
2492 ADD_EDGE node1 node2 21.32.43.54 655 222 0
2493           |     |        |       |   |  +-> options
2494           |     |        |       |   +----> weight
2495           |     |        |       +--------> UDP port of node2
2496           |     |        +----------------> real address of node2
2497           |     +-------------------------> name of destination node
2498           +-------------------------------> name of source node
2499
2500 ADD_SUBNET node 192.168.1.0/24
2501             |         |     +--> prefixlength
2502             |         +--------> network address
2503             +------------------> owner of this subnet
2504 ------------------------------------------------------------------
2505 @end example
2506
2507 The ADD_EDGE messages are to inform other tinc daemons that a connection between
2508 two nodes exist. The address of the destination node is available so that
2509 VPN packets can be sent directly to that node.
2510
2511 The ADD_SUBNET messages inform other tinc daemons that certain subnets belong
2512 to certain nodes. tinc will use it to determine to which node a VPN packet has
2513 to be sent.
2514
2515 @cindex DEL_EDGE
2516 @cindex DEL_SUBNET
2517 @example
2518 message
2519 ------------------------------------------------------------------
2520 DEL_EDGE node1 node2
2521            |     +----> name of destination node
2522            +----------> name of source node
2523
2524 DEL_SUBNET node 192.168.1.0/24
2525              |         |     +--> prefixlength
2526              |         +--------> network address
2527              +------------------> owner of this subnet
2528 ------------------------------------------------------------------
2529 @end example
2530
2531 In case a connection between two daemons is closed or broken, DEL_EDGE messages
2532 are sent to inform the other daemons of that fact. Each daemon will calculate a
2533 new route to the the daemons, or mark them unreachable if there isn't any.
2534
2535 @cindex REQ_KEY
2536 @cindex ANS_KEY
2537 @cindex KEY_CHANGED
2538 @example
2539 message
2540 ------------------------------------------------------------------
2541 REQ_KEY origin destination
2542            |       +--> name of the tinc daemon it wants the key from
2543            +----------> name of the daemon that wants the key      
2544
2545 ANS_KEY origin destination 4ae0b0a82d6e0078 91 64 4
2546            |       |       \______________/ |  |  +--> MAC length
2547            |       |               |        |  +-----> digest algorithm
2548            |       |               |        +--------> cipher algorithm
2549            |       |               +--> 128 bits key
2550            |       +--> name of the daemon that wants the key
2551            +----------> name of the daemon that uses this key
2552
2553 KEY_CHANGED origin
2554               +--> daemon that has changed it's packet key
2555 ------------------------------------------------------------------
2556 @end example
2557
2558 The keys used to encrypt VPN packets are not sent out directly. This is
2559 because it would generate a lot of traffic on VPNs with many daemons, and
2560 chances are that not every tinc daemon will ever send a packet to every
2561 other daemon. Instead, if a daemon needs a key it sends a request for it
2562 via the meta connection of the nearest hop in the direction of the
2563 destination.
2564
2565 @cindex PING
2566 @cindex PONG
2567 @example
2568 daemon  message
2569 ------------------------------------------------------------------
2570 origin  PING
2571 dest.   PONG
2572 ------------------------------------------------------------------
2573 @end example
2574
2575 There is also a mechanism to check if hosts are still alive. Since network
2576 failures or a crash can cause a daemon to be killed without properly
2577 shutting down the TCP connection, this is necessary to keep an up to date
2578 connection list. PINGs are sent at regular intervals, except when there
2579 is also some other traffic. A little bit of salt (random data) is added
2580 with each PING and PONG message, to make sure that long sequences of PING/PONG
2581 messages without any other traffic won't result in known plaintext.
2582
2583 This basically covers what is sent over the meta connection by tinc.
2584
2585
2586 @c ==================================================================
2587 @node    Security
2588 @section Security
2589
2590 @cindex TINC
2591 @cindex Cabal
2592 Tinc got its name from ``TINC,'' short for @emph{There Is No Cabal}; the
2593 alleged Cabal was/is an organisation that was said to keep an eye on the
2594 entire Internet.  As this is exactly what you @emph{don't} want, we named
2595 the tinc project after TINC.
2596
2597 @cindex SVPN
2598 But in order to be ``immune'' to eavesdropping, you'll have to encrypt
2599 your data.  Because tinc is a @emph{Secure} VPN (SVPN) daemon, it does
2600 exactly that: encrypt.
2601 Tinc by default uses blowfish encryption with 128 bit keys in CBC mode, 32 bit
2602 sequence numbers and 4 byte long message authentication codes to make sure
2603 eavesdroppers cannot get and cannot change any information at all from the
2604 packets they can intercept. The encryption algorithm and message authentication
2605 algorithm can be changed in the configuration. The length of the message
2606 authentication codes is also adjustable. The length of the key for the
2607 encryption algorithm is always the default length used by OpenSSL.
2608
2609 @menu
2610 * Authentication protocol::
2611 * Encryption of network packets::
2612 * Security issues::
2613 @end menu
2614
2615
2616 @c ==================================================================
2617 @node       Authentication protocol
2618 @subsection Authentication protocol
2619
2620 @cindex authentication
2621 A new scheme for authentication in tinc has been devised, which offers some
2622 improvements over the protocol used in 1.0pre2 and 1.0pre3. Explanation is
2623 below.
2624
2625 @cindex ID
2626 @cindex META_KEY
2627 @cindex CHALLENGE
2628 @cindex CHAL_REPLY
2629 @cindex ACK
2630 @example
2631 daemon  message
2632 --------------------------------------------------------------------------
2633 client  <attempts connection>
2634
2635 server  <accepts connection>
2636
2637 client  ID client 12
2638               |   +---> version
2639               +-------> name of tinc daemon
2640
2641 server  ID server 12
2642               |   +---> version
2643               +-------> name of tinc daemon
2644
2645 client  META_KEY 5f0823a93e35b69e...7086ec7866ce582b
2646                  \_________________________________/
2647                                  +-> RSAKEYLEN bits totally random string S1,
2648                                      encrypted with server's public RSA key
2649
2650 server  META_KEY 6ab9c1640388f8f0...45d1a07f8a672630
2651                  \_________________________________/
2652                                  +-> RSAKEYLEN bits totally random string S2,
2653                                      encrypted with client's public RSA key
2654
2655 From now on:
2656  - the client will symmetrically encrypt outgoing traffic using S1
2657  - the server will symmetrically encrypt outgoing traffic using S2
2658
2659 client  CHALLENGE da02add1817c1920989ba6ae2a49cecbda0
2660                   \_________________________________/
2661                                  +-> CHALLEN bits totally random string H1
2662
2663 server  CHALLENGE 57fb4b2ccd70d6bb35a64c142f47e61d57f
2664                   \_________________________________/
2665                                  +-> CHALLEN bits totally random string H2
2666
2667 client  CHAL_REPLY 816a86
2668                       +-> 160 bits SHA1 of H2
2669
2670 server  CHAL_REPLY 928ffe
2671                       +-> 160 bits SHA1 of H1
2672
2673 After the correct challenge replies are received, both ends have proved
2674 their identity. Further information is exchanged.
2675
2676 client  ACK 655 123 0
2677              |   |  +-> options
2678                  |   +----> estimated weight
2679                  +--------> listening port of client
2680
2681 server  ACK 655 321 0
2682              |   |  +-> options
2683                  |   +----> estimated weight
2684                  +--------> listening port of server
2685 --------------------------------------------------------------------------
2686 @end example
2687
2688 This new scheme has several improvements, both in efficiency and security.
2689
2690 First of all, the server sends exactly the same kind of messages over the wire
2691 as the client. The previous versions of tinc first authenticated the client,
2692 and then the server. This scheme even allows both sides to send their messages
2693 simultaneously, there is no need to wait for the other to send something first.
2694 This means that any calculations that need to be done upon sending or receiving
2695 a message can also be done in parallel. This is especially important when doing
2696 RSA encryption/decryption. Given that these calculations are the main part of
2697 the CPU time spent for the authentication, speed is improved by a factor 2.
2698
2699 Second, only one RSA encrypted message is sent instead of two. This reduces the
2700 amount of information attackers can see (and thus use for a cryptographic
2701 attack). It also improves speed by a factor two, making the total speedup a
2702 factor 4.
2703
2704 Third, and most important:
2705 The symmetric cipher keys are exchanged first, the challenge is done
2706 afterwards. In the previous authentication scheme, because a man-in-the-middle
2707 could pass the challenge/chal_reply phase (by just copying the messages between
2708 the two real tinc daemons), but no information was exchanged that was really
2709 needed to read the rest of the messages, the challenge/chal_reply phase was of
2710 no real use. The man-in-the-middle was only stopped by the fact that only after
2711 the ACK messages were encrypted with the symmetric cipher. Potentially, it
2712 could even send it's own symmetric key to the server (if it knew the server's
2713 public key) and read some of the metadata the server would send it (it was
2714 impossible for the mitm to read actual network packets though). The new scheme
2715 however prevents this.
2716
2717 This new scheme makes sure that first of all, symmetric keys are exchanged. The
2718 rest of the messages are then encrypted with the symmetric cipher. Then, each
2719 side can only read received messages if they have their private key. The
2720 challenge is there to let the other side know that the private key is really
2721 known, because a challenge reply can only be sent back if the challenge is
2722 decrypted correctly, and that can only be done with knowledge of the private
2723 key.
2724
2725 Fourth: the first thing that is sent via the symmetric cipher encrypted
2726 connection is a totally random string, so that there is no known plaintext (for
2727 an attacker) in the beginning of the encrypted stream.
2728
2729
2730 @c ==================================================================
2731 @node       Encryption of network packets
2732 @subsection Encryption of network packets
2733 @cindex encryption
2734
2735 A data packet can only be sent if the encryption key is known to both
2736 parties, and the connection is  activated. If the encryption key is not
2737 known, a request is sent to the destination using the meta connection
2738 to retrieve it. The packet is stored in a queue while waiting for the
2739 key to arrive.
2740
2741 @cindex UDP
2742 The UDP packet containing the network packet from the VPN has the following layout:
2743
2744 @example
2745 ... | IP header | UDP header | seqno | VPN packet | MAC | UDP trailer
2746                              \___________________/\_____/
2747                                        |             |
2748                                        V             +---> digest algorithm
2749                          Encrypted with symmetric cipher
2750 @end example
2751
2752 So, the entire VPN packet is encrypted using a symmetric cipher, including a 32 bits
2753 sequence number that is added in front of the actual VPN packet, to act as a unique
2754 IV for each packet and to prevent replay attacks. A message authentication code
2755 is added to the UDP packet to prevent alteration of packets. By default the
2756 first 4 bytes of the digest are used for this, but this can be changed using
2757 the MACLength configuration variable.
2758
2759 @c ==================================================================
2760 @node    Security issues
2761 @subsection Security issues
2762
2763 In August 2000, we discovered the existence of a security hole in all versions
2764 of tinc up to and including 1.0pre2. This had to do with the way we exchanged
2765 keys. Since then, we have been working on a new authentication scheme to make
2766 tinc as secure as possible. The current version uses the OpenSSL library and
2767 uses strong authentication with RSA keys.
2768
2769 On the 29th of December 2001, Jerome Etienne posted a security analysis of tinc
2770 1.0pre4. Due to a lack of sequence numbers and a message authentication code
2771 for each packet, an attacker could possibly disrupt certain network services or
2772 launch a denial of service attack by replaying intercepted packets. The current
2773 version adds sequence numbers and message authentication codes to prevent such
2774 attacks.
2775
2776 On the 15th of September 2003, Peter Gutmann posted a security analysis of tinc
2777 1.0.1. He argues that the 32 bit sequence number used by tinc is not a good IV,
2778 that tinc's default length of 4 bytes for the MAC is too short, and he doesn't
2779 like tinc's use of RSA during authentication. We do not know of a security hole
2780 in this version of tinc, but tinc's security is not as strong as TLS or IPsec.
2781 We will address these issues in tinc 2.0.
2782
2783 Cryptography is a hard thing to get right. We cannot make any
2784 guarantees. Time, review and feedback are the only things that can
2785 prove the security of any cryptographic product. If you wish to review
2786 tinc or give us feedback, you are stronly encouraged to do so.
2787
2788
2789 @c ==================================================================
2790 @node    Platform specific information
2791 @chapter Platform specific information
2792
2793 @menu
2794 * Interface configuration::
2795 * Routes::
2796 @end menu
2797
2798 @c ==================================================================
2799 @node    Interface configuration
2800 @section Interface configuration
2801
2802 When configuring an interface, one normally assigns it an address and a
2803 netmask.  The address uniquely identifies the host on the network attached to
2804 the interface.  The netmask, combined with the address, forms a subnet.  It is
2805 used to add a route to the routing table instructing the kernel to send all
2806 packets which fall into that subnet to that interface.  Because all packets for
2807 the entire VPN should go to the virtual network interface used by tinc, the
2808 netmask should be such that it encompasses the entire VPN.
2809
2810 For IPv4 addresses:
2811
2812 @multitable {Darwin (MacOS/X)} {ifconfig route add -bla network address netmask netmask prefixlength interface}
2813 @item Linux
2814 @tab @code{ifconfig} @var{interface} @var{address} @code{netmask} @var{netmask}
2815 @item Linux iproute2
2816 @tab @code{ip addr add} @var{address}@code{/}@var{prefixlength} @code{dev} @var{interface}
2817 @item FreeBSD
2818 @tab @code{ifconfig} @var{interface} @var{address} @code{netmask} @var{netmask}
2819 @item OpenBSD
2820 @tab @code{ifconfig} @var{interface} @var{address} @code{netmask} @var{netmask}
2821 @item NetBSD
2822 @tab @code{ifconfig} @var{interface} @var{address} @code{netmask} @var{netmask}
2823 @item Solaris
2824 @tab @code{ifconfig} @var{interface} @var{address} @code{netmask} @var{netmask}
2825 @item Darwin (MacOS/X)
2826 @tab @code{ifconfig} @var{interface} @var{address} @code{netmask} @var{netmask}
2827 @item Windows
2828 @tab @code{netsh interface ip set address} @var{interface} @code{static} @var{address} @var{netmask}
2829 @end multitable
2830
2831 For IPv6 addresses:
2832
2833 @multitable {Darwin (MacOS/X)} {ifconfig route add -bla network address netmask netmask prefixlength interface}
2834 @item Linux
2835 @tab @code{ifconfig} @var{interface} @code{add} @var{address}@code{/}@var{prefixlength}
2836 @item FreeBSD
2837 @tab @code{ifconfig} @var{interface} @code{inet6} @var{address} @code{prefixlen} @var{prefixlength}
2838 @item OpenBSD
2839 @tab @code{ifconfig} @var{interface} @code{inet6} @var{address} @code{prefixlen} @var{prefixlength}
2840 @item NetBSD
2841 @tab @code{ifconfig} @var{interface} @code{inet6} @var{address} @code{prefixlen} @var{prefixlength}
2842 @item Solaris
2843 @tab @code{ifconfig} @var{interface} @code{inet6 plumb up}
2844 @item
2845 @tab @code{ifconfig} @var{interface} @code{inet6 addif} @var{address} @var{address}
2846 @item Darwin (MacOS/X)
2847 @tab @code{ifconfig} @var{interface} @code{inet6} @var{address} @code{prefixlen} @var{prefixlength}
2848 @item Windows
2849 @tab @code{netsh interface ipv6 add address} @var{interface} @code{static} @var{address}/@var{prefixlength}
2850 @end multitable
2851
2852 On some platforms, when running tinc in switch mode, the VPN interface must be set to tap mode with an ifconfig command:
2853
2854 @multitable {Darwin (MacOS/X)} {ifconfig route add -bla network address netmask netmask prefixlength interface}
2855 @item OpenBSD
2856 @tab @code{ifconfig} @var{interface} @code{link0}
2857 @end multitable
2858
2859 On Linux, it is possible to create a persistent tun/tap interface which will
2860 continue to exist even if tinc quit, although this is normally not required.
2861 It can be useful to set up a tun/tap interface owned by a non-root user, so
2862 tinc can be started without needing any root privileges at all.
2863
2864 @multitable {Darwin (MacOS/X)} {ifconfig route add -bla network address netmask netmask prefixlength interface}
2865 @item Linux
2866 @tab @code{ip tuntap add dev} @var{interface} @code{mode} @var{tun|tap} @code{user} @var{username}
2867 @end multitable
2868
2869 @c ==================================================================
2870 @node    Routes
2871 @section Routes
2872
2873 In some cases it might be necessary to add more routes to the virtual network
2874 interface.  There are two ways to indicate which interface a packet should go
2875 to, one is to use the name of the interface itself, another way is to specify
2876 the (local) address that is assigned to that interface (@var{local_address}). The
2877 former way is unambiguous and therefore preferable, but not all platforms
2878 support this.
2879
2880 Adding routes to IPv4 subnets:
2881
2882 @multitable {Darwin (MacOS/X)} {ifconfig route add -bla network address netmask netmask prefixlength interface}
2883 @item Linux
2884 @tab @code{route add -net} @var{network_address} @code{netmask} @var{netmask} @var{interface}
2885 @item Linux iproute2
2886 @tab @code{ip route add} @var{network_address}@code{/}@var{prefixlength} @code{dev} @var{interface}
2887 @item FreeBSD
2888 @tab @code{route add} @var{network_address}@code{/}@var{prefixlength} @var{local_address}
2889 @item OpenBSD
2890 @tab @code{route add} @var{network_address}@code{/}@var{prefixlength} @var{local_address}
2891 @item NetBSD
2892 @tab @code{route add} @var{network_address}@code{/}@var{prefixlength} @var{local_address}
2893 @item Solaris
2894 @tab @code{route add} @var{network_address}@code{/}@var{prefixlength} @var{local_address} @code{-interface}
2895 @item Darwin (MacOS/X)
2896 @tab @code{route add} @var{network_address}@code{/}@var{prefixlength} @var{local_address}
2897 @item Windows
2898 @tab @code{netsh routing ip add persistentroute} @var{network_address} @var{netmask} @var{interface} @var{local_address}
2899 @end multitable
2900
2901 Adding routes to IPv6 subnets:
2902
2903 @multitable {Darwin (MacOS/X)} {ifconfig route add -bla network address netmask netmask prefixlength interface}
2904 @item Linux
2905 @tab @code{route add -A inet6} @var{network_address}@code{/}@var{prefixlength} @var{interface}
2906 @item Linux iproute2
2907 @tab @code{ip route add} @var{network_address}@code{/}@var{prefixlength} @code{dev} @var{interface}
2908 @item FreeBSD
2909 @tab @code{route add -inet6} @var{network_address}@code{/}@var{prefixlength} @var{local_address}
2910 @item OpenBSD
2911 @tab @code{route add -inet6} @var{network_address} @var{local_address} @code{-prefixlen} @var{prefixlength}
2912 @item NetBSD
2913 @tab @code{route add -inet6} @var{network_address} @var{local_address} @code{-prefixlen} @var{prefixlength}
2914 @item Solaris
2915 @tab @code{route add -inet6} @var{network_address}@code{/}@var{prefixlength} @var{local_address} @code{-interface}
2916 @item Darwin (MacOS/X)
2917 @tab ?
2918 @item Windows
2919 @tab @code{netsh interface ipv6 add route} @var{network address}/@var{prefixlength} @var{interface}
2920 @end multitable
2921
2922
2923 @c ==================================================================
2924 @node    About us
2925 @chapter About us
2926
2927
2928 @menu
2929 * Contact information::
2930 * Authors::
2931 @end menu
2932
2933
2934 @c ==================================================================
2935 @node    Contact information
2936 @section Contact information
2937
2938 @cindex website
2939 Tinc's website is at @url{http://www.tinc-vpn.org/},
2940 this server is located in the Netherlands.
2941
2942 @cindex IRC
2943 We have an IRC channel on the FreeNode and OFTC IRC networks. Connect to
2944 @uref{http://www.freenode.net/, irc.freenode.net}
2945 or
2946 @uref{http://www.oftc.net/, irc.oftc.net}
2947 and join channel #tinc.
2948
2949
2950 @c ==================================================================
2951 @node    Authors
2952 @section Authors
2953
2954 @table @asis
2955 @item Ivo Timmermans (zarq)
2956 @item Guus Sliepen (guus) (@email{guus@@tinc-vpn.org})
2957 @end table
2958
2959 We have received a lot of valuable input from users.  With their help,
2960 tinc has become the flexible and robust tool that it is today.  We have
2961 composed a list of contributions, in the file called @file{THANKS} in
2962 the source distribution.
2963
2964
2965 @c ==================================================================
2966 @node    Concept Index
2967 @unnumbered Concept Index
2968
2969 @c ==================================================================
2970 @printindex cp
2971
2972
2973 @c ==================================================================
2974 @contents
2975 @bye