Wireguard einrichten: Unterschied zwischen den Versionen

Aus XccesS Wiki
Zur Navigation springen Zur Suche springen
KKeine Bearbeitungszusammenfassung
K Änderung 352 von Hendrik (Diskussion) rückgängig gemacht.
Zeile 19: Zeile 19:
<syntaxhighlight lang="bash" line="1">
<syntaxhighlight lang="bash" line="1">
[Interface]
[Interface]
PrivateKey =
Address = 10.0.5.1/24
Address = 10.0.0.6/32
ListenPort = 51820
DNS = 192.168.1.14,1.1.1.1,8.8.8.8
# Use your own private key, from /etc/wireguard/privatekey
PrivateKey = XXX
 
 
#Routen einstellen damit Clients kommunizieren können
PostUp    = iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE; iptables -A FORWARD -i wg0 -o wg0 -j ACCEPT
PostDown  = iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE


[Peer]
[Peer]
PublicKey =  
# Client 1
Endpoint = xsarts.de:51820
PublicKey = XXX
AllowedIPs = 192.168.1.0/24
# VPN client's IP address in the VPN
 
AllowedIPs = 10.0.5.2/32


</syntaxhighlight>
</syntaxhighlight>
Zeile 34: Zeile 40:
</syntaxhighlight>
</syntaxhighlight>
wg-quick up wg0
wg-quick up wg0
====Client====
 
=====in OPNSense erzeugt=====
apt install wireguard -y
Inhalt aus Peer-Generator hier einfügen nano /etc/wireguard/wg0.conf
====OPNSense als Client====
====OPNSense als Client====
Instanz erzeugen
Instanz erzeugen
Peer erzeugen
Peer erzeugen
nano /etc/wireguard/wg0.conf
[Interface]
PrivateKey =
Address = 10.0.0.6/32
DNS = 192.168.1.14,1.1.1.1,8.8.8.8
#Table = off
# Route zum Homelab-Host *explizit* anlegen
#PostUp  = ip route add 192.168.1.17/32 dev %i
#PostDown = ip route del 192.168.1.17/32 dev %i
[Peer]
PublicKey =
Endpoint = xsarts.de:51820
AllowedIPs = 192.168.1.0/24


=== Update ===
=== Update ===

Version vom 3. Juni 2025, 23:17 Uhr

Beschreibung

Download

Installation

apt install wireguard -y

Konfiguration

Server

Keys erzeugen

wg genkey | sudo tee /etc/wireguard/priv.key
chmod go= /etc/wireguard/priv.key

cat /etc/wireguard/priv.key | wg pubkey | sudo tee >> /etc/wireguard/pub.key
nano /etc/wireguard/wg0.conf

Inhalt:

[Interface]
Address = 10.0.5.1/24
ListenPort = 51820
# Use your own private key, from /etc/wireguard/privatekey
PrivateKey = XXX 


#Routen einstellen damit Clients kommunizieren können
PostUp     = iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE; iptables -A FORWARD -i wg0 -o wg0 -j ACCEPT
PostDown   = iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE

[Peer]
# Client 1
PublicKey = XXX
# VPN client's IP address in the VPN
AllowedIPs = 10.0.5.2/32
echo "net.ipv4.ip_forward=1" >> /etc/sysctl.conf && sysctl -p && sysctl -w net.ipv4.ip_forward=1

wg-quick up wg0

OPNSense als Client

Instanz erzeugen Peer erzeugen nano /etc/wireguard/wg0.conf [Interface] PrivateKey = Address = 10.0.0.6/32 DNS = 192.168.1.14,1.1.1.1,8.8.8.8

  1. Table = off
  1. Route zum Homelab-Host *explizit* anlegen
  2. PostUp = ip route add 192.168.1.17/32 dev %i
  3. PostDown = ip route del 192.168.1.17/32 dev %i


[Peer] PublicKey = Endpoint = xsarts.de:51820 AllowedIPs = 192.168.1.0/24

Update

Test

Fehlerbehebung

Starten/Stoppen funktioniert nicht

Lösung 1
auszufüllen

Codeschnipsel

Nützliche Links

Codeschnipsel

Nützliche Links