notiz:wireguard
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen der Seite angezeigt.
Beide Seiten, vorherige ÜberarbeitungVorherige ÜberarbeitungNächste Überarbeitung | Vorherige Überarbeitung | ||
notiz:wireguard [2020/03/18 19:35] – clerie | notiz:wireguard [2020/03/31 00:31] (aktuell) – [Beispiele] clerie | ||
---|---|---|---|
Zeile 1: | Zeile 1: | ||
====== Wireguard ====== | ====== Wireguard ====== | ||
- | ===== wg0.conf ===== | + | |
+ | ===== Kryptografie ===== | ||
+ | |||
+ | ==== Privaten Schlüssel erzeugen ==== | ||
+ | <code bash> | ||
+ | wg genkey > wg-c2s-private.key | ||
+ | </ | ||
+ | |||
+ | ==== Öffentlichen Schlüssel erzeugen ==== | ||
+ | <code bash> | ||
+ | cat wg-c2s-private.key | wg pubkey > wg-c2s-public.key | ||
+ | </ | ||
+ | |||
+ | ===== Konfiguration | ||
Wireguard wird über Konfigurationsdateien verwaltet. Diese liegen unter / | Wireguard wird über Konfigurationsdateien verwaltet. Diese liegen unter / | ||
Zeile 17: | Zeile 30: | ||
[Peer] | [Peer] | ||
PublicKey = <public key of client 1> | PublicKey = <public key of client 1> | ||
- | AllowedIPs = 192.168.123.12/32 | + | AllowedIPs = 192.168.123.11/32 |
# Client 2 | # Client 2 | ||
[Peer] | [Peer] | ||
PublicKey = <public key of client 2> | PublicKey = <public key of client 2> | ||
- | AllowedIPs = 192.168.123.11/32 | + | AllowedIPs = 192.168.123.12/32 |
</ | </ | ||
+ | |||
+ | * **AllowedIPs** dient WireGuard zum routen von Paketen | ||
===== Wireguard verwenden ===== | ===== Wireguard verwenden ===== | ||
Zeile 50: | Zeile 65: | ||
<code bash> | <code bash> | ||
systemctl enable wg-quick@< | systemctl enable wg-quick@< | ||
+ | </ | ||
+ | |||
+ | ===== Beispiele ===== | ||
+ | Gute Beispiele hier: https:// | ||
+ | ==== Client-Server-Client ==== | ||
+ | === Server === | ||
+ | <code ini / | ||
+ | [Interface] | ||
+ | Address = 192.168.123.1/ | ||
+ | PrivateKey = <private key of server> | ||
+ | ListenPort = 51820 # Port, auf dem der Server läuft | ||
+ | # Forwardingregeln, | ||
+ | PostUp = iptables -A FORWARD -i %i -j ACCEPT; iptables -A FORWARD -o %i -j ACCEPT; ip6tables -A FORWARD -i %i -j ACCEPT; ip6tables -A FORWARD -o %i -j ACCEPT; | ||
+ | PostDown = iptables -D FORWARD -i %i -j ACCEPT; iptables -D FORWARD -o %i -j ACCEPT; ip6tables -D FORWARD -i %i -j ACCEPT; iptables -D FORWARD -o %i -j ACCEPT; | ||
+ | |||
+ | # Client 1 | ||
+ | [Peer] | ||
+ | PublicKey = <public key of client 1> | ||
+ | AllowedIPs = 192.168.123.11/ | ||
+ | |||
+ | # Client 2 | ||
+ | [Peer] | ||
+ | PublicKey = <public key of client 2> | ||
+ | AllowedIPs = 192.168.123.12/ | ||
+ | </ | ||
+ | |||
+ | Wichtig ist an dieser Stelle, dass auf dem Server folgende Systemvariablen gesetzt sind: | ||
+ | < | ||
+ | net.ipv4.ip_forward=1 | ||
+ | net.ipv6.conf.all.forwarding=1 | ||
+ | </ | ||
+ | |||
+ | Herausfinden kann man das folgendermaßen: | ||
+ | <code bash> | ||
+ | sysctl net.ipv4.ip_forward | ||
+ | sysctl net.ipv6.conf.all.forwarding | ||
+ | </ | ||
+ | |||
+ | Dauerhaft aktivieren lässt sich das in der / | ||
+ | <code - / | ||
+ | net.ipv4.ip_forward=1 | ||
+ | net.ipv6.conf.all.forwarding=1 | ||
+ | </ | ||
+ | |||
+ | **Achtung!** net.ipv6.conf.all.forwarding=1 verhinder IPv6 Autokonfig auf allen Interfaces. Aus diesem Grund sollte dies **vorher** statisch eingerichtet werden. | ||
+ | |||
+ | === Client 1 === | ||
+ | <code ini / | ||
+ | [Interface] | ||
+ | PrivateKey = <private key of client 1> | ||
+ | Address = 192.168.123.11/ | ||
+ | |||
+ | [Peer] | ||
+ | Endpoint = wireguard-1.clerie.de: | ||
+ | PublicKey = <public key of server> | ||
+ | AllowedIPS = 192.168.123.0/ | ||
+ | </ | ||
+ | |||
+ | === Client 2 === | ||
+ | <code ini / | ||
+ | [Interface] | ||
+ | PrivateKey = <private key of client 2> | ||
+ | Address = 192.168.123.12/ | ||
+ | |||
+ | [Peer] | ||
+ | Endpoint = wireguard-1.clerie.de: | ||
+ | PublicKey = <public key of server> | ||
+ | AllowedIPS = 192.168.123.0/ | ||
</ | </ |
notiz/wireguard.1584556541.txt.gz · Zuletzt geändert: 2020/03/18 19:35 von clerie