ENGINEERING GUIDE · ROUTING

BGP Engineering Guide

Understand BGP sessions, path attributes, policy and best-path selection without reducing BGP to a simple shortest-path protocol.

RoutingPath vectoreBGP · iBGP
The important bit: BGP is policy-driven. A path with fewer hops is not automatically preferred; attributes such as LOCAL_PREF, AS_PATH and MED influence selection.

What BGP does

Border Gateway Protocol (BGP-4) is a path-vector routing protocol. It exchanges reachability information between autonomous systems and is also widely used inside large networks where policy control and route scale matter.

eBGP and iBGP

eBGP is used between different autonomous systems. iBGP distributes BGP-learned routes inside the same AS. iBGP has additional rules around route propagation, next-hop handling and full-mesh or route-reflector designs.

Path attributes

AttributeTypical purposeSelection direction
LOCAL_PREFChoose the preferred exit from an ASHigher
AS_PATHRecords AS traversal and helps prevent loopsShorter is commonly preferred
ORIGINDescribes how the route entered BGPIGP before EGP before incomplete
MEDSignal a preferred entry point to a neighbouring ASLower, subject to comparison rules
NEXT_HOPIdentifies the next-hop addressMust be resolvable
COMMUNITYAttach policy metadata to routesPolicy dependent

Best-path selection

Exact order varies by implementation and configuration. A common sequence considers highest LOCAL_PREF, shortest AS_PATH, lowest ORIGIN code, lowest MED where applicable, eBGP over iBGP, lowest IGP cost to the next hop and then implementation-specific tie-breakers.

Use the BGP Route Analyzer to compare candidate paths and see which attribute becomes decisive in the simplified model.

Policy and filtering

Production BGP requires explicit policy. Prefix filters, maximum-prefix limits, AS-path filters, communities, route maps/policies and controlled redistribution reduce the risk of accepting or advertising unintended routes. RPKI Route Origin Validation can provide an additional signal about whether an announcement is consistent with a published Route Origin Authorisation.

Communities

BGP communities carry policy metadata. Standard, extended and large communities are used by network operators to communicate intent between routing policy stages. Their meaning is local to the operator or agreed between peers, so always consult the relevant provider or organisation's documentation.

Troubleshooting

  1. Confirm the BGP session state and transport reachability.
  2. Check that the expected prefix is received or advertised.
  3. Inspect inbound and outbound policy and prefix filters.
  4. Verify LOCAL_PREF, AS_PATH, MED, communities and next-hop reachability.
  5. Check whether the route is present in the BGP table but rejected from the main routing table.
  6. Check the forwarding table and return path separately.
Common trap: seeing a route in the BGP table does not prove that it is the active forwarding route.

Standards and references

  • RFC 4271 — BGP-4.
  • RFC 1997 — BGP Communities Attribute.
  • RFC 8092 — BGP Large Communities.
  • RFC 6811 — BGP Prefix Origin Validation.