Skip to content

Instantly share code, notes, and snippets.

@jrandiny
Last active July 3, 2023 12:51
Show Gist options
  • Save jrandiny/4abf2101e0cac724ce2469ed30c2670c to your computer and use it in GitHub Desktop.
Save jrandiny/4abf2101e0cac724ce2469ed30c2670c to your computer and use it in GitHub Desktop.
wireguard config
[Interface]
PrivateKey = <client private key>
Address = 10.50.0.1/24
DNS = 10.50.0.3
# Jump host
[Peer]
PublicKey = <jump host public key>
AllowedIPs = 0.0.0.0/0,::0/0
Endpoint = <jump host ip and port>
PersistentKeepalive = 25
[Interface]
PrivateKey = <jump host private key>
Address = 10.50.0.2/24
ListenPort = 12367
Table = 999
# Setup forwarding of all traffic from 10.50.0.0/24
PostUp = ip rule add table 999 suppress_prefixlength 0
PostUp = ip rule add from 10.50.0.0/24 table 999
PreDown = ip rule del from 10.50.0.0/24 table 999
PreDown = ip rule del table 999 suppress_prefixlength 0
PostUp = iptables -I FORWARD -i %i ! -o %i -j REJECT
PreDown = iptables -D FORWARD -i %i ! -o %i -j REJECT
# client
[Peer]
PublicKey = <client public key>
AllowedIPs = 10.50.0.1
# server
[Peer]
PublicKey = <server public key>
AllowedIPs = 10.50.0.3,0.0.0.0/0
[Interface]
PrivateKey = <server private key>
Address = 10.50.0.3/24
# Setup forwarding
PostUp = iptables -A FORWARD -i %i -j ACCEPT;iptables -A FORWARD -o %i -j ACCEPT
PostUp = iptables -t nat -A POSTROUTING -o enp5s0 -j MASQUERADE # Change enp5s0 to your network interface
PostDown = iptables -t nat -D POSTROUTING -o enp5s0 -j MASQUERADE # Change enp5s0 to your network interface
PostDown = iptables -D FORWARD -i %i -j ACCEPT;iptables -D FORWARD -o %i -j ACCEPT
# Jump host
[Peer]
PublicKey = <jump host public key>
Endpoint = <jump host ip and port>
AllowedIPs = 10.50.0.0/24
PersistentKeepalive = 25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment