Skip to content

Instantly share code, notes, and snippets.

@mariotpc
Created April 6, 2023 16:35
Show Gist options
  • Save mariotpc/abe4280f6b835f1b02335b2dab4fc0ed to your computer and use it in GitHub Desktop.
Save mariotpc/abe4280f6b835f1b02335b2dab4fc0ed to your computer and use it in GitHub Desktop.
wg interface script
[Interface]
PrivateKey = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Address = 172.20.21.4/24, fe00:a::4/64, xxxx:xxx:a::1/64
MTU = 1412
PostUp = echo "$(date +%s) Wireguard Started " >> /var/log/wireguard.log
PostDown = echo "$(date +%s) Wireguard Stop " >> /var/log/wireguard.log
PostUp = export EXITCODE=$(ifconfig wlp0s20f3 | grep inet | grep 192.168.200 | awk '{print $2}')
PostUp = test -z "$EXITCODE" && echo "Not working on the office network" || ip r add 192.168.200.0/24 via 192.168.1.1 dev wlp0s20f3
PostDown = export EXITCODE=$(ifconfig wlp0s20f3 | grep inet | grep 192.168.200 | awk '{print $2}')
PostDown = test -z "$EXITCODE" && echo "Not working on the office network" || ip r del 192.168.200.0/24 via 192.168.1.1 dev wlp0s20f3
[Peer]
PublicKey = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
AllowedIPs = 172.20.21.1/32, fe00:a::1/128, xxxx:xxxxx:a::2/128, 0.0.0.0/0, ::/0
PersistentKeepAlive = 30
Endpoint = xxxxxxxxxxxxx:51820
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment