Course contents

Module 6: Troubleshooting and PracticeLesson 6.4 (4 of 7 in this module)43 of 46 in the BGP course

Troubleshooting BGP policy

The session is up and the neighbour sends routes, yet a prefix is missing or traffic leaves by the wrong ISP. When the session is healthy, the cause is usually your own policy. This lesson shows where to look and in what order.

Advanced · 16 min read

You'll learn to locate the checkpoint where a route is stopped or changed, read policy-related show commands, and name and fix the seven most common policy faults.

When the session is up and the route is still wrong

Two earlier lessons cover sessions that will not come up and routes that stay on the router that originates them. This lesson covers the third kind of fault, the one that causes most real incidents: the session is Established, the neighbour is sending routes, and policy on one side removes a route or changes its attributes. Policy is code you wrote, and like any code it does exactly what it says, not what you meant.

A route has to pass six checkpoints on its way from one router's table into another router's routing table. Two of them are policy checkpoints, one on each side of the session. If you test in order and stop at the first failure, the fault is at that checkpoint.

Diagram
Six places a route can be stopped, and the command for each
Six places a route can be stopped, and the command for each
Six places a route can be stopped, and the command for eachSix boxes in a row from the sending router to the routing table. One: is the route in the sender's BGP table. Two: does the sender's outbound policy let it out, checked with advertised-routes. Three: does the receiver's inbound policy accept it, checked with received-routes. Four: is the route valid, with a reachable next hop. Five: is it the best path. Six: is it installed in the routing table.1 SendertableRoute there?show ip bgp2 OutboundpolicySent?neighbors Xadvertised-routes3 InboundpolicyAccepted?neighbors Xreceived-routes4 Valid?Next hopreachable?show ip bgpprefix5 Best?Attributes,tie-breakersshow ip bgpprefix6 Installed?Admin distance,RIB failureshow ip routeprefixBoxes 2 and 3 need soft-reconfiguration inbound to show received-routes

On small screens, swipe sideways or focus the diagram and use the arrow keys.

Work left to right and stop at the first box that fails. Boxes 2 and 3 are the two policy checkpoints, one on each side of the session.

Read both sides of the session

The sender and the receiver each have a say, and each has a command that shows its view. advertised-routes on the sender shows what its outbound policy let out. received-routes on the receiver shows what arrived before its inbound policy, but only if soft-reconfiguration inbound is configured. Compare them with the receiver's own table: a route in received-routes but not in show ip bgp was removed by the receiver's inbound policy.

Diagram
Locating the fault with two lists and one table
Locating the fault with two lists and one table

Compare what was sent, what arrived and what was kept.

  1. Sender saysadvertised-routes
  2. Receiver gotreceived-routes
  3. Receiver keptshow ip bgp
  4. Router usesshow ip route

A route missing between two boxes was removed by the policy between them.

Each gap between two lists points at one policy.

Next, ask the router which policies it believes are attached. This is the quickest way to catch a route map applied in the wrong direction or not applied at all.

Example output written for this lesson, not a router capture
R1#show ip bgp neighbors 192.0.2.1 policy
 Neighbor: 192.0.2.1, Address-Family: IPv4 Unicast
 Locally configured policies:
  route-map FROM-ISPA, in
  route-map TO-ISPA, out
The list names each route map or prefix list and the direction. If the one you expect is missing, or the direction is wrong, the configuration is the problem, not the policy's logic.

Then look at the policy itself. A route map prints its clauses in order, and a prefix list can print how many routes each line has matched.

Example output written for this lesson, not a router capture
R1#show ip prefix-list detail BOGONS
ip prefix-list BOGONS:
   count: 3, range entries: 3, sequences: 5 - 15, refcount: 3
   seq 5 permit 10.0.0.0/8 le 32 (hit count: 1, refcount: 1)
   seq 10 permit 172.16.0.0/12 le 32 (hit count: 0, refcount: 1)
   seq 15 permit 192.168.0.0/16 le 32 (hit count: 0, refcount: 1)
The hit count tells you which line matched. A count of 1 on sequence 5 means one prefix matched 10.0.0.0/8 or longer. A line with a count of 0 has not been needed yet, or it will not match what you intended.
show route-map FROM-ISPA show ip bgp neighbors 192.0.2.1 received-routes show ip bgp neighbors 192.0.2.1 advertised-routes show ip bgp 203.0.113.0

The four commands to run first for a policy fault. The last one shows the attributes after policy: local preference, communities and the best-path marker.

Seven policy faults and how to recognise them

Most policy problems are one of these seven. Each has a symptom that points at it and a command that confirms it. Read the table from the symptom outward: find what you see, run the check, then apply the fix.

Diagram
Seven common BGP policy faults
Seven common BGP policy faults
FaultWhat you seeCheckFix
Implicit denyEvery route disappears after a route map is appliedshow route-map: is there a final permit clause?Add a permit clause with no match line
Not refreshedA change was made and nothing movedshow ip bgp neighbors X policyclear ip bgp X soft in or out
Wrong directionAn attribute is set but has no effectshow ip bgp neighbors X policy: in or out?Re-apply the route map in the intended direction
Prefix rangeA prefix is not matched, or too many are matchedshow ip prefix-list detail: hit countsCorrect ge and le, or the sequence order
Community lostThe tag is missing on the next routershow ip bgp prefix: Community linesend-community toward that neighbour
Attribute conflictWrong exit after setting local preferenceshow ip bgp prefix: weight, then local preferenceRemove the attribute that ranks higher
Clause orderA broad clause catches routes firstshow route-map: sequence numbersPut specific clauses before broad ones
The clues are in the second and third columns. The fix is rarely anything but a re-applied or reordered line.

Worked example: the route map is attached the wrong way

The company wants R1 to prefer ISP A and has written a route map that sets local preference to 200. After applying it, R1 still chooses ISP B's path, which it learns through R2. R2 holds an older rule that gives ISP B routes local preference 150, so 200 should win. Start with the table, because it shows the attribute you were trying to set.

Example output written for this lesson, not a router capture
R1#show ip bgp 203.0.113.0
BGP routing table entry for 203.0.113.0/24, version 11
Paths: (2 available, best #2, table default)
  64501
    192.0.2.1 from 192.0.2.1 (11.11.11.11)
      Origin IGP, metric 0, localpref 100, valid, external
  64502
    10.255.0.2 (metric 20) from 10.255.0.2 (2.2.2.2)
      Origin IGP, metric 0, localpref 150, valid, internal, best
The ISP A path still shows local preference 100, not 200, so the route map set nothing. Do not edit the route map yet. First ask which policies are attached.
Example output written for this lesson, not a router capture
R1#show ip bgp neighbors 192.0.2.1 policy
 Neighbor: 192.0.2.1, Address-Family: IPv4 Unicast
 Locally configured policies:
  route-map ISPA-PREF, out
The route map is attached outbound. Local preference is not sent to an eBGP neighbour, and an outbound map on that session does not change what R1 receives. The fix is a change of direction, not of content.
router bgp 64500 address-family ipv4 unicast no neighbor 192.0.2.1 route-map ISPA-PREF out neighbor 192.0.2.1 route-map ISPA-PREF in end clear ip bgp 192.0.2.1 soft in

R1. Remove the outbound attachment, attach the same map inbound, then ask ISP A to resend so the map runs on the routes.

Diagram
The same route map in two directions
The same route map in two directions

Inbound changes what R1 stores. Outbound changes what R1 tells the neighbour.

In (correct)Runs on arriving routesLocal preference is storedR1 chooses with it
Out (this fault)Runs on routes sentLocal preference is droppedR1 chooses as before
Attributes you want to act on locally belong in an inbound map.
Diagram
Which direction for which goal
Which direction for which goal
GoalAttributeMap directionWhy
Make R1 prefer one exitLocal preferenceIn, from the neighbourIt is stored on arrival and shared with iBGP peers, not sent to eBGP neighbours
Make only R1 prefer an exitWeight (Cisco)InIt stays on the router and is not advertised
Make the neighbour see a longer pathAS-path prependOut, to the neighbourThe neighbour reads the path R1 sends
Suggest an entry point to a neighbour ASMEDOut, to the neighbourThe neighbour compares it between paths from the same AS
Tag routes for later policyCommunityIn or outSent to a neighbour only when send-community is configured
Attribute behaviour shown for Cisco IOS XE. Decide the direction from where the attribute must take effect.

Worked example: the range does not match

A bogon filter should remove 10.99.0.0/16 from a provider, but the prefix is still in the table. The route map is attached correctly. The fault is in the prefix list.

Example output written for this lesson, not a router capture
R1#show ip prefix-list detail BOGONS
ip prefix-list BOGONS:
   count: 1, range entries: 0, sequences: 5 - 5, refcount: 3
   seq 5 permit 10.0.0.0/8 (hit count: 0, refcount: 1)
Hit count 0 and no range entries. The line permit 10.0.0.0/8 matches only a /8, and the provider sent a /16, so nothing matched. The fix is le 32, which means 10.0.0.0/8 and any longer prefix inside it.
Diagram
What four prefix-list lines match
What four prefix-list lines match
Line10.0.0.0/810.99.0.0/1610.99.1.0/2410.99.1.128/25
permit 10.0.0.0/8YesNoNoNo
permit 10.0.0.0/8 le 32YesYesYesYes
permit 10.0.0.0/8 ge 16NoYesYesYes
permit 10.0.0.0/8 ge 16 le 24NoYesYesNo
Matches worked out by script from the prefix-list rules: a prefix must sit inside 10.0.0.0/8 and its length must fall within ge and le. With no ge or le, only the exact prefix matches.

Worked example: a community that replaced another

R1 tags routes from ISP A with 64500:100 and a second map later adds 64500:300 to mark them as backup. R2 matches 64500:100 in an outbound rule, and the rule has stopped working.

Example output written for this lesson, not a router capture
R2#show ip bgp 203.0.113.0
BGP routing table entry for 203.0.113.0/24, version 19
Paths: (1 available, best #1, table default)
  64501
    10.255.0.1 (metric 20) from 10.255.0.1 (1.1.1.1)
      Origin IGP, metric 0, localpref 100, valid, internal, best
      Community: 64500:300
Only 64500:300 is left. A set community line without the additive keyword replaces every community the route carried. The fix is set community 64500:300 additive, which adds the new tag to the existing one.
Diagram
What a route carries after each set community form
What a route carries after each set community form
Route map lineRoute carried 64500:100 beforeResult
set community 64500:30064500:10064500:300 only
set community 64500:300 additive64500:10064500:100 and 64500:300
set community none64500:100No community
(no set community line)64500:10064500:100 unchanged
Cisco IOS XE behaviour. A neighbour receives the communities only when send-community is configured toward it.

A repeatable order

You now have the whole method. Check the session first, since a route cannot cross a session that is not up. Then find the checkpoint using advertised and received routes. Then confirm the attachment with the policy command. Then read the policy and its hit counts. Then apply the fix, and soft-clear in the right direction so it takes effect. Each step eliminates one half of the problem, which is why the order matters.

Diagram
The order for a policy fault
The order for a policy fault

Confirm the session, find the checkpoint, check the attachment and the policy, then fix and soft-clear in the right direction.

  1. Sessionis itEstablished?
  2. Checkpointsent, got,kept, used
  3. Policyattached, in orout, hit counts
  4. Fixedit, thensoft clear
Stop at the first step that fails and fix that one before moving on.
Diagram
After a policy change, which clear
After a policy change, which clear
What changedCommand on R1What happens
Inbound policy on a neighbourclear ip bgp 192.0.2.1 soft inRoutes from the neighbour are evaluated again by the new policy
Outbound policy on a neighbourclear ip bgp 192.0.2.1 soft outR1 sends its routes again, run through the new policy
A mistake you need evidence ofLeave the session up and read the lists firstA hard clear removes the faulty state you want to inspect
Soft clears keep the session and the traffic. Whether the inbound clear uses a stored copy or a route refresh depends on the release and configuration.
Why not just clear the whole session?

A hard clear, clear ip bgp *, tears the session down and withdraws every route until the session is rebuilt. It also hides the evidence you need, because the faulty state is gone. A soft clear in the right direction applies the new policy to the existing session and keeps the traffic flowing.

Received-routes shows nothing but the neighbour has routes

The command works only when neighbor X soft-reconfiguration inbound is configured, and the neighbour must resend its routes after it is turned on. Enable it, run clear ip bgp X soft in, then read the list again.

Technical reference: Cisco, BGP best path selection algorithm. Output above is an example written for this lesson.

Check what you learned

Predict · scenario 1

After you attach a route map with a single deny clause, every route disappears. Why?

Predict · scenario 2

A route map that sets local preference 200 is attached outbound to ISP A. What does R1 see?

Predict · scenario 3

permit 10.0.0.0/8 is the only line of a prefix list, and 10.99.0.0/16 is not matched. What fixes it?

Predict · scenario 4

R2 shows only 64500:300 on a route that R1 tagged 64500:100 earlier. Which keyword was missing from the second route map?

Predict · scenario 5

You edited the outbound route map toward ISP A. Which command applies it to routes R1 already advertised?

Predict · scenario 6

A prefix-list line is permit 10.0.0.0/8 ge 16 le 24. Which prefix inside 10.0.0.0/8 is still not matched?

FAQ

A neighbour is Established but a prefix is missing. What do I check first?
Run received-routes (or advertised-routes on the other router) to see whether the route was sent at all. If it was sent and is not in the table, an inbound policy removed it. If it was not sent at all, the sender's table or outbound policy is the cause.
Why does a policy change sometimes do nothing?
BGP applies policy to updates as they arrive or leave. A change affects routes already learned only after a soft clear in the matching direction, or a route refresh.
Should soft-reconfiguration inbound be turned on for every neighbour?
It keeps an extra copy of every route received, so it costs memory, and a full Internet table is large. Turn it on where received-routes is needed, or for a short troubleshooting period. Many releases can use route refresh instead, so check the release in use.
What does an implicit deny mean in a route map?
A route that matches no clause is dropped. A route map with only a deny clause therefore drops every route. Add a final permit clause with no match line to accept the rest.