02-24-2017 03:29 AM - edited 03-05-2019 08:05 AM
Hi,
I want to track my bgp peer session and if it is down I want to remove my policy based routing. I could not find any configuration example for that purpose. Is it possible to track bgp sessions with ip sla?
Thanks.
02-24-2017 04:21 AM
Hello,
I don't think you can directly track a BGP session. However, you could do a TCL or EEM script that takes action based on BGP neighbor/up/down notifications...
02-24-2017 09:00 AM
Here is an example. If you post the exact config you want to modify, we can customize the below script.
event manager applet BGP_DOWN_REMOVE_POLICY
event syslog pattern “.*%BGP-5-ADJCHANGE:neighbor x.x.x.x DOWN”
action 1.0 cli command “enable”
action 2.0 cli command “conf t”
action 3.0 cli command “router bgp xxx”
action 4.0 cli command “no neighbor x.x.x.x route-map POLICY_ROUTE out”
action 5.0 cli command “exit”
action 6.0 cli command “clear ip bgp x.x.x.x soft in”
action 7.0 cli command “end”
action 8.0 cli command “wr”
action 9.0 mail from "user@example.com" to "user@example.com" subject "BGP Neighbor x.x.x.x down" server "x.x.x.x" body "Policy route to neighbor x.x.x.x has been removed"
This script removes the line 'neighbor x.x.x.x route-map POLICY_ROUTE out' from your BGP configuration when the BGP neighbor is down.It also sends an email to you, notifying you that the neighbor is down, and that the policy has been removed.
02-27-2017 03:30 AM
I want to remove the policy route,
What will happen after the bgp session is established again?
interface GigabitEthernet0/0.40
ip policy route-map ISPExit
02-27-2017 03:58 AM
Hi
As Georg mentioned, you can use that script to track the BGP neighbor behavior, it is useful if you have redundancy and in order to avoid any flapping, remember if you are passing voice over the BGP it will be affected, the reestablish must be done manually otherwise if you want, you could have other EEM script, example (taking as reference Georg's script):
event manager applet BGP_UP_REESTABLISH_POLICY
event syslog pattern “.*%BGP-5-ADJCHANGE:neighbor x.x.x.x UP”
action 1.0 cli command “enable”
action 2.0 cli command “conf t”
action 3.0 cli command “router bgp xxx”
action 4.0 cli command “neighbor x.x.x.x route-map POLICY_ROUTE out”
action 5.0 cli command “exit”
action 6.0 cli command “clear ip bgp * soft”
action 7.0 cli command “end”
action 8.0 cli command “wr”
Basically you can include the actions with the commands that you would like to execute once the message is received, so the EEM script will detect the message and execute the command lines in order using the sequence.
Then you will have 2 scripts to have automatic failover and restore. But remember if you have sensitive traffic like voice and you have redundancy paths, I'll select reestablish the bgp neighbor manually and verify with the provider the root cause before. Hope it is useful
:-)
02-27-2017 04:21 AM
Last question :
action 1.0 cli command “enable”
What will be happening to the password? Is it getting to enable mode without password, I mean the script.
02-27-2017 04:36 AM
Hi
How it is done by the device, the enable password will be bypassed.
You can use this debug in order to see how it is being applied it is very useful for troubleshooting and determine if the script is working properly without inconveniences:
debug event manager action cli
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide