BGP · Topic 5 of 5

Configuring, Monitoring and BGP Routing Policy

JN0-650 study page on configuring, monitoring and troubleshooting BGP on Junos, plus BGP import and export policy, default policies and route filters.

  • 5 min
In a nutshell
  • Default import accepts all; default export advertises only active BGP routes.
  • To advertise local, static or IGP routes you need an export policy with from protocol and accept.
  • The most specific attach point wins: neighbor over group over global.

What it is

This page ties the chapter together. You build a BGP configuration, read the show commands that describe it, and use routing policy to decide what BGP accepts and announces.

BGP policy is where most of the real configuration work happens, because BGP does not choose routes by metric. It follows the policy you apply.

Neighbor UPDATEimport policyRouting tableinet.0export policyNeighborAdvertised routes

How it works

Default policies

BGP has built-in behavior when you configure no policy:

DirectionDefault
ImportAccept all received BGP routes
ExportAdvertise active BGP routes; follow the IBGP and EBGP rules; do not advertise routes from other protocols

So to advertise your own prefixes, such as a loopback, a static route or an OSPF route, you must write an export policy.

set policy-options policy-statement ANNOUNCE term 1 from protocol [ direct static ]
set policy-options policy-statement ANNOUNCE term 1 from route-filter 203.0.113.0/24 exact
set policy-options policy-statement ANNOUNCE term 1 then accept
set protocols bgp group EXT export ANNOUNCE

Where policy is attached

Policy can be attached at group level or at neighbor level. The most specific level applies.

set protocols bgp import GLOBAL-IN
set protocols bgp group EXT import GROUP-IN
set protocols bgp group EXT neighbor 192.0.2.2 import NEIGHBOR-IN

A chain such as import [ P1 P2 P3 ] evaluates policies left to right until one accepts or rejects. If none takes a final action, the default policy for that protocol applies. Use then next policy to move to the next policy in the chain, or then next term for the next term in the same policy.

Route filters

Match typeMatches
exactOnly that prefix and length
orlongerThe prefix and any longer prefix inside it
longerLonger prefixes only, not the prefix itself
upto /nThe prefix and prefixes up to length n
prefix-length-range /a-/bPrefixes between the two lengths
set policy-options policy-statement NO-LONG term 1 from route-filter 0.0.0.0/0 prefix-length-range /25-/32
set policy-options policy-statement NO-LONG term 1 then reject

You can also match from neighbor, from as-path, from community, and from protocol. In an export policy, matching from protocol bgp selects routes learned by BGP.

Typical policy goals

GoalTool
Choose an exitImport: then local-preference
Influence inbound trafficExport: as-path-prepend or metric
Block bogon or too long prefixesImport: route-filter with reject
Advertise your prefixesExport: from protocol plus accept
Mark routes for a customercommunity add
Act as next hop for IBGPthen next-hop self

Show commands

QuestionCommand
State of every session and prefix countsshow bgp summary
Details, families and errors for one peershow bgp neighbor 192.0.2.2
What did the peer send, before policyshow route receive-protocol bgp 192.0.2.2
What do we send the peershow route advertising-protocol bgp 192.0.2.2
All BGP routes in the tableshow route protocol bgp
Routes that cannot be usedshow route hidden
Why this path was chosenshow route 198.51.100.0/24 extensive

In show bgp summary the last column for an Established peer shows counts of active, received, accepted and damped prefixes. A peer that is not Established shows its state name instead.

Exam tip

show route receive-protocol bgp shows what the peer sent. If the route is there but not in show route protocol bgp, a policy or hidden route is the cause. If it is not there, the peer never sent it.

Troubleshooting a session

State or symptomCheck
IdleNo route to the peer, or the neighbor is administratively disabled or waiting after an error
Connect or ActiveTCP is failing: no route, wrong neighbor address, wrong local-address, a filter blocking port 179, or multihop missing
OpenSent with NOTIFICATIONLook at the error in show bgp neighbor: bad peer AS, bad hold time or authentication
Established, route missingImport policy, hidden next hop, or the peer's export policy
Established, route not advertisedYour export policy, or the IBGP re-advertisement rule
Session up?noTCP and AS checksSession up?yesRoute received?Route received?noPeer export policyRoute received?yesAccepted and active?Accepted and active?noImport policy or hidden next hop

When you change policy, use clear bgp neighbor 192.0.2.2 soft to reapply it without resetting the session.

Watch out

Changing a policy does not automatically change what was already advertised. Soft clear refreshes it; a hard clear resets the session.

Common mistakes

Expecting direct or static routes to be advertised by default. BGP exports only BGP routes without an export policy.

Ending an import policy with no action. Routes fall through to the default and are accepted, which may not be your intention.

Using orlonger when exact was meant. It matches too much.

Applying policy at group level but a neighbor-level policy exists. The neighbor-level policy takes over for that neighbor.

Hard resetting a production session to test policy. Use a soft clear.

What to remember for the exam

  • Default import accepts all; default export advertises only active BGP routes.
  • To advertise local, static or IGP routes you need an export policy with from protocol and accept.
  • The most specific attach point wins: neighbor over group over global.
  • Route filter match types: exact, orlonger, longer, upto, prefix-length-range.
  • show route receive-protocol bgp and advertising-protocol bgp show what comes in and goes out.
  • show route hidden finds routes that exist but cannot be used.
  • clear bgp neighbor ... soft reapplies policy.

Check yourself

  • Why is a static route not advertised to an EBGP peer, with no export policy?

    The default export policy advertises only BGP routes, so an export policy with from protocol static and accept is needed.

  • How do you see what a peer sent before your import policy?

    show route receive-protocol bgp <peer> (with hidden for rejected or unusable routes).

  • What does route-filter 10.0.0.0/8 orlonger match?

    The prefix 10.0.0.0/8 and every longer prefix inside it.

Topic 5 of 5 in BGP

Test yourself on BGP

The full Juniper JNCIP-ENT JN0-650 question bank has 858 questions, with timed practice exams and an explanation for every answer.

This study guide is independent and is not affiliated with, endorsed by, or sponsored by Juniper. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.