cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1739
Views
0
Helpful
6
Replies

Script to disable G0/0 port if assigned IP address is not reachable

Alex Caldas
Level 1
Level 1

Hi folks

 

First of all, I'm not a network guy, I'm a developer guy.

I'm trying to help my network guy with the following...

 

We have a Cisco 1921 router where G0/0 port is hooked up to a Comcast modem (primary line) which is assigned a single static IP address.

G0/1 port is hooked up to a wireless Raven X device powered by Sprint (backup line).

 

Idea is when Comcast goes down, all traffic goes to the G0/1 interface (Sprint).

However, it seems router can only switch traffic if physical G0/0 port is down which means unplugging the cable.

No matter if Comcast is really down, the Comcast modem will always be up on the G0/0 port.

 

So, I wonder if there is a way we could write a script to check if the assigned Comcast static IP address is reachable.

If it is not reachable, disable the G0/0 to force all traffic to go to the G0/1 interface.

When the Comcast IP is reachable, re-enable the G0/0 interface back.

 

Not sure if possible, but I think Cisco routers must be running a type of OS which allows some kind of programming and scheduling.

 

Thoughts?

Thanks for reading.

 

...Alex

2 Accepted Solutions

Accepted Solutions

Joe Clarke
Cisco Employee
Cisco Employee

This isn't entirely possible.  While you can certainly test if a port is viable or not, once you disable it, how do you retest its viability?

 

One thing that could make this possible is to switch the default route.  I can't imagine simply having an interface up when it doesn't have routes pointing out of it would disrupt traffic.  In that case you could test the point-to-point connectivity out of that interface, then switch the default route back if the connectivity works.

View solution in original post

Assuming your provider gives you IP address 10.1.1.2 and they have 10.1.1.1 on their end of the link, you pint 10.1.1.1 to test to see if the link is really up.  This assumes that when it's not up that the ping would fail.

 

This use case is rather common and most use IP SLA to do the ping, then track the result with object tracking.  EEM then reacts to the change in the object tracking state.  I have an example of this in my CiscoLive automation deck at https://www.ciscolive.com/online/connect/sessionDetail.ww?SESSION_ID=78628&backBtn=true .

View solution in original post

6 Replies 6

Leo Laohoo
Hall of Fame
Hall of Fame

Alex, 

 

Move this thread to the EEM section.  

 

Your request is very common, in regards to EEM, and can be found in that section of the forum.

Leo,

 

Thanks for your response.

 

Post moved to EEM ;)

 

...Alex

Joe Clarke
Cisco Employee
Cisco Employee

This isn't entirely possible.  While you can certainly test if a port is viable or not, once you disable it, how do you retest its viability?

 

One thing that could make this possible is to switch the default route.  I can't imagine simply having an interface up when it doesn't have routes pointing out of it would disrupt traffic.  In that case you could test the point-to-point connectivity out of that interface, then switch the default route back if the connectivity works.

Alex Caldas
Level 1
Level 1

Joseph,

 

Agree and it makes total sense, why disable the G0/0 interface when all I need is the traffic to out on G0/1 when G0/0 assigned static IP is not reachable and switch back when it is.

For me the logic to switch traffic between interfaces is whether the router is able to "reach" (ping) the assigned static IP address on the interface; however, you seem to refer to a certain "point to point connectivity" test, could you please elaborate on this particular test?

Also, do you mind giving me some script coding to illustrate how to code this script on the router

Thanks for your prompt response.

 

 

Assuming your provider gives you IP address 10.1.1.2 and they have 10.1.1.1 on their end of the link, you pint 10.1.1.1 to test to see if the link is really up.  This assumes that when it's not up that the ping would fail.

 

This use case is rather common and most use IP SLA to do the ping, then track the result with object tracking.  EEM then reacts to the change in the object tracking state.  I have an example of this in my CiscoLive automation deck at https://www.ciscolive.com/online/connect/sessionDetail.ww?SESSION_ID=78628&backBtn=true .

alexanderkieser
Level 1
Level 1

Read up on tracking and ip SLA, your router will automaticlly switch to the other route and vise versa. No need for EEM for this.

Review Cisco Networking for a $25 gift card