Guest User

Untitled

a guest
Apr 5th, 2014
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 KB | None | 0 0
  1. DEV=gre2
  2. LOCAL_ADDR=MYIP
  3. FILTER_ADDR=198.148.83.92
  4. INTERNAL_ADDR=10.17.16.14
  5. NETWORK=10.17.16.12
  6. GATEWAY=10.17.16.13
  7. TYPE=gre
  8. TABLE=T1
  9. TABLE_ID=100
  10.  
  11. DEV1=gre3
  12. LOCAL_ADDR1=MYIP
  13. FILTER_ADDR1=209.141.38.206
  14. INTERNAL_ADDR1=10.17.24.2
  15. NETWORK1=10.17.24.0
  16. GATEWAY1=10.17.24.1
  17. TYPE1=gre
  18. TABLE1=T2
  19. TABLE_ID1=101
  20.  
  21. DEV2=gre4
  22. LOCAL_ADDR2=MYIP
  23. FILTER_ADDR2=64.32.5.139
  24. INTERNAL_ADDR2=10.17.13.6
  25. NETWORK2=10.17.13.4
  26. GATEWAY2=10.17.13.5
  27. TYPE2=gre
  28. TABLE2=T3
  29. TABLE_ID2=102
  30.  
  31. MTU=1436
  32.  
  33. ## DO NOT EDIT BELOW THIS LINE ##
  34.  
  35. if [[ -f /proc/user_beancounters ]]; then
  36. if [[ ! $(ip addr show gre0 | grep gre0) ]]; then
  37. echo "Kernel ip_gre module not loaded or accessible. Contact your hosting company."
  38. exit 2
  39. fi
  40. fi
  41.  
  42.  
  43.  
  44. iptunnel add ${DEV} mode ${TYPE} local ${LOCAL_ADDR} remote ${FILTER_ADDR} ttl 255
  45. ip addr add ${INTERNAL_ADDR}/30 dev ${DEV}
  46. ip link set ${DEV} up
  47.  
  48. if grep -q "${TABLE_ID} ${TABLE}" "/etc/iproute2/rt_tables" ; then
  49. echo "Routing table already exists, skipping"
  50. else
  51. echo "${TABLE_ID} ${TABLE}" >> /etc/iproute2/rt_tables
  52. fi
  53.  
  54. ip rule add from ${NETWORK}/30 table ${TABLE}
  55. ip route add default via ${GATEWAY} table ${TABLE}
  56.  
  57. ifconfig ${DEV} mtu ${MTU}
  58.  
  59.  
  60. iptunnel add ${DEV1} mode ${TYPE1} local ${LOCAL_ADDR1} remote ${FILTER_ADDR1} ttl 255
  61. ip addr add ${INTERNAL_ADDR1}/30 dev ${DEV}
  62. ip link set ${DEV1} up
  63.  
  64. if grep -q "${TABLE_ID1} ${TABLE1}" "/etc/iproute2/rt_tables" ; then
  65. echo "Routing table already exists, skipping"
  66. else
  67. echo "${TABLE_ID1} ${TABLE1}" >> /etc/iproute2/rt_tables
  68. fi
  69.  
  70. ip rule add from ${NETWORK1}/30 table ${TABLE1}
  71. ip route add default via ${GATEWAY1} table ${TABLE1}
  72.  
  73. ifconfig ${DEV1} mtu ${MTU}
  74.  
  75.  
  76. iptunnel add ${DEV2} mode ${TYPE2} local ${LOCAL_ADDR2} remote ${FILTER_ADDR2} ttl 255
  77. ip addr add ${INTERNAL_ADDR2}/30 dev ${DEV}
  78. ip link set ${DEV2} up
  79.  
  80. if grep -q "${TABLE_ID2} ${TABLE2}" "/etc/iproute2/rt_tables" ; then
  81. echo "Routing table already exists, skipping"
  82. else
  83. echo "${TABLE_ID2} ${TABLE2}" >> /etc/iproute2/rt_tables
  84. fi
  85.  
  86. ip rule add from ${NETWORK2}/30 table ${TABLE2}
  87. ip route add default via ${GATEWAY2} table ${TABLE2}
  88.  
  89. ifconfig ${DEV2} mtu ${MTU}
  90.  
  91. echo "Done"
Advertisement
Add Comment
Please, Sign In to add comment