Skip to content

Instantly share code, notes, and snippets.

@malikbenkirane
Last active February 10, 2026 11:36
Show Gist options
  • Select an option

  • Save malikbenkirane/f9ed53dac24267fc660b6810d85faba7 to your computer and use it in GitHub Desktop.

Select an option

Save malikbenkirane/f9ed53dac24267fc660b6810d85faba7 to your computer and use it in GitHub Desktop.
Wireguard Wg-quick
[Interface]
Address = # e.g. 10.20.10.2/24
ListenPort = 33333
DNS = 8.8.8.8
PrivateKey = # ...
[Peer]
PublicKey = # server.conf public key
Endpoint = # server IP:PORT
AllowedIPs = # e.g. 10.20.10.0/24 or 0.0.0.0/0
sudo vi /etc/wireguard/wg0.conf
sudo systemctl start wg-quick@wg0 # first time and after reboot
sudo systemctl enable wg-quick@wg0 # persist after reboot (no need to run start command)
sudo systemctl reload wg-quick@wg0 # reload server/peers configuration
# /etc/wireguard/wg0.conf
[Interface]
Address = # e.g. 10.20.10.1/24
ListenPort = 33333
PrivateKey = $(wg genkey)
PostUp = iptables -A FORWARD -i %i -j ACCEPT
PostUp = iptables -A FORWARD -o %i -j ACCEPT
PostUp = iptables -t nat -A POSTROUTING -o ens4 -j MASQUERADE
PostDown = iptables -D FORWARD -i %i -j ACCEPT
PostDown = iptables -D FORWARD -o %i -j ACCEPT
PostDown = iptables -t nat -D POSTROUTING -o ens4 -j MASQUERADE
[Peer]
PublicKey = # ...
AllowedIPs = # e.g. 10.20.10.2/32
# ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment