Skip to content

Instantly share code, notes, and snippets.

@kyxap1
Last active February 22, 2021 19:13
Show Gist options
  • Select an option

  • Save kyxap1/fe88e0c62774bad2e1eb52811dda8a4f to your computer and use it in GitHub Desktop.

Select an option

Save kyxap1/fe88e0c62774bad2e1eb52811dda8a4f to your computer and use it in GitHub Desktop.
Asus RT-N56U custom vpn client script
#!/bin/sh
ACTION=${1}
DEBUG=1
func_res() {
[[ ${DEBUG:-0} -ge 1 ]] && set 2>&1 | logger -t vpnc-script
# how to get cidrs: http://kyxap.org.ua/articles/google_ip_range
CIDRS="$(cat /opt/home/admin/cidrs/*.txt)"
EXCLUDE="$(cat /opt/home/admin/cidrs/exclude/*.txt)"
set -- ${CIDRS}
gateway="$(echo $IPLOCAL | cut -d. -f1-3).1"
for net; do echo "ip route ${ACTION} $net via ${gateway} dev ${IFNAME} src ${IPLOCAL}"; done
for exclude in ${EXCLUDE}; do echo "ip route ${ACTION} ${exclude} dev eth3"; done
return 0
}
case "$ACTION" in
up)
ACTION=add
;;
down)
ACTION=del
;;
esac
func_res | tee /tmp/vpn.log | sh 2>&1 | logger -t vpnc-script
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment