Benutzer-Werkzeuge

Webseiten-Werkzeuge


notiz:wireguard

Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen der Seite angezeigt.

Link zu der Vergleichsansicht

Beide Seiten, vorherige ÜberarbeitungVorherige Überarbeitung
Nächste Überarbeitung
Vorherige Überarbeitung
notiz:wireguard [2020/03/18 19:29] – angelegt clerienotiz: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 
 +</code> 
 + 
 +==== Öffentlichen Schlüssel erzeugen ==== 
 +<code bash> 
 +cat wg-c2s-private.key | wg pubkey > wg-c2s-public.key 
 +</code> 
 + 
 +===== Konfiguration ===== 
 +Wireguard wird über Konfigurationsdateien verwaltet. Diese liegen unter /etc/wireguard/<interface name>.conf. 
 + 
 +Eine solche Datei sieht ungefähr so aus. 
 <code ini /etc/wireguard/wg0.conf> <code ini /etc/wireguard/wg0.conf>
 # Lokales Interface # Lokales Interface
Zeile 13: Zeile 30:
 [Peer] [Peer]
 PublicKey = <public key of client 1> PublicKey = <public key of client 1>
 +AllowedIPs = 192.168.123.11/32
 +
 +# Client 2
 +[Peer]
 +PublicKey = <public key of client 2>
 AllowedIPs = 192.168.123.12/32 AllowedIPs = 192.168.123.12/32
 +</code>
 +
 +  * **AllowedIPs** dient WireGuard zum routen von Paketen
 +
 +===== Wireguard verwenden =====
 +
 +==== Interface starten ====
 +<code bash>
 +wg-quick up <interface name>
 +</code>
 +
 +==== Interface stoppen ====
 +<code bash>
 +wg-quick down <interface name>
 +</code>
 +
 +==== Interface starten systemd ====
 +<code bash>
 +systemctl start wg-quick@<interface name>
 +</code>
 +
 +==== Interface stoppen systemd ====
 +<code bash>
 +systemctl stop wg-quick@<interface name>
 +</code>
 +
 +==== Interface persistent starten systemd ====
 +<code bash>
 +systemctl enable wg-quick@<interface name>
 +</code>
 +
 +===== Beispiele =====
 +Gute Beispiele hier: https://github.com/pirate/wireguard-docs
 +==== Client-Server-Client ====
 +=== Server ===
 +<code ini /etc/wireguard/wg-csc.conf>
 +[Interface]
 +Address = 192.168.123.1/24 # IP Adresse des Servers
 +PrivateKey = <private key of server>
 +ListenPort = 51820 # Port, auf dem der Server läuft
 +# Forwardingregeln, damit Clients untereinander reden können
 +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/32 # IP des Client 1
  
 # 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 # IP des Client 2 
 +</code> 
 + 
 +Wichtig ist an dieser Stelle, dass auf dem Server folgende Systemvariablen gesetzt sind: 
 +<code> 
 +net.ipv4.ip_forward=1 
 +net.ipv6.conf.all.forwarding=1 
 +</code> 
 + 
 +Herausfinden kann man das folgendermaßen: 
 +<code bash> 
 +sysctl net.ipv4.ip_forward 
 +sysctl net.ipv6.conf.all.forwarding 
 +</code> 
 + 
 +Dauerhaft aktivieren lässt sich das in der /etc/sysctl.conf 
 +<code - /etc/sysctl.conf> 
 +net.ipv4.ip_forward=1 
 +net.ipv6.conf.all.forwarding=1 
 +</code> 
 + 
 +**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 /etc/wireguard/wg-csc.conf> 
 +[Interface] 
 +PrivateKey = <private key of client 1> 
 +Address = 192.168.123.11/24 # IP Adresse des Client 1 
 + 
 +[Peer] 
 +Endpoint = wireguard-1.clerie.de:51820 # Hostname und Port auf dem der Server lauscht 
 +PublicKey = <public key of server> 
 +AllowedIPS = 192.168.123.0/24 # IPs die über WireGuard getunnelt werden sollen 
 +</code> 
 + 
 +=== Client 2 === 
 +<code ini /etc/wireguard/wg-csc.conf> 
 +[Interface] 
 +PrivateKey = <private key of client 2> 
 +Address = 192.168.123.12/24 # IP Adresse des Client 2 
 + 
 +[Peer] 
 +Endpoint = wireguard-1.clerie.de:51820 # Hostname und Port auf dem der Server lauscht 
 +PublicKey = <public key of server> 
 +AllowedIPS = 192.168.123.0/24 # IPs die über WireGuard getunnelt werden sollen
 </code> </code>
notiz/wireguard.txt · Zuletzt geändert: 2020/03/31 00:31 von clerie

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki