Created
February 25, 2020 02:31
-
-
Save pacmac/d92ec88ad60b94a1a3b3000a35638cba to your computer and use it in GitHub Desktop.
Asus Padadavan - Run the Script After Connected/Disconnected to VPN Server:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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