tinc.texi 123 KB

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