Code to continually reconnect the PPP session until the current ISP default gateway is either a target IP we are looking to connect to, or a new IP not on a list of known working gateways. Useful for ISP support staff to test routing issues associated with certain gateways as reported by users or by an end user to ensure they do not connect to a gateway with a current issue, when 3rd line or NOC are dragging their feet.
The first code block is for targeting a specific default gateway IP to connect to, the second is if you know a list of default gateways that work ok and want to look for any others to test.


  1. #Set targetgateway to the IP of the ISP default gateway you want to connect to.
  2. #Set the intWAN and intATM appropriately for your cpe.
  3. set targetgateway 85.210.250.36
  4. set found 0
  5. set intWAN "Dialer0"
  6. set intATM "atm0/0/0"
  7.  
  8. while {$found == 0} {
  9. set ipConnected [exec "show ip route connected | include $intWAN"]
  10. if {[string match "*$targetgateway*" $ipConnected]} {
  11. puts "target gateway of $targetgateway found..exiting script for testing"
  12. set found 1
  13. #If a back up link is configured the script could now send an email or poll a PHP page to alert the admin that router is ready for testing
  14. break
  15. } else {
  16. exec "clear int $intATM"
  17. after 8000
  18. }
  19. }



  1. #Or if you know which default gateway(s) work and want to find if there are others to test.
  2. #Set workingGateways with as many IP's you know work, separated by a space.
  3. set workingGateways {###.###.###.### ###.###.###.###}
  4. set foundNew 0
  5. set intWAN "Dialer0"
  6. set intATM "atm0/0/0"
  7. while {$foundNew == 0} {
  8. set ipConnected [exec "show ip route connected | include $intWAN"]
  9. foreach workingIP $workingGateways {
  10. if {![string match "*$workingIP*" $ipConnected]} { set foundNew 1}
  11. }
  12. if {$foundNew} {
  13. puts "new gateway found..exiting script for testing\n$ipConnected"
  14. puts "Once finished testing if looking for more Gateways remember to add this new ip to the workingGateways list before running the script again"
  15. #If a back up link is configured the script could now send an email or poll a PHP page to alert the admin that router is ready for testing
  16. break
  17. } else {
  18. exec "clear int $intATM "
  19. after 8000
  20. }
  21. }