tinc.texi 87 KB

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