Debian10.page 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  1. # Installation
  2. - Wird an anderer Stelle des Wiki beschrieben
  3. # Allgemein
  4. - Informationen auf dieser Seite sind teilweise von anderen Wiki-Seiten übernommen.
  5. Hier sollen die Schritte nach der Installation von Debian 10 (buster) zum Aufbau eines VPN mit Tinc und Bird beschrieben werden.
  6. Für die meisten Befehle sind root Rechte erforderlich.
  7. Es werden für alle Interfaces statische IPV4 Adressen verwendet, auf dem Laptop ist auch DHCP aktiv.
  8. Die hier verwendeten Adressen sind dem Wiki [IP-Adressen](IP-Adressen) für berghofen entnommen.
  9. # Hardware
  10. - APU mit Buster ohne grafische Oberfläche
  11. - Laptop mit Ubuntu 18.04
  12. berghofen, wie auch die anderen Standorte, bestehen jeweils mindesten aus der APU und einem Laptop sowie einem Internetrouter (F!Box).
  13. An jedem Standort gibt es mehrere Tincverbindungen:
  14. - lan: zwischen APU und Laptop
  15. - wan: zwischen APU und den anderen Standorten
  16. - wan: zwischen Laptop und den anderen Standorten
  17. # Software
  18. - Debian 10.7 (buster), auf dem Laptop Ubuntu 18.04
  19. - Tinc 1.1pre17 oder tinc 1.0.36
  20. - Bird 2.07
  21. # Dateien der APU
  22. /etc/network/interfaces
  23. # This file describes the network interfaces available on your system
  24. # and how to activate them. For more information, see interfaces(5).
  25. source /etc/network/interfaces.d/*
  26. # The loopback network interface
  27. auto lo
  28. iface lo inet loopback
  29. up ip addr add 193.43.220.130/32
  30. # The primary network interface
  31. allow-hotplug enp1s0
  32. iface enp1s0 inet static
  33. address 192.168.178.51/24
  34. #default gateway wird von bird erledigt
  35. # gateway 192.168.178.254
  36. broadcast 192.168.178.255
  37. # dns-* options are implemented by the resolvconf package, if installed
  38. dns-nameservers 192.168.178.254
  39. dns-search fritz.box
  40. up ip rule add from all iif enp1s0 lookup 1 prio 1000 || true
  41. up ip rule add from 192.168.178.0/24 lookup 1 prio 1010 || true
  42. allow-hotplug wan
  43. iface wan inet static
  44. address 193.43.220.162/27
  45. broadcast 193.43.220.191
  46. mtu 1504
  47. allow-hotplug lan
  48. iface lan inet static
  49. address 192.168.34.1/24
  50. broadcast 192.168.34.255
  51. mtu 1504
  52. #allow-hotplug wlp5s0 # wlan z.Zt. nicht verwendet
  53. #iface wlp5s0 inet dhcp
  54. Die Schnittstellen der Interfacesdatei sind:
  55. - lo Standardloopback
  56. - enp1s0 ethernet
  57. - wan virtuelle Tinc Schnittstelle
  58. - lan virtuelle Tinc Schnittstelle
  59. - wlp5s0 nicht verwendete, auskommentierte WLAN Schnittstelle
  60. Für die Datenweitergabe zwischen den Netzen ist der folgende Eintrag nötig.
  61. /etc/sysctl.conf
  62. # Uncomment the next line to enable packet forwarding for IPv4
  63. net.ipv4.ip_forward=1
  64. # Tinc Verzeichnistruktur Tinc APU und Laptop Einstellungen
  65. etc/tinc/
  66. |-- lan
  67. | |-- hosts
  68. | | |-- apu
  69. | | `-- laptop
  70. | |-- rsa_key.priv
  71. | |-- ed25519_key.priv ## nur bei tinc 1.1
  72. | `-- tinc.conf
  73. `-- wan
  74. |-- hosts
  75. | |-- berghofen ## berglap auf dem laptop
  76. | |-- hoerde
  77. | `-- nordstadt
  78. |-- rsa_key.priv
  79. |-- ed25519_key.priv ## nur bei tinc 1.1
  80. `-- tinc.conf
  81. /etc/tinc/lan/tinc.conf
  82. ## APU lan tinc.conf
  83. Name = apu
  84. Device = /dev/net/tun
  85. Mode = switch
  86. AddressFamily = ipv4
  87. BindToAddress = 192.168.178.51
  88. Port = 10001
  89. MaxTimeout = 30
  90. GraphDumpFile = /var/run/tinc.lan.dot
  91. ConnectTo = laptop
  92. /etc/tinc/wan/tinc.conf
  93. ## APU wan tinc.conf
  94. Name = berghofen
  95. Device = /dev/net/tun
  96. Mode = switch
  97. AddressFamily = ipv4
  98. BindToaddress = 192.168.178.51
  99. Port = 661
  100. MaxTimeout = 30
  101. GraphDumpFile = /var/run/tinc.wan.dot
  102. ConnectTo = hoerde
  103. ConnectTo = nordstadt
  104. /etc/tinc/lan/tinc.conf
  105. ## Laptop lan tinc.conf
  106. Name = laptop
  107. Device = /dev/net/tun
  108. Mode = switch
  109. AddressFamily = ipv4
  110. BindToAddress = 192.168.178.52
  111. Port = 10001
  112. MaxTimeout = 30
  113. GraphDumpFile = /var/run/tinc.lan.dot
  114. ConnectTo = apu
  115. /etc/tinc/wan/tinc.conf
  116. ## Laptop wan tinc.conf
  117. Name = berglap
  118. Device = /dev/net/tun
  119. Mode = switch
  120. AddressFamily = ipv4
  121. BindToaddress = 192.168.178.52
  122. Port = 661
  123. MaxTimeout = 30
  124. GraphDumpFile = /var/run/tinc.wan.dot
  125. ConnectTo = hoerde
  126. ConnectTo = nordstadt
  127. Inhalt der hosts Dateien
  128. Die Public und private Keys werden von Tinc erzeugt:
  129. bei tinc 1.0.36:
  130. tincd -n wan -K 4096
  131. tincd -n lan -K 4096
  132. bei tinc 1.1:
  133. tinc -n wan generate-keys 4096
  134. tinc -n lan generate-keys 4096
  135. Die ED25519PublicKey Zeile wird nur bei tinc 1.1 erzeugt/verwendet.
  136. /etc/tinc/lan/hosts/apu auf APU und laptop
  137. Address = 192.168.178.51
  138. Port = 10001
  139. -----BEGIN RSA PUBLIC KEY-----
  140. Schlüsseldaten
  141. -----END RSA PUBLIC KEY-----
  142. Ed25519PublicKey = WmAmMY95+B/A9FDQz7ZiV6WQcG2qAUUclRP52dwXSdD
  143. /etc/tinc/lan/hosts/laptop auf APU und laptop
  144. Address = 192.168.178.52
  145. Port = 10001
  146. -----BEGIN RSA PUBLIC KEY-----
  147. Schlüsseldaten
  148. -----END RSA PUBLIC KEY-----
  149. Ed25519PublicKey = WCkEAe/gohI7JAGLiHPKdE+ayxYrG1wuTfQQijAROuD
  150. /etc/tinc/wan/hosts/berghofen auf APU
  151. -----BEGIN RSA PUBLIC KEY-----
  152. Schlüsseldaten
  153. -----END RSA PUBLIC KEY-----
  154. Ed25519PublicKey = Tkhp7t+MsmQKsWIkO5qimTKoWdkvRigKwctxtfOu2MF
  155. /etc/tinc/wan/hosts/hoerde auf APU und berglap
  156. Address = 130.180.53.22
  157. Port = 661
  158. -----BEGIN RSA PUBLIC KEY-----
  159. Schlüsseldaten
  160. -----END RSA PUBLIC KEY-----
  161. Ed25519PublicKey = MjaltxtfPP1SdHgNH/dUuHmbYDXFdZMEUUbl0Qi/YCA
  162. /etc/tinc/wan/hosts/nordstadt auf APU und berglap
  163. Address = 91.204.4.53
  164. Port = 661
  165. -----BEGIN RSA PUBLIC KEY-----
  166. Schlüsseldaten
  167. -----END RSA PUBLIC KEY-----
  168. Ed25519PublicKey = 4znU87BKnctOFb+/JQhIltGtYN3h3czOVInolRPWgvA
  169. /etc/tinc/wan/hosts/berglap auf berglap
  170. -----BEGIN RSA PUBLIC KEY-----
  171. Schlüsseldaten
  172. -----END RSA PUBLIC KEY-----
  173. Ed25519PublicKey = 4znU87BKnctOFb+/JQhIltGtYN3h3czOVInolRPWgvA
  174. Die Tinc Instanzen können auf APU und berglap gestartet werden mit:
  175. systemctl start tinc@lan
  176. systemctl start tinc@wan
  177. Um die Programme automatisch nach einem reboot zu starten, eventuell
  178. falls nicht durch die Installation schon eingerichtet:
  179. systemctl enable tinc@lan
  180. systemctl enable tinc@wan
  181. # Bird auf der APU und berglap
  182. /etc/iproute2/rt_tables identisch auf APU / laptop
  183. #
  184. # reserved values
  185. #
  186. 255 local
  187. 254 main
  188. 253 default
  189. 0 unspec
  190. #
  191. # local
  192. #
  193. 1 tinc
  194. - Die bird.conf des laptops ist bis auf andere IP Adressen identisch
  195. /etc/bird/bird.conf
  196. router id 193.43.220.130; /* public IP APU */
  197. log syslog { debug, info, trace, remote }; /* optional */
  198. define AS35675_all = [
  199. 193.43.220.0/23
  200. ];
  201. define AS35675_any = [
  202. 193.43.220.0/23+
  203. ];
  204. protocol device device0 {
  205. scan time 10;
  206. }
  207. /* wg. BSD: */
  208. protocol direct direct0 {
  209. ipv4;
  210. }
  211. protocol kernel kernel0 {
  212. learn on;
  213. scan time 120;
  214. ipv4 {
  215. import all;
  216. export where source != RTS_DEVICE;
  217. };
  218. }
  219. # erstellt neue routing tabelle
  220. ipv4 table fib1table;
  221. #RTS route source
  222. #import / export
  223. protocol kernel kernel1 {
  224. kernel table 1;
  225. learn on;
  226. scan time 120;
  227. ipv4 {
  228. table fib1table;
  229. import all;
  230. export where source != RTS_DEVICE;
  231. };
  232. }
  233. protocol static static1 {
  234. ipv4 {
  235. table fib1table;
  236. };
  237. route 0.0.0.0/0 via 192.168.178.254; /* zur F!Box */
  238. }
  239. protocol ospf ospfwan {
  240. ipv4 {
  241. import all;
  242. export where net ~ AS35675_any;
  243. };
  244. area 0.0.0.0 {
  245. stubnet 193.43.220.130/32 { cost 1; };
  246. interface "wan" {
  247. type broadcast;
  248. cost 100;
  249. };
  250. interface "lan" {
  251. type broadcast;
  252. cost 10;
  253. };
  254. };
  255. }
  256. Den bird starten und eventuell rebootfest machen:
  257. systemctl start bird
  258. systemctl enable bird