Advertisement
Guest User

Untitled

a guest
Apr 11th, 2020
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.18 KB | None | 0 0
  1. =-=-=-=-=-=-=-=-=-=-=-=-=-=
  2. #! /bin/bash
  3.  
  4. DEV=
  5. LOCAL_IP=23.111.92.132
  6.  
  7. OFFSET=40
  8.  
  9. if ip link sh qrtun &>/dev/null; then
  10.     echo 'Tunnel is set up already, nothing to do.' >&2
  11.     exit -1
  12. fi
  13.  
  14. if [ -z "$DEV" ]; then
  15.     echo '$DEV unset'
  16.     exit -1
  17. fi
  18.  
  19. if [ -z "$LOCAL_IP" ]; then
  20.     echo '$LOCAL_IP unset'
  21.     exit -1
  22. fi
  23.  
  24. if ! modprobe ipip; then
  25.     echo 'Failed to load ipip module'
  26.     exit -1
  27. fi
  28.  
  29. if ! grep -q qrtun_route /etc/iproute2/rt_tables; then
  30.     if egrep -q '^[[:space:]]*'$OFFSET'[[:space:]]' /etc/iproute2/rt_tables; then
  31.         echo Cannot append appropriate lines to /etc/iproute2/rt_tables. >&2
  32.         echo You need to set up qrtun_route table yourself. >&2
  33.         exit
  34.     else
  35.         echo ' '$OFFSET' qrtun_route' >> /etc/iproute2/rt_tables
  36.     fi
  37. fi
  38.  
  39. echo -n Setting up tunnel... >&2
  40.  
  41. src=172.16.108.60
  42. dst=172.16.208.60
  43.  
  44. ip tunnel add qrtun mode ipip remote 185.104.208.60 local $LOCAL_IP ttl 64 dev $DEV
  45.  
  46. ip address add $src peer $dst/32 dev qrtun
  47. ip link set qrtun up
  48. ip rule add from $src table qrtun_route
  49. ip route add default dev qrtun table qrtun_route
  50.  
  51. echo ' done'. >&2
  52. =-=-=-=-=-=-=-=-=-=-=-=-=-=
  53.  
  54. // Qrator Labs Support
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement