SHOW:
|
|
- or go back to the newest paste.
1 | #! /bin/bash | |
2 | VPNIF="tun0" | |
3 | VPNUSER="rt" | |
4 | - | #Modified "ifconfig" to "ip addr show" to support iproute2 |
4 | + | # Edited the routing table name to "rt" insted of "vpnuser" |
5 | # Modified "ifconfig" to "ip addr show" to support iproute2 | |
6 | GATEWAYIP=`ip addr show $VPNIF | egrep -o '([0-9]{1,3}\.){3}[0-9]{1,3}' | egrep -v '255|(127\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})' | tail -n1` | |
7 | if [[ `ip rule list | grep -c 0x1` == 0 ]]; then | |
8 | ip rule add from all fwmark 0x1 lookup $VPNUSER | |
9 | fi | |
10 | ip route replace default via $GATEWAYIP table $VPNUSER | |
11 | ip route append default via 127.0.0.1 dev lo table $VPNUSER | |
12 | ip route flush cache |