Skip to content

Instantly share code, notes, and snippets.

@paolobasso99
Created March 29, 2021 19:41
Show Gist options
  • Save paolobasso99/13c49415a5b0298042c8b4ffb3e006ba to your computer and use it in GitHub Desktop.
Save paolobasso99/13c49415a5b0298042c8b4ffb3e006ba to your computer and use it in GitHub Desktop.
Wireguard on VPS to expose home
[Interface]
PrivateKey = xxxx
Address = 10.0.0.2/24
[Peer]
# VPS
PublicKey = xxxx
AllowedIPs = 10.0.0.1/32
Endpoint = 35.xxx.xxx.xxx:54321
PersistentKeepalive = 25
[Interface]
PrivateKey = xxxx
ListenPort = 54321
Address = 10.0.0.1/24
PostUp = iptables -t nat -A PREROUTING -p tcp -i ens4 '!' --dport 22 -j DNAT --to-destination 10.0.0.2; iptables -t nat -A POSTROUTING -o wg0 -d 10.0.0.2 -j SNAT --to-source 10.0.0.1
PostUp = iptables -t nat -A PREROUTING -p udp -i ens4 '!' --dport 54321 -j DNAT --to-destination 10.0.0.2;
PostDown = iptables -t nat -D PREROUTING -p tcp -i ens4 '!' --dport 22 -j DNAT --to-destination 10.0.0.2; iptables -t nat -D POSTROUTING -o wg0 -d 10.0.0.2 -j SNAT --to-source 10.0.0.1
PostDown = iptables -t nat -D PREROUTING -p udp -i ens4 '!' --dport 54321 -j DNAT --to-destination 10.0.0.2;
[Peer]
# HOME RASPBERRY
PublicKey = xxxx
AllowedIPs = 10.0.0.2/32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment