123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389 |
- # Software
- - Debian 11 (bullseye), auf dem Laptop Ubuntu 18.04
- - Tinc 1.1pre17 oder tinc 1.0.36
- - Bird 2.07
- # Installation
- - Installation des Betriebssystems wird hier nicht beschrieben.
- - Hier werden die Schritte nach der Installation von Debian 11 (bullseye) zum Aufbau eines VPN mit Tinc und Bird beschrieben werden.
- - Für die meisten Befehle sind root Rechte erforderlich.
- - Tinc 1.0.36 und bird 2 können aus dem stable Repo installiert werden mit
- apt install tinc bird2
- - Tinc 1.1pre17 kann aus experimental installiert werden (hier nicht beschrieben) oder aus den Sourcen kompiliert werden:
-
- sudo apt install build-essential libncurses-dev libreadline-dev liblzo2-dev libssl-dev
- wget http://tinc-vpn.org/packages/tinc-1.1pre17tar.gz
- tar zxvf tinc-1.1pre17.tar.gz
- ./configure
- Falls Fehler auftreten, fehlende Pakete nach installieren,dann
- make
- sudo make install
- # Allgemein
- - Informationen auf dieser Seite sind teilweise von anderen Wiki-Seiten übernommen.
- Es werden für alle Interfaces statische IPV4 Adressen verwendet, auf dem Laptop ist auch DHCP aktiv.
- Die hier verwendeten Adressen sind dem Wiki [IP-Adressen](IP-Adressen) für berghofen entnommen.
- # Hardware
- - APU mit Debian 11 (Bullseye) ohne grafische Oberfläche
- - Laptop mit Ubuntu 18.04
- Berghofen, wie auch die anderen Standorte, besteht jeweils mindestens aus der APU und einem Laptop sowie einem Internetrouter (F!Box).
- An jedem Standort gibt es mehrere Tincverbindungen:
- - lan: zwischen APU und Laptop
- - wan: zwischen APU und den anderen Standorten
- - wan: zwischen Laptop und den anderen Standorten
- # Dateien der APU
-
- # This file describes the network interfaces available on your system
- # and how to activate them. For more information, see interfaces(5).
- source /etc/network/interfaces.d/*
- # The loopback network interface
- auto lo
- iface lo inet loopback
- up ip addr add 193.43.220.130/32 dev lo
-
- # The primary network interface
- allow-hotplug enp1s0
- iface enp1s0 inet static
- address 192.168.178.51/24
-
- #default gateway wird von bird erledigt
- # gateway 192.168.178.254
- broadcast 192.168.178.255
- # dns-* options are implemented by the resolvconf package, if installed
- dns-nameservers 192.168.178.254
- dns-search fritz.box
- up ip rule add from all iif enp1s0 lookup 1 prio 1000 || true
- up ip rule add from 192.168.178.0/24 lookup 1 prio 1010 || true
- allow-hotplug wan
- iface wan inet static
- address 193.43.220.162/27
- broadcast 193.43.220.191
- mtu 1504
- allow-hotplug lan
- iface lan inet static
- address 192.168.34.1/24
- broadcast 192.168.34.255
- mtu 1504
- #allow-hotplug wlp5s0 # wlan z.Zt. nicht verwendet
- #iface wlp5s0 inet dhcp
- Die Schnittstellen der Interfacesdatei sind:
- - lo Standardloopback
- - enp1s0 ethernet
- - wan virtuelle Tinc Schnittstelle
- - lan virtuelle Tinc Schnittstelle
- - wlp5s0 nicht verwendete, auskommentierte WLAN Schnittstelle
- ## Für die Datenweitergabe zwischen den Netzen ist der folgende Eintrag nötig.
- # Uncomment the next line to enable packet forwarding for IPv4
- net.ipv4.ip_forward=1
- # Tinc Verzeichnistruktur Tinc APU und Laptop Einstellungen
- etc/tinc/
- |-- lan
- | |-- hosts
- | | |-- berghofen
- | | `-- berglap
- | |-- rsa_key.priv
- | |-- ed25519_key.priv ## nur bei tinc 1.1
- | `-- tinc.conf
- `-- wan
- |-- hosts
- | |-- berghofen
- | |-- berglap
- | |-- hoerde
- | `-- nordstadt
- |-- rsa_key.priv
- |-- ed25519_key.priv ## nur bei tinc 1.1
- `-- tinc.conf
- ## APU lan tinc.conf
- Name = berghofen
- Device = /dev/net/tun
- Mode = switch
- AddressFamily = ipv4
- BindToAddress = 192.168.178.51
- Port = 10001
- MaxTimeout = 30
- GraphDumpFile = /var/run/tinc.lan.dot
- ConnectTo = berglap
- ## APU wan tinc.conf
- Name = berghofen
- Device = /dev/net/tun
- Mode = switch
- AddressFamily = ipv4
- BindToaddress = 192.168.178.51
- Port = 661
- MaxTimeout = 30
- GraphDumpFile = /var/run/tinc.wan.dot
- ConnectTo = hoerde
- ConnectTo = nordstadt
- ## Laptop lan tinc.conf
- Name = berglap
- Device = /dev/net/tun
- Mode = switch
- AddressFamily = ipv4
- BindToAddress = 192.168.178.52
- Port = 10001
- MaxTimeout = 30
- GraphDumpFile = /var/run/tinc.lan.dot
- ConnectTo = berghofen
- ## Laptop wan tinc.conf
- Name = berglap
- Device = /dev/net/tun
- Mode = switch
- AddressFamily = ipv4
- BindToaddress = 192.168.178.52
- Port = 661
- MaxTimeout = 30
- GraphDumpFile = /var/run/tinc.wan.dot
- ConnectTo = hoerde
- ConnectTo = nordstadt
- Da auf jedem Rechner 2 Tincinstanzen an demselben Interface laufen, werden sie durch unterschiedliche Ports getrennt: WAN mit port 661, LAN mit Port 10001.
- Inhalt der hosts Dateien
- Die Public und private Keys werden von Tinc erzeugt:
- bei tinc 1.0.36:
- tincd -n wan -K 4096
- tincd -n lan -K 4096
-
- bei tinc 1.1:
- tinc -n wan generate-keys 4096
- tinc -n lan generate-keys 4096
- Die ED25519PublicKey Zeile wird nur bei tinc 1.1 erzeugt/verwendet.
- Für hosts, die per ConnectTo in der tinc.conf angesprochen werden, ist in der zugehörigen hosts Datei die IPadresse des hosts und der port erforderlich für die aktive Verbindungsaufnahme.
- Address = 192.168.178.51
- Port = 10001
- -----BEGIN RSA PUBLIC KEY-----
- Schlüsseldaten
- -----END RSA PUBLIC KEY-----
- Ed25519PublicKey = WmAmMY95+B/A9FDQz7ZiV6WQcG2qAUUclRP52dwXSdD
- Address = 192.168.178.52
- Port = 10001
- -----BEGIN RSA PUBLIC KEY-----
- Schlüsseldaten
- -----END RSA PUBLIC KEY-----
- Ed25519PublicKey = WCkEAe/gohI7JAGLiHPKdE+ayxYrG1wuTfQQijAROuD
- -----BEGIN RSA PUBLIC KEY-----
- Schlüsseldaten
- -----END RSA PUBLIC KEY-----
- Ed25519PublicKey = Tkhp7t+MsmQKsWIkO5qimTKoWdkvRigKwctxtfOu2MF
- Address = 130.180.53.22
- Port = 661
- -----BEGIN RSA PUBLIC KEY-----
- Schlüsseldaten
- -----END RSA PUBLIC KEY-----
- Ed25519PublicKey = MjaltxtfPP1SdHgNH/dUuHmbYDXFdZMEUUbl0Qi/YCA
- Address = 91.204.4.53
- Port = 661
- -----BEGIN RSA PUBLIC KEY-----
- Schlüsseldaten
- -----END RSA PUBLIC KEY-----
- Ed25519PublicKey = 4znU87BKnctOFb+/JQhIltGtYN3h3czOVInolRPWgvA
- -----BEGIN RSA PUBLIC KEY-----
- Schlüsseldaten
- -----END RSA PUBLIC KEY-----
- Ed25519PublicKey = 4znU87BKnctOFb+/JQhIltGtYN3h3czOVInolRPWgvA
- Die Tinc Instanzen können auf APU und berglap gestartet werden mit:
- systemctl start tinc@lan
- systemctl start tinc@wan
- Beispielhaft tinc@lan abfragen:
- systemctl status tinc@lan
- tinc@lan.service - Tinc net lan
- Loaded: loaded (/lib/systemd/system/tinc@.service; enabled; vendor preset: enabled)
- Active: active (running) since Tue 2022-03-29 21:26:01 CEST; 1 months 0 days ago
- Docs: info:tinc
- man:tinc(8)
- man:tinc.conf(5)
- http://tinc-vpn.org/docs/
- Main PID: 472 (tincd)
- Tasks: 1 (limit: 4657)
- Memory: 4.1M
- CPU: 22min 34.347s
- CGroup: /system.slice/system-tinc.slice/tinc@lan.service
- └─472 /usr/sbin/tincd -n lan -D
- ...
- Dabei ist das enabled in der Loaded Zeile wichtig.
- Um die Programme automatisch nach einem reboot zu starten, eventuell
- falls nicht durch die Installation schon eingerichtet:
- systemctl enable tinc@lan
- systemctl enable tinc@wan
- # Bird auf der APU berghofen und Laptop berglap
- #
- # reserved values
- #
- 255 local
- 254 main
- 253 default
- 0 unspec
- #
- # local
- #
- 1 tinc
- - Die bird.conf des laptops ist bis auf andere IP Adressen identisch
- # bird.conf Alle Anpassungen als defines
- # damit keine übersehen wird
- define publicIP = 193.43.220.130;
- define publicIP_32 = 193.43.220.130/32;
- define isprouter = 192.168.178.254;
- # ab hier passt alles für unsere lan/wan Netze
- router id publicIP;
-
- # log syslog { debug, info, trace, remote }; /* optional */
- define AS35675_all = [
- 193.43.220.0/23
- ];
- define AS35675_any = [
- 193.43.220.0/23+
- ];
- protocol device device0 {
- scan time 10;
- }
- protocol direct direct0 {
- ipv4;
- }
- protocol kernel kernel0 {
- learn on;
- scan time 120;
- ipv4 {
- import all;
- export where source != RTS_DEVICE;
- };
- }
- # erstellt neue routing tabelle
- ipv4 table fib1table;
- #RTS route source
- #import / export
- protocol kernel kernel1 {
- kernel table 1;
- learn on;
- scan time 120;
- ipv4 {
- table fib1table;
- import all;
- export where source != RTS_DEVICE;
- };
- }
- protocol static static1 {
- ipv4 {
- table fib1table;
- };
- route 0.0.0.0/0 via isprouter; /* zur F!Box */
- }
- protocol ospf ospfwan {
- ipv4 {
- import all;
- export where net ~ AS35675_any;
- };
- area 0.0.0.0 {
- stubnet publicIP_32 { cost 1; };
- interface "wan" {
- type broadcast;
- cost 100;
- };
- interface "lan" {
- type broadcast;
- cost 10;
- };
- };
- }
- Den bird starten und eventuell rebootfest machen:
- systemctl start bird
- systemctl enable bird
|