Debian10.page 8.0 KB

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