Created
December 19, 2022 19:07
-
-
Save fabiojmendes/39b90472bdf04cde4d6a4cb92adc4a6d to your computer and use it in GitHub Desktop.
Wireguard vpn nat proxy
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
# ---------- Server Config ---------- | |
# vim: ft=conf | |
# | |
# Make sure ip forwarding is enabled | |
# net.ipv4.ip_forward=1 | |
# net.ipv6.conf.all.forwarding=1 | |
[Interface] | |
# IPV4 CIDR | |
Address = 10.10.0.1/24 | |
# IPV6 CIDR | |
Address = fd86:ea04:1111::1/64 | |
# Add forwarding when VPN is started | |
PostUp = iptables -A FORWARD -i wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -o enp1s0 -j MASQUERADE; ip6tables -A FORWARD -i wg0 -j ACCEPT; ip6tables -t nat -A POSTROUTING -o enp1s0 -j MASQUERADE | |
# Remove forwarding when VPN is shutdown | |
PostDown = iptables -D FORWARD -i wg0 -j ACCEPT; iptables -t nat -D POSTROUTING -o enp1s0 -j MASQUERADE; ip6tables -D FORWARD -i wg0 -j ACCEPT; ip6tables -t nat -D POSTROUTING -o enp1s0 -j MASQUERADE | |
PrivateKey = PRIVATE_KEY | |
# Port server should be listening on | |
ListenPort = 51820 | |
[Peer] | |
PublicKey = PUBLIC_KEY | |
AllowedIPs = 10.10.0.2/32, fd86:ea04:1111::2/128 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment