Skip to content

Instantly share code, notes, and snippets.

@xmoforf
Created October 4, 2025 23:57
Show Gist options
  • Save xmoforf/b384fd9541f3a8ab1f76a77b155f2399 to your computer and use it in GitHub Desktop.
Save xmoforf/b384fd9541f3a8ab1f76a77b155f2399 to your computer and use it in GitHub Desktop.
wg-systemd

Systemd + Wireguard

/etc/systemd/network/wg0.netdev

[NetDev]
Name=wg0
Kind=wireguard
Description=WireGuard tunnel wg0

[WireGuard]
ListenPort=xxxx
PrivateKey=<secret>

[WireGuardPeer]
PublicKey = <not-secret>
PresharedKey = <secret>
AllowedIPs = 10.0.0.2/32

/etc/systemd/network/wg0.network

Name=wg0

[Network]
Address=10.0.0.1/25

[Route]
Destination=10.1.0.0/24
Scope=link

[Route]
Destination=10.2.0.0/24
Scope=link
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment