Skip to content

Instantly share code, notes, and snippets.

@pacmac
Created February 25, 2020 02:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pacmac/d92ec88ad60b94a1a3b3000a35638cba to your computer and use it in GitHub Desktop.
Save pacmac/d92ec88ad60b94a1a3b3000a35638cba to your computer and use it in GitHub Desktop.
Asus Padadavan - Run the Script After Connected/Disconnected to VPN Server:
#!/bin/sh
### Custom user script
### Called after internal VPN client connected/disconnected to remote VPN server
### $1 - action (up/down)
### $IFNAME - tunnel interface name (e.g. ppp5 or tun0)
### $IPLOCAL - tunnel local IP address
### $IPREMOTE - tunnel remote IP address
### $DNS1 - peer DNS1
### $DNS2 - peer DNS2
IPSTART="192.168.0.200"
IPEND="192.168.0.205"
#
ip route flush table 10
ip route del default table 10
ip rule del fwmark 10 table 10
ip route flush table 12
ip route del default table 12
ip rule del fwmark 12 table 12
ip route flush cache
iptables -t mangle -F PREROUTING
tun_if=$IFNAME
tun_ip=$IPLOCAL
ip route add default via $tun_ip dev $tun_if table 10
ip rule add fwmark 10 table 10
ip route add default via $(nvram get wan_gateway) dev eth2 table 12
ip rule add fwmark 12 table 12
echo 0 > /proc/sys/net/ipv4/conf/$tun_if/rp_filter
iptables -t mangle -A PREROUTING -i br0 -m iprange --src-range $IPSTART-$IPEND -j MARK --set-mark 10
iptables -t mangle -A PREROUTING -i br0 -p tcp --dport 563 -j MARK --set-mark 12
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment