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 17:05] – [Inter-Client Communication] 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 74: | Line 71: | ||
| sudo iptables -A FORWARD -i wg0 -o wg0 -j ACCEPT | sudo iptables -A FORWARD -i wg0 -o wg0 -j ACCEPT | ||
| sudo iptables -I 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/32 | ||
| + | </ | ||
| + | |||
| + | Client | ||
| + | <code bash> | ||
| + | [Interface] | ||
| + | PrivateKey = <private key client> | ||
| + | Address = 10.1.2.1/32 | ||
| + | DNS = 10.1.2.254 #, 1.1.1.1 | ||
| + | |||
| + | [Peer] | ||
| + | PublicKey = <public key server> | ||
| + | AllowedIPs = 0.0.0.0/0, ::/0 | ||
| + | Endpoint = vpn.example.com: | ||
| + | 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.1680361545.txt.gz · Last modified: (external edit)