Skip to content

Instantly share code, notes, and snippets.

@ricardobalk
Created April 27, 2026 16:37
Show Gist options
  • Select an option

  • Save ricardobalk/35b53b02f9cb14034a5f387dbad8ecc7 to your computer and use it in GitHub Desktop.

Select an option

Save ricardobalk/35b53b02f9cb14034a5f387dbad8ecc7 to your computer and use it in GitHub Desktop.
WireGuard with iptables ipv4 and ipv6
WireGuard(r) VPN configuration: Dual-stack VPN gateway.
[Interface]
Address = 10.13.37.1/24, fd42:1337:cafe:babe::1/64
ListenPort = 51820
PrivateKey = [REDACTED]
PostUp = sysctl -q net.ipv4.ip_forward=1
PostUp = sysctl -q net.ipv6.conf.all.forwarding=1
PostUp = iptables -A FORWARD -i %i -o eth0 -j ACCEPT
PostUp = iptables -A FORWARD -i eth0 -o %i -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
PostUp = iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
PostUp = ip6tables -A FORWARD -i %i -o eth0 -j ACCEPT
PostUp = ip6tables -A FORWARD -i eth0 -o %i -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
PostUp = ip6tables -t nat -A POSTROUTING -s fd42:1337:cafe:babe::/64 -o eth0 -j MASQUERADE
PostDown = iptables -D FORWARD -i %i -o eth0 -j ACCEPT
PostDown = iptables -D FORWARD -i eth0 -o %i -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
PostDown = iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE
PostDown = ip6tables -D FORWARD -i %i -o eth0 -j ACCEPT
PostDown = ip6tables -D FORWARD -i eth0 -o %i -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
PostDown = ip6tables -t nat -D POSTROUTING -s fd42:1337:cafe:babe::/64 -o eth0 -j MASQUERADE
PostDown = sysctl -q net.ipv4.ip_forward=0
PostDown = sysctl -q net.ipv6.conf.all.forwarding=0
[Peer]
AllowedIPs = 10.13.37.2/32, fd42:1337:cafe:babe:deca:f:c0ff:ee42/128
PersistentKeepalive = 90
PublicKey = [REDACTED]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment