Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /bin/bash
- VPNIF="tun0"
- VPNUSER="rt"
- #Modified "ifconfig" to "ip addr show" to support iproute2
- 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`
- if [[ `ip rule list | grep -c 0x1` == 0 ]]; then
- ip rule add from all fwmark 0x1 lookup $VPNUSER
- fi
- ip route replace default via $GATEWAYIP table $VPNUSER
- ip route append default via 127.0.0.1 dev lo table $VPNUSER
- ip route flush cache
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement