linux:vpn:wireguard
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
linux:vpn:wireguard [2023/04/01 16:53] – [Server] admin | linux:vpn:wireguard [2024/02/25 14:28] (current) – gsys | ||
---|---|---|---|
Line 3: | Line 3: | ||
===== Installation ===== | ===== Installation ===== | ||
- | < | + | < |
sudo apt update | sudo apt update | ||
sudo apt install wireguard wireguard-tools | sudo apt install wireguard wireguard-tools | ||
Line 12: | Line 12: | ||
==== Server ==== | ==== Server ==== | ||
create private key and remove permissions for any one other than root | create private key and remove permissions for any one other than root | ||
- | < | + | < |
wg genkey | sudo tee / | wg genkey | sudo tee / | ||
sudo chmod go= / | sudo chmod go= / | ||
Line 18: | Line 18: | ||
create public key | create public key | ||
- | < | + | < |
sudo cat / | sudo cat / | ||
</ | </ | ||
- | < | + | < |
sudo nano / | sudo nano / | ||
</ | </ | ||
- | FIXME | ||
<code bash> | <code bash> | ||
[Interface] | [Interface] | ||
Line 33: | Line 32: | ||
ListenPort = 51820 | ListenPort = 51820 | ||
SaveConfig = false | SaveConfig = false | ||
- | PostUp = iptables -A FORWARD -i wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE | ||
- | PostDown = iptables -D FORWARD -i wg0 -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE | ||
[Peer] | [Peer] | ||
Line 47: | Line 44: | ||
</ | </ | ||
- | === Optional | + | ==== Client ==== |
+ | |||
+ | <code bash> | ||
+ | [Interface] | ||
+ | PrivateKey = <private key client> | ||
+ | Address = 10.1.2.1/ | ||
+ | DNS = 10.1.2.254 | ||
+ | |||
+ | [Peer] | ||
+ | PublicKey = <public key server> | ||
+ | AllowedIPs = 10.1.2.1/ | ||
+ | Endpoint = vpn.example.com: | ||
+ | PersistentKeepalive = 25 | ||
+ | </ | ||
+ | |||
+ | ==== Inter-Client Communication ==== | ||
- | FIXME | + | IPv4 Packet Forwarding aktivieren |
- | Inter-Client Communication | + | |
< | < | ||
- | sudo sysctl -w net.ipv4.ip_forward=1 | + | sudo sysctl -w net.ipv4.ip_forward=1 |
- | sudo sysctl -p | + | sudo sysctl -p |
- | sudo iptables -A FORWARD -i wg0 -o wg0 -j ACCEPT | + | |
- | sudo iptables -I FORWARD -i wg0 -o wg0 -j ACCEPT | + | |
</ | </ | ||
- | ==== Client | + | Kommunikation wg0 <-> wg0 erlauben |
+ | < | ||
+ | sudo iptables -A FORWARD -i wg0 -o wg0 -j ACCEPT | ||
+ | sudo iptables -I FORWARD -i wg0 -o wg0 -j ACCEPT | ||
+ | </ | ||
+ | |||
+ | ==== Internetzugriff | ||
+ | |||
+ | Server | ||
+ | IPv4/IPv6 Packet Forwarding aktivieren | ||
+ | < | ||
+ | sudo sysctl -w net.ipv4.ip_forward=1 | ||
+ | sudo sysctl -w net.ipv6.ip_forward=1 | ||
+ | sudo sysctl -p # Änderung anwenden | ||
+ | </ | ||
+ | |||
+ | Server | ||
+ | <code bash> | ||
+ | [Interface] | ||
+ | PrivateKey = <private key server> | ||
+ | Address = 10.1.2.254/ | ||
+ | ListenPort = 51820 | ||
+ | SaveConfig = false | ||
+ | PostUp = iptables -A FORWARD -i wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE | ||
+ | PostDown = iptables -D FORWARD -i wg0 -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE | ||
+ | |||
+ | [Peer] | ||
+ | PublicKey = <public key client> | ||
+ | AllowedIPs = 10.1.2.1/ | ||
+ | </ | ||
+ | Client | ||
<code bash> | <code bash> | ||
[Interface] | [Interface] | ||
PrivateKey = <private key client> | PrivateKey = <private key client> | ||
Address = 10.1.2.1/32 | Address = 10.1.2.1/32 | ||
- | DNS = 10.1.2.254 | + | DNS = 10.1.2.254 |
[Peer] | [Peer] | ||
PublicKey = <public key server> | PublicKey = <public key server> | ||
- | AllowedIPs = 10.1.2.1/32 | + | AllowedIPs = 0.0.0.0/0, ::/0 |
Endpoint = vpn.example.com: | Endpoint = vpn.example.com: | ||
PersistentKeepalive = 25 | PersistentKeepalive = 25 | ||
+ | </ | ||
+ | |||
+ | ==== DNS-Suffix und Suchliste ==== | ||
+ | |||
+ | Client interface Anpassen | ||
+ | <code bash> | ||
+ | [Interface] | ||
+ | PrivateKey = <private key client> | ||
+ | Address = 10.1.2.1/32 | ||
+ | DNS = 10.1.2.254, lab.local, wg0.lab.local | ||
+ | |||
+ | [Peer] | ||
+ | PublicKey = <public key server> | ||
+ | AllowedIPs = 0.0.0.0/0, ::/0 | ||
+ | Endpoint = vpn.example.com: | ||
+ | PersistentKeepalive = 25 | ||
+ | </ | ||
+ | |||
+ | ==== Windows Client ==== | ||
+ | |||
+ | < | ||
+ | wireguard / | ||
+ | wireguard / | ||
+ | wireguard / | ||
+ | wireguard / | ||
+ | wireguard /update 2> C: | ||
</ | </ |
linux/vpn/wireguard.1680360789.txt.gz · Last modified: 2024/02/17 19:03 (external edit)