Skip to main content

IPIP tunnel creator via bash

   1:  #!/bin/bash
   2:  #
   3:  # Tunnel ipip Automation
   4:  # Creator: Shiran Guez
   5:  #
   6:  TUN_ETH="eth0"
   7:  IP_DEST_EXT=""
   8:  TUNNEL_IP_SRC=""
   9:  TUNNEL_IP_DST=""
  10:  _CREATE_ () {
  11:  echo "Please enter the name of your local interface [eth0 is default]: "
  12:  echo "[ To Skip enter >>>skip<<< ]"
  13:  while :;
  14:  do
  15:      read COMM_ETH
  16:      if [ "$COMM_ETH" == "skip" ] ;then 
  17:          break
  18:      elif [ "$COMM_ETH" == "eth0" ] ;then
  19:          break
  20:      else
  21:          ifconfig "$COMM_ETH" >/dev/null
  22:          if [ $? -eq 0 ] ;then
  23:              TUN_ETH="$COMM_ETH"
  24:              break
  25:          else
  26:              echo "You have entered a wrong ethernet interface"
  27:              echo "Please try again: "
  28:          fi
  29:      fi
  30:   
  31:  done
  32:  localip=$(ifconfig $TUN_ETH | grep Bcast | awk '{print $2}' | awk -F: '{print $2}')
  33:  echo "Please enter the destination IP for the tunnel: "
  34:  while :;
  35:  do
  36:      read IP_DEST_EXT
  37:      echo "Are you sure $IP_DEST_EXT is a valid IP [Y]:"
  38:      read ANS_ME
  39:      ANS_ME=$(echo $ANS_ME | tr a-z A-Z)
  40:      if [ "$ANS_ME" == "Y" ] ;then
  41:          break
  42:      else
  43:          echo "Please enter destination again:"
  44:       fi
  45:  done       
  46:  echo "Please enter tunnel IP and Peer Address: "
  47:  while :;
  48:  do  
  49:      echo "IP : "    
  50:          read TUNNEL_IP_SRC
  51:      echo "Peer : "
  52:      read TUNNEL_IP_DST
  53:      echo "Peer subnet mask [ /16 , /24 ...]: "
  54:      read TUNNEL_IP_DST_MASK
  55:      echo "Tunnel IP will be $TUNNEL_IP_SRC and its peer address will be $TUNNEL_IP_DST using subnet mask $TUNNEL_IP_DST_MASK"
  56:      echo "Please confirm [Y]:"
  57:          read ANS_ME_NOW
  58:          ANS_ME_NOW=$(echo $ANS_ME_NOW | tr a-z A-Z)
  59:          if [ "$ANS_ME_NOW" == "Y" ] ;then
  60:                  break
  61:          else
  62:                  echo "Please enter again:"
  63:          fi
  64:   
  65:  done
  66:  ip tu ad ipiptun mode ipip local $localip remote $IP_DEST_EXT ttl 64 dev $TUN_ETH
  67:  ip ad ad dev ipiptun $TUNNEL_IP_SRC peer $TUNNEL_IP_DST/$TUNNEL_IP_DST_MASK
  68:  ifconfig ipiptun up
  69:  }
  70:   
  71:  _DESTROY_ () {
  72:  ip add | grep ipiptun > /dev/null
  73:  if [ $? -eq 0 ] ;then
  74:      ifconfig ipiptun down
  75:      echo "Tunnel was removed"
  76:  else
  77:      echo "No Tunnel to remove"
  78:  fi
  79:  }
  80:   
  81:  lsmod | grep ipip > /dev/null
  82:  if [ $? -eq 0 ] ;then
  83:      while :;
  84:      do
  85:          echo "Please enter 1 to create or 2 for removing a tunnel"
  86:          read SELECTION
  87:          if [ "$SELECTION" == "1" ] ; then
  88:              _CREATE_
  89:              break
  90:          elif [ "$SELECTION" == "2" ] ; then
  91:              _DESTROY_
  92:              break
  93:          fi
  94:      
  95:      done
  96:  else
  97:      echo "ipip module is not loaded try to first load the ipip module and then run the tool again, Thank you!"
  98:  fi
Post a Comment

Popular posts from this blog

Step By Step MPLS – Basic MPLS Setup

Initial configuration , very basic with no MPLS, connectivity only to directly connected interfaces.R1R2R3R4!
!
!
interface Loopback0
ip address 1.1.1.1 255.255.255.255
!
interface FastEthernet0/0
ip address 10.0.31.1 255.255.255.0
duplex auto
speed auto
!
!
!
interface Loopback0
ip address 2.2.2.2 255.255.255.255
!
interface FastEthernet0/0
ip address 10.0.42.2 255.255.255.0
duplex auto
speed auto
!
!
!
interface Loopback0
ip address 3.3.3.3 255.255.255.255
no clns route-cache
!
interface FastEthernet0/0
ip address 10.0.31.3 255.255.255.0
duplex auto
speed auto
  no clns route-cache
!
interface Serial1/0
ip address 10.0.43.3 255.255.255.0
  serial restart-delay 0
no clns route-cache
!
!
!
interface Loopback0
ip address 4.4.4.4 255.255.255.255
no clns route-cache
!
interface FastEthernet0/0
ip address 10.0.42.4 255.255.255.0
duplex auto
speed auto
!
interface Serial1/0
ip address 10.0.43.4 255.255.255.0
  serial restart-delay 0
no clns route-cache
!
adding to the following configuration MPLS labels we will start wi…

VRF Maximum Routes

Maximum routes under customer vrf, if the service provider had unlimited resources he would not have needed that!
however normally resources are limited and expensive, and Service provider would like to make money from his available resources. maximum routes configured under VRF provide a mean of controlling PE local resource and abuse avoidance from the CE side.I have vrf called DC_EXTRANET, you can see that I have 16 routes, I have configured 10 maximum routes under that vrf however I did not want to be aggressive so I have set the warning only option. See that immediately I get a notice that I have more routes then the maximum, however no action is taken other then alerting and sending a syslog. ! PE_ashdod_otherisp.n(config-vrf)# maximum routes 10 warning-only % The current number of routes in the routing table is equal to, or exceeds the configured warning limit PE_ashdod_otherisp.n(config-vrf)# *Nov 26 20:39:41.175: %IPRT-3-ROUTELIMITWARNING: IP routing table limit warning - DC_…

ISIS Database Reading

ISIS is simple to operate normally while everything is working, most common deployments are flat network based on L2, however when there is a problem and we need to start troubleshooting then people start to get lost.So I would like to provide some tools on how to read ISIS database.notice to the “*” sign, that mean LSP was generated on the router you did the show command, you can see that host name from the show command match also host name on the LSPID,LSPID identified by hostname.xx-yy,  xx is normally 00 unless that LSP is pseudo node LSP generated by DIS , yy is representing the number of fragments for that LSP 00 – FF (max 255 fragments, plenty), most cases all the important information will be in 00 unless there are many fragments.LSP Holdtime is the amount of time an LSP will stay in database without any refresh.ATT/P/OL - 0/0/0, ATT bit or attached bit is used on L1/L2 connected to L1 node, if set to 1 L1 node will generate default route to the best L1/L2 node (best metric)AT…