Skip to content

Instantly share code, notes, and snippets.

@p1-olm
Last active February 12, 2018 11:16
Show Gist options
  • Save p1-olm/5d280be80853372834feef59dad908d1 to your computer and use it in GitHub Desktop.
Save p1-olm/5d280be80853372834feef59dad908d1 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
iface=$(ip -4 route list 0/0 | cut -d " " -f 5)
gateway=$(ip -4 route list 0/0 | cut -d " " -f 3)
ip=$(ip -4 route get $gateway | head -n 1 | cut -d " " -f 5)
# XXX check if gateway/ip in VPN range
set -v #echo on
ip address flush $iface
ip address add $ip/32 dev $iface
ip route add $gateway/32 dev $iface src $ip
ip route add default via $gateway dev $iface src $ip
wg-quick up wg0
# Fix stuck SSH on some connections by adjusting MTU
# see https://lists.zx2c4.com/pipermail/wireguard/2017-May/001265.html
ip link set mtu 1416 dev wg0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment