cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2181
Views
0
Helpful
5
Replies

how to detect using EEM which route-map is applied to a BGP neighbor ?

gnijs
Level 4
Level 4

I need to be able to detect which route-map is applied to a BGP neighbor in an EEM script.

For example:

 

if route-map PRIMARY is configured on neighbor x, then run the command "standby 80 prio 160"

if route-map BACKUP is configured on neighbor x, however, then run the command "standby 80 prio 150"

 

regards,

Geert

 

5 Replies 5

balaji.bandi
Hall of Fame
Hall of Fame

Just trying to understand what is the use case  here ?

 

This can be done manually also ? if 1 time replacement ?

BB

***** Rate All Helpful Responses *****

How to Ask The Cisco Community for Help

Use case is simple: I have two routers: one is primary , one is secondary.

But operational team can decide to switch primary to secondary and vica versa at any time.

There is an EEM script running on the router, but its behavior depends on the router being primary or secondary.

So when the function changes (ie route-maps get swapped) the script needs to behave differently.

I know, when they switch the functions (route-maps) they can also adjust the script, but that is often forgotten, so why not let the script detect itself if it is running on the primary or secondary router ?

So you looking the EEM script to trigger based on failure scenarios ? 

BB

***** Rate All Helpful Responses *****

How to Ask The Cisco Community for Help

ok, so i have managed to get this working, thanks to some old Joe Clarke scripts :-)

The script itself detects if the router has a primary or standby function and adjusts HSRP accordingly.

the name of the route-maps are PRIMARY-MAP-OUT and BACKUP-MAP-OUT

 

event manager applet default-change
event routing network 0.0.0.0/0 type modify
action 0.1 set role "NONE"
action 0.2 cli command "show ip bgp neighbor 172.31.255.246 | i map for outgoing"
action 0.3 regexp ".*\s(.*)-MAP-OUT.*" "$_cli_result" match role
action 0.4 if $role eq "PRIMARY"
action 0.5 set hpriority "160"
action 0.6 else
action 0.7 set hpriority "150"
action 0.8 end
action 1.0 syslog msg "Default route changed to $_routing_lastgateway"
action 1.1 syslog msg "Detected role: $role"
action 2.0 if $_routing_lastgateway eq "172.31.255.2"
action 3.0 cli command "enable"
action 3.1 cli command "conf t"
action 3.2 cli command "interface Fa0/0"
action 3.3 cli command "standby 80 prio 50"
action 3.4 syslog msg "Adjusted HSRP priority (Fa0/0) to 50"
action 4.0 elseif $_routing_lastgateway eq 172.31.255.246
action 5.0 cli command "enable"
action 5.1 cli command "conf t"
action 5.2 cli command "interface Fa0/0"
action 5.3 cli command "standby 80 prio $hpriority"
action 5.4 syslog msg "Adjusted HSRP priority (Fa0/0) to $hpriority"
action 6.0 end

Glad all working..may it is time to test when the link fails and auto fail over with EEM.

Hope you have tested this i guess.

 

BB

***** Rate All Helpful Responses *****

How to Ask The Cisco Community for Help

Review Cisco Networking for a $25 gift card