Layer 3 Technologies · Topic 8 of 8

BGP Path Selection, Route Reflectors and Policy

Learn the BGP best path order, how a single route reflector works, and how inbound and outbound filtering and attribute changes shape paths on IOS XE.

  • 6 min
  • Includes a diagram
In a nutshell
  • Weight is Cisco specific and local. Higher is better.
  • Local preference defaults to 100. Higher is better.
  • Shorter AS path wins, and lower MED wins.

What it is

BGP chooses one best path for each prefix using attributes, and policy tools let you filter routes and change those attributes.

BGP does not use a simple metric. It compares a list of attributes in a fixed order, and the first difference decides. Policy is how an operator influences that order.

A route reflector (RR) is a router that is allowed to pass iBGP routes between iBGP peers, so a full mesh is not needed.

Prefixseveral pathsvalid next hop onlyBest pathattribute orderadvertised toNeighboursafter outbound policy

How it works

Think of best path selection as a sequence of tie breakers, and policy as a way to move the tie breaker you want.

The best path order

A path is considered only if its next hop is reachable. The router then compares paths in this order, on Cisco devices.

  1. Highest weight, which is local to the router.
  2. Highest local preference, which defaults to 100 and is shared in the AS.
  3. Paths the router originated itself.
  4. Shortest AS path.
  5. Lowest origin code: IGP, then EGP, then incomplete.
  6. Lowest MED, compared by default only between paths from the same neighbouring AS.
  7. eBGP over iBGP.
  8. Lowest IGP metric to the next hop.
  9. Further tie breakers, ending with the lowest router ID and then the lowest neighbour address.
R1# show ip bgp
R1# show ip bgp 10.1.0.0/16

In the table, * means valid and > means best. A route with no * is usually invalid because the next hop is unreachable. The second command lists every path with its attributes and says why one was chosen.

Influencing path choice

R1 in AS 65002 connects to ISP A and ISP B. An inbound route map sets local preference 200 on routes from ISP A so traffic leaves there, and an outbound route map prepends AS 65002 twice toward ISP B to make that path less attractive.

GoalTool
Prefer an exit for one routerWeight
Prefer an exit for the whole ASLocal preference, set inbound
Make a path less attractive to other ASesAS path prepend, set outbound
Hint the entry point to a neighbour ASMED, set outbound
R1(config)# route-map FROM-ISP-A permit 10
R1(config-route-map)# set local-preference 200
R1(config)# route-map TO-ISP-B permit 10
R1(config-route-map)# set as-path prepend 65002 65002
R1(config-route-map)# exit
R1(config)# router bgp 65002
R1(config-router)# neighbor 192.0.2.2 route-map FROM-ISP-A in
R1(config-router)# neighbor 198.51.100.2 route-map TO-ISP-B out
R1(config-router)# neighbor 192.0.2.2 weight 300

Local preference is only seen inside your AS, so it controls how traffic leaves. Prepending is how you discourage traffic from entering by one path.

Filtering

Filters apply per neighbour and direction. Three tools are common.

  • A prefix list matches prefixes and lengths.
  • A filter list matches the AS path with a regular expression.
  • A route map matches many things and can also set attributes.
R1(config)# ip prefix-list NO-DEFAULT deny 0.0.0.0/0
R1(config)# ip prefix-list NO-DEFAULT permit 0.0.0.0/0 le 32
R1(config)# ip as-path access-list 10 permit ^65001$
R1(config-router)# neighbor 192.0.2.2 prefix-list NO-DEFAULT in
R1(config-router)# neighbor 192.0.2.2 filter-list 10 out

An AS path list uses ^ for the start and $ for the end. The pattern ^65001$ matches only routes whose whole path is that one AS.

To see what is sent or received, use the neighbour commands. Received routes before policy are only kept if soft-reconfiguration inbound is configured.

R1# show ip bgp neighbors 192.0.2.2 advertised-routes
R1# show ip bgp neighbors 192.0.2.2 received-routes
R1# show ip bgp regexp ^65001_

Communities tag routes so one policy can match many prefixes. They are not sent to a neighbour unless send-community is configured.

Route reflectors

Client A sends a route to a route reflector, which reflects it to another client and to a non-client iBGP peer inside AS 65002 and adds an originator ID and cluster list. Without an RR, an iBGP router will not pass on a route learned from an iBGP peer. The RR relaxes that rule for its clients.

RR(config-router)# neighbor 10.2.2.1 remote-as 65002
RR(config-router)# neighbor 10.2.2.1 route-reflector-client

The reflection rules are short:

  • A route from a client goes to all clients and all non clients.
  • A route from a non client goes to clients only.
  • A route from an eBGP peer goes to all.

The RR adds two attributes to prevent loops: an originator ID and a cluster list. A router that sees its own ID in them drops the route.

The RR does not change the next hop, so clients must still reach it. This page covers one RR only.

Client AiBGProuteRoute reflectorreflectsrouteClient BiBGP
Exam tip

When the wrong path wins, run show ip bgp PREFIX and compare weight, local preference and AS path in order.

What to remember for the exam

Eight facts cover most questions on this topic.

  • Weight is Cisco specific and local. Higher is better.
  • Local preference defaults to 100. Higher is better.
  • Shorter AS path wins, and lower MED wins.
  • A path with an unreachable next hop is not eligible.
  • Set local preference inbound to steer outbound traffic.
  • Prepending lengthens the AS path to steer inbound traffic away.
  • send-community is needed to send communities.
  • An RR passes iBGP routes between its clients and non clients.
Watch out

Changing policy does not take effect on existing routes until you refresh. Use clear ip bgp ADDRESS soft in or soft out.

Common mistakes

These five mistakes appear often.

Setting local preference outbound. It does nothing for outside neighbours, so set it inbound.

Expecting MED across different ASes. By default it is compared only for the same neighbouring AS.

Forgetting the final permit in a prefix list. The implicit deny drops every other prefix.

Not sending communities. A neighbour never sees tags that were set.

Forgetting next hop reachability at an RR client. The route is received but not used.

Check yourself

Work through these three questions.

  • Which attribute is checked first in best path selection?

    Weight, where higher is better and the value is local to the router.

  • How do you steer traffic leaving your AS toward one ISP?

    Set a higher local preference inbound on the routes from that ISP, for example with set local-preference 200.

  • Where does a route reflector send a route learned from one of its clients?

    A route learned from a client is passed to all other clients and non clients.

Topic 8 of 8 in Layer 3 Technologies

Test yourself on Layer 3 Technologies

The full Cisco CCNP 300-410 ENARSI question bank has 857 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 Cisco. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.