andrewglass3

Untitled

Apr 23rd, 2016
292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. #!/bin/vbash
  2.  
  3. ########################################################################
  4. # Script to switch between gateways depending on connection #
  5. # Relies on static routes and pings to hosts #
  6. # #
  7. # @Author Andrew Shaw #
  8. # @Date 2015-10-16 #
  9. ########################################################################
  10.  
  11. #It's for Vyatta
  12.  
  13.  
  14. #Get the Vyatta functions for configuration
  15. source /opt/vyatta/etc/functions/script-template
  16.  
  17. #Function to check the gateway
  18. function checkGateway {
  19. /usr/lib/nagios/plugins/check_ping -w 1000,50% -c 1000,50% -H $1
  20. }
  21.  
  22. #Function to set the gateway
  23. function setGateway {
  24. configure
  25. set system gateway-address $1
  26. commit
  27. # exit
  28. }
  29.  
  30. #Failover Logic
  31. while true
  32. do
  33. if checkGateway 185.60.88.85
  34. then echo "Manannan 5GHz Bow has Internet"
  35. setGateway 10.22.0.158
  36. elif checkGateway 185.60.88.86
  37. then echo "Manannan 5GHz Stern has Internet"
  38. setGateway 10.22.0.162
  39. elif checkGateway 185.60.88.87
  40. then echo "Manannan 4G Bow has Internet"
  41. setGateway 10.23.0.2
  42. elif checkGateway 185.60.88.88
  43. then echo "Manannan 4G Stern has Internet"
  44. setGateway 10.23.0.6
  45. elif checkGateway 185.60.88.89
  46. then echo "Manannan Satellite has Internet"
  47. setGateway 10.24.0.2
  48. fi
  49. sleep 1
  50. done
Add Comment
Please, Sign In to add comment