Last active
February 13, 2020 19:41
-
-
Save coopbri/c804652f99fd628a0d2b4ea5b66c3eba to your computer and use it in GitHub Desktop.
Wireguard server and client template with iptables rules (peer-to-peer connection with one client)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/etc/wireguard/wg0-client.conf | |
-------------------------------------------------------------- | |
[Interface] | |
Address = ($client-ipv4)/32 | |
PrivateKey = $(client-privkey) | |
[Peer] | |
PublicKey = $(server-pubkey) | |
Endpoint = $(external-address):51820 | |
AllowedIPs = 0.0.0.0/0 | |
PersistentKeepalive = 21 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/etc/wireguard/wg0.conf | |
-------------------------------------------------------------- | |
[Interface] | |
Address = $(server-ipv4)/24 | |
SaveConfig = true | |
PrivateKey = $(server-privkey) | |
ListenPort = $(external-address):51820 | |
PostUp = iptables -A FORWARD -i %i -j ACCEPT; iptables -A FORWARD -o %i -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE | |
PostDown = iptables -D FORWARD -i %i -j ACCEPT; iptables -D FORWARD -o %i -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE | |
[Peer] | |
PublicKey = $(client-pubkey) | |
AllowedIPs = $(client-ipv4)/32 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment