Articles

BGP: sessions, attributes and the policy that picks a path

Policy filters first; attributes only rank the routes that policy already allowed.

Reading: 5 minNetworking

Article cover: BGP: sessions, attributes and the policy that picks a path

Inside one network a routing protocol can compare costs: one administration owns the metrics. BGP begins where that assumption ends: “The primary function of a BGP speaking system is to exchange network reachability information with other BGP systems.” (rfc4271.txt lines 32–33). Every route is judged twice — by the sender and by the receiver — so “best” describes one router’s reasoning, not a property of the path.

The session comes before the routes

            eBGP, TCP port 179                      eBGP
   AS 64500 <-------------------> AS 64501 <-------------------> AS 64502

   inside one AS: iBGP, and a route taken from an internal peer
   is not passed on to another internal peer

   what a peer sends
        |
        v
   Adj-RIB-In --> decision process --> Loc-RIB --> outbound policy --> Adj-RIBs-Out --> peer
                        ^
                        |  policy decides what enters at all;
                        |  the attribute order ranks only the survivors

“BGP uses TCP [RFC793] as its transport protocol” and “listens on TCP port 179” (rfc4271.txt lines 426, 428); the first message is an OPEN, answered by a KEEPALIVE (lines 681–682), the session’s liveness signal (lines 1155–1156). A peer is configured, not discovered: the state machine starts “in the Idle state” (line 2943) and reaches Established only through Connect, Active, OpenSent and OpenConfirm (lines 3010, 3255, 3495, 3708).

The relationship sets the rules. Peers are “external” across autonomous systems and “internal” inside one (lines 249, 259). A route taken from an internal peer is not passed on to other internal peers (lines 4680–4682), so internal reachability needs “n*(n-1)/2 unique Internal BGP (IBGP) sessions” (rfc4456.txt lines 88–89) — a mesh that “clearly does not scale” (line 90) and that route reflection or a confederation replaces (lines 41–43).

What a route carries

A route pairs “a set of destinations with the attributes of a path to those destinations” (rfc4271.txt lines 277–278). AS_PATH lists “the autonomous systems through which routing information carried in this UPDATE message has passed” (lines 1380–1381), and a path that already contains the local AS “should be excluded from the Phase 2 decision function” (lines 4329–4330). NEXT_HOP “defines the IP address of the router that SHOULD be used as the next hop” (lines 1446–1448). LOCAL_PREF never leaves the AS — required towards internal peers, forbidden towards external ones (lines 1590–1600) — and the higher value is preferred (line 1595). MULTI_EXIT_DISC discriminates “among multiple exit or entry points to the same neighboring AS” (lines 1553–1555) and compares only within one neighbour AS (lines 4488–4489). Communities tag a route so that “the routing decision can also be based on the identity of a group” (rfc1997.txt lines 46–47) — the marking set at one edge and matched at another.

The order of preference is vendor documentation

The numbered list readers meet belongs to the implementation. RFC 4271 does define a decision process in “three distinct phases” (line 4245) and does fix an order — “The criteria MUST be applied in the order specified” (lines 4459–4460): AS_PATH length first, then ORIGIN, MED, eBGP over iBGP, interior cost, BGP Identifier and peer address (lines 4468–4569). LOCAL_PREF enters earlier, as a route’s degree of preference (lines 4285–4286). The document still calls the procedure a model: “The BGP Decision Process described here is conceptual, and does not have to be implemented precisely as described” (lines 4216–4217).

Cisco’s page for its own algorithm starts with a step no RFC names — “Prefer the path with the highest WEIGHT”, described as “a Cisco-specific parameter. It is local to the router on which it is configured” (cisco-bgp-bestpath.md lines 116, 118) — then LOCAL_PREF, a locally originated path, the criteria above, and finally the oldest path and the lowest router ID (lines 120, 124, 206, 221). WEIGHT, locally-originated and oldest-route are not in RFC 4271; nor does a platform default such as a local preference of 100 (cisco-bgp-case-studies.md line 1127). Cite the RFC for what must hold between independent implementations, the vendor for what one box will do.

Policy decides before the comparison

The decision process applies “the policies in the local Policy Information Base (PIB) to the routes stored in its Adj-RIBs-In” (lines 4209–4211), so inbound policy decides which candidates exist before any attribute is compared, and outbound policy decides what leaves: “All routes in the Loc-RIB are processed into Adj-RIBs-Out according to configured policy”, which “MAY exclude a route in the Loc-RIB from being installed in a particular Adj-RIB-Out” (lines 4588–4590). A route refused on the way in is never ranked, and a rule that denies one direction leaves the other open. Communities are the marking that policy matches across domains, and BCP 194 expects the tag and the filter to meet on the same router (rfc7454.txt lines 1131–1132).

What breaks, and what the filters catch

NIST SP 800-189 defines a prefix hijack as a case where “an autonomous system (AS) accidentally or maliciously originates a prefix that it is not authorized (by the prefix owner) to originate” (lines 446–447); because forwarding prefers “the most specific (i.e., longest) matching entry in a router’s FIB” (lines 459–460), a more-specific false announcement takes traffic that a shorter one would not. A route leak is “the propagation of routing announcements beyond their intended scope” (lines 564–565), and it “most often arise from accidental misconfigurations” (lines 575–576). The answer is filtering that knows what a peer may originate: origin validation against RPKI data, prefix filters, the maximum-prefix limit BCP 194 recommends (rfc7454.txt lines 969–970) and session protection such as TTL security (lines 331–332).

Level and prerequisites

L4 — advanced architectures and network defence. It assumes the L1 packet-path vocabulary and the L3 sheet on dynamic routing; IGP families, area design and address planning belong there or to siblings. No configuration appears here.

Where to go next

References

  • IETF — A Border Gateway Protocol 4 (BGP-4) (RFC 4271, Standards Track, January 2006; obsoletes RFC 1771) — purpose and reachability (lines 32–33); the route and its attributes (lines 277–278, 1380–1381, 1446–1448, 1553–1555, 1590–1600); transport, OPEN and KEEPALIVE (lines 426, 428, 681–682, 1155–1156); peer FSM states (lines 2943, 3010, 3255, 3495, 3708, 3932); eBGP and iBGP definitions (lines 249, 259); decision process, phases and tie-breaks (lines 4209–4211, 4216–4217, 4245, 4285–4286, 4329–4330, 4459–4460, 4468–4569); Adj-RIBs and outbound policy (lines 4588–4590); iBGP re-advertisement rule (lines 4680–4682).
  • IETF — BGP Communities Attribute (RFC 1997, Standards Track, August 1996) — the community as a group of destinations (lines 46–47); the attribute, optional and transitive (lines 102–103); NO_ADVERTISE (lines 145–148).
  • IETF — BGP Large Communities Attribute (RFC 8092, Standards Track, February 2017) — the four-octet ASN limitation of the 32-bit community (lines 128–129); the 12-octet encoding (line 175).
  • IETF — BGP Route Reflection: An Alternative to Full Mesh Internal BGP (IBGP) (RFC 4456, Standards Track, April 2006; obsoletes RFC 2796 and RFC 1966) — route reflection as the alternative to the mesh (lines 41–43); the full-mesh session count and its scaling (lines 88–90); the MED and IGP caveat on route selection (lines 399–400).
  • IETF — BGP Operations and Security (RFC 7454, BCP 194, February 2015) — protection of the speaker and of the session (lines 239–285); TTL security (lines 331–332); maximum prefixes on a peering (lines 969–970); community scrubbing (lines 1131–1132).
  • NIST — Resilient Interdomain Traffic Exchange: BGP Security and DDoS Mitigation (SP 800-189, December 2019) — BGP as the protocol that distributes paths between autonomous networks (lines 109–110); prefix hijack (lines 446–447); longest-match preference (lines 459–460); route leak and its usual cause (lines 564–565, 575–576).
  • Cisco — How the Best Path Algorithm Works (BGP Best Path Selection Algorithm) — the vendor order (lines 114–231): WEIGHT (116, 118), LOCAL_PREF (120), locally originated (124), oldest path (206), router ID (221).
  • Cisco — Examine Border Gateway Protocol Case Studies — iBGP re-advertisement and the mesh (line 768); local preference as exit preference and its default (line 1127).
  • NIST — Border Gateway Protocol Security (SP 800-54, July 2007) — withdrawn on 17 December 2019 and superseded in its entirety by SP 800-189 (nist-sp800-54.txt lines 5, 13, 14). Consulted only to confirm the withdrawal; it supports no current claim in this sheet.
Nodrius Field Kit — cover

Get the Nodrius Field Kit

Enter your email and we'll send you the complete Field Kit: eight technical resources in one download.

Your email address is sent to Nodrius and used to deliver the Field Kit to you by email. Marketing messages are separate and optional: the checkbox does not affect your download, and you are only added to our updates list if you tick it. Privacy Policy.

Privacy & cookies

This site does not use cookies, analytics or tracking, and it does not profile you. There is nothing technical to switch off, so Accept and Reject change nothing about how the site works: either choice lets you browse everything normally.

The only difference is what your browser remembers: two entries in local storage — your choice here, so this notice is not shown again, and a marker that the Field Kit offer has already been made — so the offer is presented once and not on every page. They contain no identifier, they are not shared with anyone, and the site sets no cookie for either.

What we do with your data
How your email address is used when you ask for a Resource, how long it is kept and which rights you have — in the Privacy Policy.
What the site stores in your browser
Two entries in local storage — your choice on this notice and whether the Field Kit offer has been shown — and no cookies, no session storage, no third-party content: in the Cookie Policy.