Description

This article describes how to use event-options in Junos OS to automatically modify the device configuration when a Bidirectional Forwarding Detection (BFD) session changes state. In this example, the router dynamically adjusts the VRRP priority based on the status of a monitored BFD session.

Symptoms

You want the router to:

  • Monitor the state of a specific BFD session.
  • Reduce the VRRP priority when the BFD session goes down, allowing the backup router to become the VRRP master.
  • Restore the original VRRP priority when the BFD session comes back up.

Solution

Using the below configuration,

set event-options policy bfd-fail events bfdd_state_up_to_down
set event-options policy bfd-fail within 1 trigger on
set event-options policy bfd-fail within 1 trigger 1
set event-options policy bfd-fail attributes-match bfdd_state_up_to_down.session-id matches 110.110.110.1
set event-options policy bfd-fail then change-configuration commands "set interfaces ge-0/0/0 unit 1000 family inet address 110.110.110.62/24 vrrp-group 1 priority 99"
set event-options policy bfd-fail then change-configuration commit-options log "from event bfd-fail"
set event-options policy bfd-up events bfdd_trap_shop_state_up
set event-options policy bfd-up within 1 trigger on
set event-options policy bfd-up within 1 trigger 1
set event-options policy bfd-up attributes-match bfdd_trap_shop_state_up.remote-peer matches 110.110.110.1
set event-options policy bfd-up then change-configuration commands "set interfaces ge-0/0/0 unit 1000 family inet address 110.110.110.62/24 vrrp-group 1 priority 200"
set event-options policy bfd-up then change-configuration commit-options log "from event bfd-up" 

 

Configuration Behavior

  • The bfd-fail policy is triggered when the monitored BFD session transitions from Up to Down. The policy lowers the VRRP priority from 200 to 99 and commits the configuration automatically. This allows the backup VRRP router to assume the master role.
  • The bfd-up policy is triggered when the monitored BFD session returns to the Up state. The policy restores the VRRP priority to 200 and commits the configuration, allowing the router to resume its preferred master role.

Modification History

V1