LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices

Reply
 
Search this Thread
Old 12-09-2009, 02:01 AM   #1
buff2l0
LQ Newbie
 
Registered: Apr 2009
Posts: 3

Rep: Reputation: 0
Question Script check ICMP and auto change route static


Diagram:
PHP Code:
                           GRE Tunnel ISP A
                          
|------ISP A------|
Site A----FW A (Linux)----|  GRE Tunnel     |----FW B (Linux)----Site B
                          
|------ISP B------|
                           
GRE Tunnel ISP A 
Site A connect to Site B: 2 GRE Tunnel

- Site A --> GRE Tunnel ISP A --> Site B
- Site A --> GRE Tunnel ISP B --> Site B

Default routing Site A --> Site B: GRE Tunnel ISP A

The sometimes Site A --> GRE Tunnel ISP A --> Site B: packets loss, i want script checking ICMP Packet loss and change static route to GRE Tunnel ISP B.

PS: I have use monit (http://mmonit.com/monit/) checking ICMP but only checking host down, up.

This is my script shell:

PHP Code:
#! /bin/bash

# ping_check.sh

ping_check()
{
  
ping_recv=`ping -W1 -f -c100 $1 | grep rtt | cut -f4 -d' ' | cut -f2 -d'/' | cut -f1 -d'.'`
  
ping_loss=`ping -W1 -f -c100 $1 | grep loss | cut -f3 -d',' | cut -f2 -d' ' | sed 's/\(.*\)./\1/'`
  if [ 
"$ping_recv" -gt 200 ] || [ "$ping_loss" -gt 10 ]; then
   
return 
  
else
   return 
1
  fi
}

ispa_route()
{
  
ip ro re 10.10.0.0/16 dev gre_isp_a
  ip ro re 10.20.0.0
/16 dev gre_isp_a
  ip ro re 10.30.0.0
/16 dev gre_isp_a

  current_route
=ispa
  
echo $current_route current_route
  
echo `date$current_route >> change_route.log
}
ispb_route()
{
  
ip ro re 10.10.0.0/16 dev gre_isp_b
  ip ro re 10.20.0.0
/16 dev gre_isp_b
  ip ro re 10.30.0.0
/16 dev gre_isp_b

  current_route
=ispb
  
echo $current_route current_route
  
echo `date$current_route >> change_route.log
}

ISPA_IP=1.1.1.1
ISPB_IP
=5.5.5.5

ispa_route

while [ "1" "1" ]; do
 case 
$current_route in
  ispa
)
   !(
ping_check $ISPA_IP) && ispb_route 
  
;;
  
ispb)
   !(
ping_check $ISPB_IP) && ispa_route
  
;;
  *)
 
esac
 sleep 10
done 

Last edited by buff2l0; 12-09-2009 at 03:04 AM.
 
Old 12-09-2009, 02:26 AM   #2
buff2l0
LQ Newbie
 
Registered: Apr 2009
Posts: 3

Original Poster
Rep: Reputation: 0
Who can help me? Thanks
 
Old 12-09-2009, 02:53 AM   #3
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,563
Blog Entries: 29

Rep: Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179
Sorry -- I can't but I can tell you it's not a good idea to bump your own questions on LQ because zero-reply threads are automatically bumped and by bumping it yourself you have taken it off the zero-reply thread list.

It is a non-trivial question requiring expertise to answer so likely to take longer for a suitable expert to find it.

BTW, It's easier to read your text-based data if you put it in code tags (that's a link to instructions or you may prefer to use "Advanced Edit" mode which has a # button for code tags).
 
Old 12-09-2009, 03:05 AM   #4
buff2l0
LQ Newbie
 
Registered: Apr 2009
Posts: 3

Original Poster
Rep: Reputation: 0
hi @catkin I have change thread

Last edited by buff2l0; 12-09-2009 at 03:07 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
route-eth - Adding a static route gbwien Linux - Networking 5 02-24-2012 06:15 AM
writing auto start script for static routes in suse linux10.3 with shorewall 3.0 nerdnero Linux - Newbie 5 06-18-2010 06:25 PM
Help with static route noinfo Linux - Networking 1 10-05-2005 12:40 PM
How to check ICMP code through shell script? Thakowbbery Linux - Networking 2 07-19-2005 10:52 AM
SCRIPT: check if auto-mount mount-points are still mounted markus1982 Linux - Software 0 05-25-2003 06:48 AM


All times are GMT -5. The time now is 05:02 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration