Example: Configuring BGP to Advertise Inactive Routes
By default, BGP readvertises only active routes. To have the routing table export to BGP the best route learned by BGP even if Junos OS did not select it to be an active route, include the advertise-inactive statement:
In Junos OS, BGP advertises BGP routes that are installed or active, which are routes selected as the best based on the BGP path selection rules. The advertise-inactive statement allows nonactive BGP routes to be advertised to other peers.
If the routing table has two BGP routes where one is active and the other is inactive, the advertise-inactive statement does not advertise the inactive BGP prefix. This statement does not advertise an inactive BGP route in the presence of another active BGP route. However, if the active route is a static route, the advertise-inactive statement advertises the inactive BGP route.
Junos OS also provides support for configuring a BGP export policy that matches the state of an advertised route. You can match either active or inactive routes, as follows:
This qualifier only matches when used in the context of an export policy. When a route is being advertised by a protocol that can advertise inactive routes (such as BGP), state inactive matches routes advertised as a result of the advertise-inactive (or advertise-external) statement.
For example, the following configuration can be used as a BGP export policy to mark routes advertised due to the advertise-inactive setting with a user-defined community. That community can be later used by the receiving routers to filter out such routes from the forwarding table. Such a mechanism can be used to address concerns that advertising paths not used for forwarding by the sender might lead to forwarding loops.
No special configuration beyond device initialization is required before configuring this example.
In this example, Device R2 has two external BGP (EBGP) peers, Device R1 and Device R3.
Device R1 has a static route to 172.16.5/24. Likewise, Device R2 also has a static route to 172.16.5/24. Through BGP, Device R1 sends information about its static route to Device R2. Device R2 now has information about 172.16.5/24 from two sources—its own static route and the BGP-learned route received from Device R1. Static routes are preferred over BGP-learned routes, so the BGP route is inactive on Device R2. Normally Device R2 would send the BGP-learned information to Device R3, but Device R2 does not do this because the BGP route is inactive. Device R3, therefore, has no information about 172.16.5/24 unless you enable the advertise-inactive command on Device R2, which causes Device R2 to send the BGP-learned to Device R3.
Figure 1 shows the sample network.
The section Step-by-Step Procedure describes the steps on Device R2.
CLI Quick Configuration
To quickly configure this example, copy the following commands, paste them into a text file, remove any line breaks, change any details necessary to match your network configuration, and then copy and paste the commands into the CLI at the  hierarchy level.
The following example requires that you navigate various levels in the configuration hierarchy. For information about navigating the CLI, see Using the CLI Editor in Configuration Mode in the CLI User Guide.
To configure Device R2:
- Configure the device interfaces.[edit interfaces]user@R2# set fe-1/2/0 unit 0 family inet address 10.0.0.2/30user@R2# set fe-1/2/1 unit 0 family inet address 10.0.0.5/30user@R2# set lo0 unit 0 family inet address 192.168.0.2/32
- Configure the EBGP connection to Device R1.[edit protocols bgp group to_R1]user@R2# set type externaluser@R2# set neighbor 10.0.0.1 peer-as 100
- Configure the EBGP connection to Device R3.[edit protocols bgp group to_R3]user@R2# set type externaluser@R2# set neighbor 10.0.0.6 peer-as 300
- Add the advertise-inactive statement to the
EBGP group peering session with Device R3.[edit protocols bgp group to_R3]user@R2# set advertise-inactive
- Configure the static route to the 172.16.5.0/24 network.[edit routing-options static]user@R2# set route 172.16.5.0/24 discarduser@R2# set route 172.16.5.0/24 install
- Configure the autonomous system (AS) number.[edit routing-options]user@R2# set autonomous-system 200
From configuration mode, confirm your configuration by entering the show interfaces, show protocols, show policy-options, and show routing-options commands. If the output does not display the intended configuration, repeat the instructions in this example to correct the configuration.
If you are done configuring the device, enter commit from configuration mode.
Confirm that the configuration is working properly.
Verifying the BGP Active Path
On Device R2, make sure that the 172.16.5.0/24 prefix is in the routing table and has the expected active path.
user@R2> show route 172.16.5
inet.0: 7 destinations, 8 routes (7 active, 0 holddown, 0 hidden) + = Active Route, - = Last Active, * = Both 172.16.5.0/24 *[Static/5] 21:24:38 Discard [BGP/170] 21:21:41, localpref 100 AS path: 100 I, validation-state: unverified > to 10.0.0.1 via fe-1/2/0.0
Device R2 receives the 172.16.5.0/24 route from both Device R1 and from its own statically configured route. The static route is the active path, as designated by the asterisk (*). The static route path has the lowest route preference (5) as compared to the BGP preference (170). Therefore, the static route becomes active.
Verifying the External Route Advertisement
On Device R2, make sure that the 172.16.5.0/24 route is advertised toward Device R3.
user@R2> show route advertising-protocol bgp 10.0.0.6
inet.0: 6 destinations, 7 routes (6 active, 0 holddown, 0 hidden) Prefix Nexthop MED Lclpref AS path 172.16.5.0/24 Self 100 I
Device R2 is advertising the 172.16.5.0/24 route toward Device R3
Verifying the Route on Device R3
Make sure that the 172.16.6.0/24 prefix is in Device R3’s routing table.
user@R3> show route 172.16.5.0/24
inet.0: 5 destinations, 5 routes (5 active, 0 holddown, 0 hidden) + = Active Route, - = Last Active, * = Both 172.16.5.0/24 *[BGP/170] 00:01:19, localpref 100 AS path: 200 100 I, validation-state: unverified > to 10.0.0.5 via fe-1/2/1.0
Device R3 has the BGP-learned route for 172.16.5.0/24.
Experimenting with the advertise-inactive Statement
See what happens when the advertise-inactive statement is removed from the BGP configuration on Device R2.
On Device R2, deactivate the advertise-inactive statement.[edit protocols bgp group to_R3]user@R2# deactivate advertise-inactiveuser@R2# commit
On Device R2, check to see if the 172.16.5.0/24 route is advertised toward Device R3.
user@R2> show route advertising-protocol bgp 10.0.0.6
As expected, the route is no longer advertised.
On Device R3, ensure that the 172.16.5/24 route is absent from the routing table.
user@R3> show route 172.16.5/24
Device R1 advertises route 172.16.5/24 to Device R2, but Device R2 has a manually configured static route for this prefix. Static routes are preferred over BGP routes, so Device R2 installs the BGP route as an inactive route. Because the BGP route is not active, Device R2 does not readvertise the BGP route to Device R3. This is the default behavior in Junos OS. If you add the advertise-inactive statement to the BGP configuration on Device R2, Device R2 readvertises nonactive routes.