bgp peer switch script

Hello, I have nodes with 2 uplinks for redundantie
I have two bgp peers on the node peer 1 is enabled peer 2 is disabeld
Now a want a script that if bgp peer 1 go down peer 2 would be enabled
And vice versa if bgp peer go’s back online that bgp peer2 becomes disable

Any a idee?

how are you enabling and disabling each peer?

I want a script at failure of the bgp peer.I don’t want it self off
Thanks for reply

with command in script

/routing bgp peer enable

/routing bgp peer disable

But i want that the script see that peer1 is down and enable automatic peer2
and vice versa if peer1 back online that peer2 disable

Something with netwatch ore so


:if ([/routing bgp peer get [find name=“xxx”] state] != “established”) do={ .. send email here…}
In the place of email I would like to enable bgp peer2.

I want also in place of establisched that bgp peer is down
How write te script

Anybody can help?

Nowbody has a idee :frowning:

I have no experience with BGP, but here is a go:

/routing bgp peer {
    :local priPeerState [get [:pick [find name="Primary"] 0] state]
    :local secPeer [:pick [find name="Secondary"] 0]
    :local secPeerDisabled [get $secPeer disabled]
    :if ($priPeerState != "established") do={
        :if ($secPeerDisabled = true) do={
            enable $secPeer
        }
    } else={
        :if ($secPeerDisabled = false) do={
            disable $secPeer
        }
    }
}

Thanks, i try this and let you know if this works.