Advertisement
Guest User

Untitled

a guest
Mar 27th, 2016
918
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. # http://www.linksysinfo.org/index.php?threads/routing-traffic-between-regular-isp-and-two-vpn-connections.72248/
  2. # Put this in the Firewall portion of the script section in Administration
  3.  
  4. #!/bin/sh
  5. set -x # uncomment/comment to enable/disable debug mode
  6.  
  7. (
  8. TID="200"
  9. FW_MARK="0x88"
  10. IPSET="myipset"
  11.  
  12. # cleanup from prior execution
  13. (
  14. # stop split tunnel
  15. ip rule del fwmark $FW_MARK table $TID
  16.  
  17. # delete firewall rules
  18. iptables -t mangle -F
  19.  
  20. # delete ipset hash table
  21. ipset -F $IPSET
  22. ipset -X $IPSET
  23.  
  24. # delete alternate routing table
  25. ip route flush table $TID
  26.  
  27. # force routing system to recognize our changes
  28. ip route flush cache
  29.  
  30. # enable reverse path filtering
  31. for i in /proc/sys/net/ipv4/conf/*/rp_filter; do echo 1 > $i; done
  32.  
  33. sleep 3
  34. ) > /dev/null 2>&1
  35.  
  36. # quit if neither OpenVPN client is active
  37. ! ip route show | egrep -qm1 'tun1[1-2]' && exit
  38.  
  39. # copy main routing table (exclude all default gateway routes)
  40. ip route show | egrep -v '^default|^0.0.0.0/1|^128.0.0.0/1' \
  41. | while read route; do
  42. ip route add $route table $TID
  43. done
  44.  
  45. # add WAN as default gateway
  46. ip route add default via $(nvram get wan_gateway) table $TID
  47.  
  48. # force routing system to recognize our changes
  49. ip route flush cache
  50.  
  51. # disable reverse path filtering
  52. for i in /proc/sys/net/ipv4/conf/*/rp_filter; do echo 0 > $i; done
  53.  
  54. # load required netfilter modules
  55. (modprobe xt_set || modprobe ipt_set) 2> /dev/null
  56.  
  57. # create ipset hash table
  58. insmod ip_set_hash_ip
  59. ipset -N $IPSET iphash -q
  60. ipset -F $IPSET
  61.  
  62. # add firewall rule
  63. iptables -t mangle -A PREROUTING -p tcp -m multiport --sport 3000,8085,32400 -j MARK --set-mark $FW_MARK
  64. iptables -t mangle -A PREROUTING -m set --match-set $IPSET dst -j MARK --set-mark $FW_MARK
  65.  
  66. # OUTPUT for Admin page of router (Set port for your setting)
  67. iptables -t mangle -A OUTPUT -p tcp -m multiport --sport 8080 -j MARK --set-mark $FW_MARK
  68.  
  69. # start split tunnel
  70. ip rule add fwmark $FW_MARK table $TID
  71.  
  72. ) 2>&1 | logger -t "ovpn_split[$$]"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement