BGP Router Configuration

This statement enters BGP server mode for the specified VRF and enters config-bgp mode.

tnsr(config)# route dynamic bgp
tnsr(config-frr-bgp)# server vrf default


Older versions of TNSR specified the ASN here, rather than a VRF name. That format has been deprecated. The ASN is still mandatory, but is now set by the as-number <asn> command within config-bgp mode.

BGP mode defines the main behaviors of the BGP daemon, as well as the neighbors and behavior of BGP for different address families, among other possibilities.

From within config-bgp mode, the following commands are available:

as-number <asn>

Mandatory. Sets the autonomous system number for this BGP instance.

address-family (ipv4|ipv6) (unicast|multicast)

Enter BGP Address Family Configuration mode.


Allow Martian next hops.

Martians are addresses that would otherwise be considered invalid such as reserved private networks and link-local addresses.


Instructs the BGP daemon to always consult MED values in routes, no matter which AS the routes were received through.

bestpath as-path (confed|ignore|multipath-relax|as-set|no-as-set)

Controls how the BGP daemon determines the best path to a destination. May be one of:


Considers the length of confederation path sets and sequences.


Ignores AS path lengths when computing the route to a destination.


Consider paths of equal length when choosing between multiple paths to a destination, rather than looking for an exact match. This allows load sharing across different AS paths, so long as they are of equal length.


For use with multipath-relax, it adds AS set information for aggregate routes.


For use with multipath-relax, it prevents AS set generation.

bestpath compare-routerid

Uses the router ID of peers (or originator ID, if present) to break ties when computing paths to a destination based on other information. A lower router ID will win in a tie.

bestpath med confed

Compare confederation path MEDs

bestpath med missing-as-worst

If a route is missing MED information, it will be considered least preferred.

client-to-client reflection

Enables reflection of routes from one client to another client.

cluster-id (<ipv4>|<value>)

Configures the BGP daemon to participate in route reflection with the given cluster ID. The ID may be given in IP address (dotted quad) notation or as an unsigned 32-bit integer (1-4294967295).


If the ID is set to an integer the BGP daemon converts the ID to the equivalent IP address value internally. Thus, when viewing the running BGP configuration, the cluster ID value will always display as an IP address.

coalesce-time <value>

Configures the Subgroup coalesce timer, in milliseconds (1-4294967295).

confederation identifier <ASN>

Configures an AS number for the entire group of IBGP routers participating in confederation.

confederation peer <ASN>

Configures the sub-AS number for the subset of peers inside a group of IBGP routers participating in confederation.

dampening [penalty <val> [reuse <val> [suppress <val> [maximum <max>]]]]

This command enables BGP route flap dampening (RFC 2439) to prevent unstable routers from adversely affecting routing behavior.

penalty <penalty-val>

The time duration during which the stability value will be reduced by half if the route is unreachable.

reuse <reuse-val>

Stability threshold that must be crossed for a route to be reused.

suppress <suppress-val>

Stability threshold that, when crossed, a route will be suppressed.

maximum <suppress-max>

Maximum time to suppress a route considered stable.


Determine route selection locally, even when MED values are present. Picks the best MED path from neighbor advertisements.


Disable checking if nexthop is an eBGP session.


Determines whether or not BGP will exchange routes with peers when a policy is not present allowing that to take place. For example, with this active, BGP will not exchange routes with a neighbor unless there is a route map configured on the address family neighbor entry which matches and permits the routes inbound and outbound.


This behavior is enabled by default on new configurations in TNSR 21.07 and later, and is disabled when upgrading from older installations to preserve the pre-existing behavior in those environments. To disable, use no ebgp-requires-policy.


Consider creating appropriate route maps and using them rather than disabling the policy check, as using policies is a more secure behavior, and can prevent unintended routes from being exchanged.

graceful-restart <keyword> [<value>]

Configures global BGP graceful restart behavior. For details, see Graceful Restart.


Controls whether or not all BGP peers (IPv4 and IPv6) are automatically included in the IPv4 unicast routing address family by default.

This behavior is active by default and can be deactivated by negating the directive (no ipv4-unicast-enabled).

When this directive is active, all peers (IPv4 and IPv6) can exchange IPv4 unicast routes by default.

When this directive is negated peers must be manually added to the IPv4 unicast address family to exchange IPv4 routes.


Users who prefer to keep their IPv4 and IPv6 peers separate can opt to disable this behavior and then add the peers into their appropriate IPv4 or IPv6 unicast address families manually.


Most examples in the documentation already include adding IPv4 peers to the IPv4 address family manually, so users following those examples need not make further adjustments for IPv4 peers when changing this setting.

listen limit <value>

Maximum number of dynamic neighbors from 1-5000.

listen range (<ip4-prefix>|<ip6-prefix>) peer-group <peer-group-name>

Listen range for dynamic neighbors.


Instructs the BGP daemon to log changes in neighbor adjacencies. This is useful for tracking changes to neighbor relationships, especially during initial configuration.

See also

See Logging for information on dynamic routing logging.

long-lived-graceful-restart-stale-time <value>

Part of global BGP graceful restart configuration. For details, see Graceful Restart.

max-med administrative [<med>]

Sends the defined MED value, or 4294967294 when unset, at all times.

max-med on-startup period <seconds> [<med>]

Sends the defined MED value, or 4294967294 when unset, only at startup for the defined period in seconds, from 5-86400.

neighbor <peer>

Enter BGP Neighbor Configuration mode.

network import-check

Checks if a BGP network route exists in IGP before creating BGP table entries.


This behavior is enabled by default on new configurations in TNSR 21.07 and later, and is disabled when upgrading from older installations to preserve the pre-existing behavior in those environments. To disable, use no network import-check.

route-reflector allow-outbound-policy

Allows attributes modified by route maps to be reflected.

router-id <A.B.C.D>

Sets the router ID for the BGP daemon. This is typically set to an IP address unique to this router, and commonly is set to a local private address.

timers keep-alive <interval> hold-time <hold-time>

Configures the intervals between keep alive messages and how long to wait for a response before considering the peer unreachable.


When changing these values the BGP session must be restarted to reflect the new timers. This can be accomplished by clearing the session, for example:

tnsr(config)# route dynamic bgp
tnsr(config-frr-bgp)# session clear *
tnsr(config-frr-bgp)# exit
tnsr(config)# exit
update-delay <delay>

Keeps BGP in a read-only mode for the specified time after the daemon restarts or peers are cleared.

write-quanta <packets>

Controls the size of peer update transmissions.

Graceful Restart

The graceful restart feature allows BGP routers to maintain their established routes in the event of a BGP daemon crash or similar unexpected event.


This behavior does not apply in cases when BGP is stopped or restarted naturally (e.g. manual stop/restart or changing settings).

This feature is configured by the graceful-restart command from within config-bgp mode.

graceful-restart (enable|helper|disable)

Enables or disables graceful restart globally.

helper mode preserves routes from the restarting router for a specified period of time.

By default this is enabled and in helper mode.


This behavior can be overridden on a per-peer basis. See BGP Neighbor Configuration.

graceful-restart notification

Enables support for graceful restart in BGP NOTIFICATION messages.

Peers must be reset after changing this behavior.

graceful-restart preserve-fw-state

Whether preserve the forwarding state for routes or not.

graceful-restart restart-time <value>

This is the estimated time, in seconds, it will take for TNSR to re-establish a BGP session after a restart.

The value can be within the range 0-4095. The default value is 120.

graceful-restart rib-stale-time <value>

The amount of time, in seconds, that TNSR will retain stale routes in the RIB.

The value can be within the range 1-3600.

graceful-restart select-defer-time <value>

Maximum amount of time, in seconds, TNSR will defer route selection after restart.

The value can be within the range 1-3600.

graceful-restart stalepath-time <value>

The maximum amount of time, in seconds, TNSR will hold onto stale paths from a restarting peer.

The value can be within the range 1-4095.

long-lived-graceful-restart-stale-time <value>

The maximum amount of time, in seconds, TNSR will wait before purging long-lived stale routes from routers in helper mode.

This only affects graceful restart mode.

The value can be within the range 0-16777215. A value of 0 means the feature is disabled (default).

Graceful Restart Example

This example configures the BGP daemon for graceful restart.

tnsr(config-bgp)# graceful-restart enable
tnsr(config-bgp)# graceful-restart preserve-fw-state
tnsr(config-bgp)# graceful-restart restart-time 120
tnsr(config-bgp)# graceful-restart rib-stale-time 120

This particular combination of settings results in the following behavior if the BGP daemon goes offline:

  • TNSR attempts to continue forwarding traffic during BGP downtime.

  • TNSR keeps routes received from neighbors for at least rib-stale-time (120 seconds).

  • TNSR advertises a time period of restart-time (120 seconds) to its neighbor peers, indicating they can rely on/support packet forwarding for that duration while BGP on TNSR restarts.

Viewing Graceful Restart Status

To view the current graceful restart behavior and status, use the show route dynamic bgp [vrf <vrf-name>] (ipv4|ipv6) neighbors <peer> graceful-restart as described in BGP Status:

tnsr# show route dynamic bgp ipv4 neighbors graceful-restart

Codes: GR - Graceful Restart, * -  Inheriting Global GR Config,
       Restart - GR Mode-Restarting, Helper - GR Mode-Helper,
       Disable - GR Mode-Disable.

Global BGP GR Mode :  Helper

BGP neighbor is
    Local GR Mode: Helper*

    Remote GR Mode: Helper

    R bit: False
    N bit: True
      Configured Restart Time(sec): 120
      Received Restart Time(sec): 120
      Configured LLGR Stale Path Time(sec): 0
    IPv4 Unicast:
      F bit: False
      End-of-RIB sent: Yes
      End-of-RIB sent after update: No
      End-of-RIB received: Yes
        Configured Stale Path Time(sec): 360
        LLGR Stale Path Time(sec): 0