Advertisement
Guest User

Untitled

a guest
Feb 3rd, 2014
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.47 KB | None | 0 0
  1. #! /bin/bash
  2. VPNIF="tun0"
  3. VPNUSER="rt"
  4. #Modified "ifconfig" to "ip addr show" to support iproute2
  5. 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`
  6. if [[ `ip rule list | grep -c 0x1` == 0 ]]; then
  7. ip rule add from all fwmark 0x1 lookup $VPNUSER
  8. fi
  9. ip route replace default via $GATEWAYIP table $VPNUSER
  10. ip route append default via 127.0.0.1 dev lo table $VPNUSER
  11. ip route flush cache
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement