Advanced Networking

Chapter 5
Border Gateway Protocol and Internet Routing

Bachelors Program in IT
Advanced Networking   •   Bachelor

Border Gateway Protocol and Internet Routing

Introduction and Context

The Internet is not a single network operated by one organization. It is a federation of independently administered networks that exchange reachability information and apply their own technical, commercial, and security policies. Border Gateway Protocol (BGP) is the principal inter-domain routing protocol that enables this federation.

BGP is a path-vector protocol. Unlike an interior gateway protocol (IGP), which normally selects efficient paths within one administrative domain, BGP exchanges complete or partial path information between autonomous systems (ASes). Its decisions are therefore influenced not only by topology but also by business relationships, security requirements, traffic-engineering objectives, and organizational policy.

This chapter examines autonomous systems, BGP operation, peering, route attributes, route reflectors, policy control, multihoming, traffic engineering, route security, and convergence. Configuration examples use vendor-neutral concepts; exact commands vary among Cisco IOS, Juniper Junos, FRRouting, Arista EOS, and other platforms.

Learning Objectives

By the end of this chapter, you should be able to:

  1. Explain autonomous systems and the distinction between intra-domain and inter-domain routing.
  2. Describe BGP session establishment, route exchange, and best-path selection.
  3. Configure and evaluate eBGP and iBGP peering conceptually.
  4. Explain route attributes, route reflectors, policy controls, and traffic engineering.
  5. Analyze multihoming designs and their operational trade-offs.
  6. Describe RPKI, route filtering, and other route-security practices.
  7. Evaluate convergence, scalability, and failure scenarios.

1. Autonomous Systems and Internet Routing

An autonomous system is a collection of IP prefixes and routers under one clearly defined administrative policy. An AS is identified in BGP by an Autonomous System Number (ASN), allocated by a Regional Internet Registry or, in some cases, by an Internet service provider. Modern ASNs are 32-bit values, although traditional notation used 16-bit values.

An AS may be an Internet service provider, cloud platform, university, enterprise, content provider, or large private organization. The important characteristic is not its size but its common routing policy.

Intra-domain and inter-domain routing

Interior Gateway Protocols (IGPs), such as OSPF and IS-IS, operate within an AS. They generally optimize a technical metric such as cost, delay, or bandwidth. BGP operates between ASes and may deliberately select a longer or less technically efficient path because that path satisfies policy or commercial constraints.

PropertyIGPBGP
ScopeWithin an ASBetween ASes, and logically within an AS for iBGP
Primary concernTopological efficiencyPolicy and reachability
Typical convergenceRelatively fastDeliberately controlled and often slower
Path informationCost or metricAS path and attributes
ExamplesOSPF, IS-ISeBGP, iBGP

The global Internet routing table contains hundreds of thousands of IPv4 and IPv6 prefixes. No single router needs to know every physical link. Instead, routers exchange reachability to prefixes and select next hops according to local policy.

2. BGP Architecture and Operation

BGP runs over TCP port 179. A BGP speaker establishes a TCP connection with a configured neighbor and then exchanges BGP messages. The principal message types are:

  • OPEN: Negotiates the BGP version, ASN, hold time, BGP identifier, and optional capabilities.
  • KEEPALIVE: Maintains the session when no other messages are being sent.
  • UPDATE: Advertises new routes, withdraws routes, and carries path attributes.
  • NOTIFICATION: Reports an error and normally terminates the session.

BGP is commonly described using a finite-state machine: Idle, Connect, Active, OpenSent, OpenConfirm, and Established. The Established state permits normal UPDATE exchange. “Active” does not mean that the session is functioning; it generally indicates that BGP is trying to establish TCP connectivity after an unsuccessful attempt.

A router maintains several conceptual data sets:

  1. Adj-RIB-In: Routes received from a neighbor.
  2. Loc-RIB: Routes selected as best by the local decision process.
  3. Adj-RIB-Out: Routes selected for advertisement to a particular neighbor.
  4. Forwarding table: Routes installed for packet forwarding, usually after cooperation with the IGP and next-hop resolution.

BGP is incremental. After the initial exchange, it sends changes rather than repeatedly transmitting the entire table. A route advertisement is not automatically propagated everywhere: export policy determines what each neighbor receives.

eBGP and iBGP

An eBGP session connects routers in different ASes. An iBGP session connects routers in the same AS. eBGP is used to exchange routes across administrative boundaries; iBGP distributes externally learned routes inside an AS.

A fundamental iBGP rule is that a route learned from one iBGP neighbor is not advertised to another iBGP neighbor. This split-horizon rule prevents certain loops but creates a scalability problem: a conventional design requires a full mesh. With n iBGP speakers, the number of one-to-one sessions is:

S = n(n − 1) ÷ 2

Here, S is the number of sessions and n is the number of routers. The formula assumes a complete undirected mesh in which every pair of routers has one session. For 10 routers, S = 10 × 9 ÷ 2 = 45 sessions. Route reflectors and confederations reduce this requirement.

3. BGP Path Attributes and Best-Path Selection

BGP does not select a route using one universal shortest-path metric. It applies an ordered decision process, and the precise order can vary by implementation. A common sequence is:

  1. Prefer the highest weight where the vendor supports this local, non-transitive attribute.
  2. Prefer the highest local preference.
  3. Prefer locally originated routes.
  4. Prefer the shortest AS_PATH.
  5. Prefer the lowest origin type: IGP, EGP, then incomplete.
  6. Prefer the lowest MED when the implementation and policy permit comparison.
  7. Prefer eBGP-learned over iBGP-learned routes.
  8. Prefer the lowest IGP cost to the BGP next hop.
  9. Apply implementation-specific tie-breakers, such as oldest path, router ID, or neighbor address.

Because policy and vendor defaults differ, engineers must consult platform documentation and verify decisions with operational commands.

Major attributes

AttributeFunctionTypical scope or effect
AS_PATHLists ASes traversed by a routeLoop prevention and path-length policy
NEXT_HOPIdentifies the next router toward the prefixMust be recursively reachable
LOCAL_PREFIndicates preferred exit from an ASInternal to an AS; higher is preferred
MEDSuggests preferred entry point into an ASUsually lower is preferred; comparison is policy-dependent
ORIGINDescribes how the route entered BGPIGP is preferred over EGP and incomplete
COMMUNITIESLabels routes for policyStandard, extended, and large communities exist
ATOMIC_AGGREGATE / AGGREGATORRecords effects or source of aggregationUseful for operational interpretation

AS_PATH is central to loop prevention. An AS normally rejects a route if its own ASN appears in the received path. An operator can also prepend its ASN multiple times to make a route appear longer, although this is an imperfect traffic-engineering method because many networks apply local policies that override path length.

LOCAL_PREF is the usual tool for choosing an outbound path within an AS. If an organization has two providers, setting local preference to 200 for Provider A and 100 for Provider B causes internal routers to prefer Provider A for routes that are otherwise comparable.

MED is commonly used to influence which link a neighboring AS uses to enter the advertising AS. Lower MED is generally preferred. MED is not a universal command to a remote network: the receiving AS may ignore it, compare it only among routes from the same neighboring AS, or overwrite it.

Communities attach policy labels to routes. A provider may define communities such as “do not advertise to peers,” “prepend toward region X,” or “set local preference low.” Large communities provide a standardized three-part value suitable for modern, large-scale policies.

Route aggregation

Aggregation summarizes multiple more-specific prefixes into a shorter advertisement. It reduces routing-table size and limits the propagation of internal topology. However, aggregation can create black holes if a summary is advertised while no more-specific route remains reachable. A carefully designed discard or null route, conditional advertisement, and monitoring can reduce this risk.

4. Configuring and Evaluating BGP Peering

A sound BGP configuration follows a deliberate sequence:

  1. Confirm addressing, interface state, and TCP reachability.
  2. Confirm the correct local and remote ASNs.
  3. Configure the neighbor and, where necessary, an update source.
  4. Configure authentication, commonly TCP MD5 or TCP-AO where supported.
  5. Apply inbound and outbound prefix filters before permitting routes.
  6. Set explicit policy attributes such as local preference and communities.
  7. Establish the session and inspect received, accepted, advertised, and best routes.
  8. Test forwarding and failure behavior.

For loopback-based peering, the session commonly uses ebgp-multihop for eBGP when the neighbor is not directly connected, and update-source loopback for a stable source address. eBGP normally changes the next-hop attribute to itself, whereas iBGP usually preserves the next hop. The next-hop-self function is therefore often required when an edge router advertises an external route to internal peers whose IGP cannot reach the external next hop.

A conceptual configuration is:

router bgp 64510
  neighbor 192.0.2.2 remote-as 64520
  neighbor 192.0.2.2 description Transit-Provider
  address-family ipv4
    neighbor 192.0.2.2 activate
    neighbor 192.0.2.2 route-map INBOUND in
    neighbor 192.0.2.2 route-map OUTBOUND out

The exact syntax is platform-specific. A production configuration should also include maximum-prefix limits, explicit prefix lists, logging, session monitoring, and a policy that rejects routes not intentionally permitted.

Important verification questions include:

  • Is the session Established?
  • How long has it been established, and how often has it reset?
  • Which prefixes were received and accepted?
  • Which prefixes were advertised?
  • Which path is installed as best, and why?
  • Is the next hop reachable in the IGP?
  • Are inbound and outbound filters working as intended?

5. Route Reflectors and Scaling iBGP

A route reflector (RR) relaxes the iBGP full-mesh requirement. Clients establish iBGP sessions with the RR; the RR reflects selected routes between clients and non-client peers. To prevent loops, reflected routes carry attributes such as ORIGINATOR_ID and CLUSTER_LIST.

A basic design uses two route reflectors for resilience, with clients connected to both. Large networks may use hierarchical clusters or multiple levels of reflection. However, route reflection changes path visibility. A client may not see every path that exists elsewhere, and a reflector can become a policy or failure bottleneck. Therefore, redundancy, consistent policy, and careful placement are essential.

Route reflectors do not replace an IGP. The IGP still provides reachability to loopbacks and next hops, while BGP distributes inter-domain prefixes and policy information.

6. Policy Control and Traffic Engineering

BGP policy is implemented through prefix lists, route maps, policy statements, communities, AS-path filters, and attribute modification. A secure policy normally follows a default-deny principle: explicitly permit intended prefixes and reject everything else.

Inbound and outbound control

Inbound policy affects which routes an AS accepts and how it selects an exit. Outbound policy affects which routes it advertises and how other networks may reach it. Importantly, an organization cannot directly force every remote network to adopt its preferred path. It can advertise different attributes and rely on the policies of other ASes.

Traffic engineering has two directions:

  • Outbound traffic engineering: Usually controlled with local preference, selective acceptance, and IGP costs.
  • Inbound traffic engineering: Attempted with more-specific advertisements, AS-path prepending, MED, provider communities, and selective announcements.

More-specific prefixes usually attract traffic, but they increase global table size and may be rejected by filters. A provider may also impose minimum-prefix-length rules. Prepending is simple but unreliable; it should be tested from multiple observation points.

Policy example

Suppose an enterprise has Provider A and Provider B. It wants normal outbound traffic to use A and B to provide backup. It can assign local preference 200 to routes learned from A and 100 to equivalent routes learned from B. For inbound traffic, it may advertise the aggregate through both providers but prepend its ASN on the B advertisement. This may make A appear preferable, but the result remains dependent on remote routing policy.

Communities are often superior to repeated manual changes. A provider can offer documented communities for regional preference, selective advertisement, or controlled prepending. These must be treated as contractual and operational interfaces and tested before deployment.

7. Multihoming Design

Multihoming connects an organization to two or more providers. Its goals may include availability, capacity, geographic diversity, improved control, or independence from one provider.

Common designs include:

  1. Single-homed: Simple and inexpensive, but provider failure disconnects the site.
  2. Dual-provider with one edge router: Provides provider diversity but retains an equipment failure risk.
  3. Dual-provider with dual edge routers: Improves equipment and link resilience.
  4. Partial routes with default routing: Reduces router resources but provides less precise path control.
  5. Full Internet routes: Gives detailed control but requires substantial memory, processing, filtering, and operational expertise.

An organization advertising provider-independent address space generally needs its own ASN, allocations or assignments appropriate to the registry rules, and a documented plan for announcements, authentication, filtering, and failover. Address portability and policy requirements should be considered before deployment.

Multihoming does not automatically double usable bandwidth. The selected BGP path is normally one best path per prefix; load sharing requires carefully engineered multiple paths, equal-cost mechanisms, or more-specific policies. Packet-level multipath can also create ordering and troubleshooting concerns.

8. Route Security and Governance

BGP was designed for cooperative research and commercial interconnection, not for strong origin authentication. A router may accept a false announcement, an accidental leak, or an excessively broad prefix unless filtering and validation are applied.

Core controls

  • Prefix filtering: Permit only expected prefixes from each customer or peer.
  • Maximum-prefix limits: Shut down or warn when received routes exceed a defined threshold.
  • AS-path filtering: Reject paths containing prohibited ASNs or unexpected patterns.
  • Bogon filtering: Reject unallocated, reserved, or otherwise inappropriate address space where appropriate.
  • Session protection: Use authentication, TTL security, access control, and infrastructure isolation.
  • Monitoring: Detect unexpected announcements, withdrawals, route changes, and session resets.

RPKI and Route Origin Validation

The Resource Public Key Infrastructure (RPKI) allows an address holder to create a Route Origin Authorization (ROA), stating that a particular ASN is authorized to originate a prefix up to a maximum length. A validator converts ROAs into validated prefix-origin data. A route is commonly classified as:

  • Valid: The origin ASN and prefix length are authorized.
  • Invalid: A covering ROA exists, but the origin or prefix length is unauthorized.
  • Not found: No applicable ROA exists.

Origin validation does not validate the complete AS path. BGPsec attempts stronger path validation through cryptographic signatures, but deployment complexity and partial adoption limit its use. Consequently, RPKI, filtering, monitoring, and operational coordination remain complementary controls.

Route leaks and hijacks also raise governance issues. Operators should publish accurate Internet Routing Registries data, maintain emergency contacts, coordinate maintenance, and follow regional Internet registry policies. Security controls must balance protection with availability: an incorrect ROA or overly strict filter can withdraw legitimate reachability.

9. Convergence, Stability, and Failure Analysis

Convergence is the process by which routers detect a change, withdraw or replace routes, select new best paths, and update forwarding tables. BGP convergence can be slower than IGP convergence because changes may cross many ASes and be processed through policy decisions.

Factors affecting convergence include:

  • Failure-detection time, including interface detection, BFD, and hold timers.
  • UPDATE propagation and processing time.
  • Route-selection and forwarding-programming time.
  • Route dampening and suppression policies.
  • The number of affected prefixes and paths.
  • MED oscillation, route reflection, and policy interactions.

Fast timers can detect failures sooner but increase sensitivity to transient loss and CPU load. BFD can provide rapid detection, but it should be deployed with appropriate thresholds and carefully tested. Graceful Restart may preserve forwarding temporarily during a control-plane restart, but stale routes can be harmful if the forwarding plane is not actually capable of continuing service.

A useful operational model is to distinguish three events: detection, decision, and propagation. Improving only detection does not guarantee rapid end-to-end recovery if route processing, policy, or remote propagation remains slow.

Troubleshooting should proceed from physical and IP connectivity to TCP, BGP state, policy, next-hop reachability, route installation, and data-plane testing. Packet captures, route tables, BGP logs, looking glasses, and route collectors provide complementary evidence.

10. Applied Case: Illustrative University Multihoming Design

Background

A fictional university operates a research campus, online learning services, and a public data repository. It has two Internet providers, Provider North and Provider South, and wants continued connectivity if either provider fails.

Problem

The university initially receives only default routes from both providers. It sends traffic through North, but inbound traffic frequently enters through South, and a provider outage causes a prolonged disruption. The network team also discovers that its BGP policy accepts more prefixes than intended.

Analysis

The university identifies four requirements: resilient outbound access, predictable inbound access to public services, controlled route acceptance, and observable failover. It decides that full Internet tables are unnecessary for its current edge routers. Instead, it will receive default routes plus selected regional routes and use explicit policy.

Approach and solution

The team establishes eBGP sessions using loopback addresses, authenticated where supported. It applies strict prefix filters and maximum-prefix limits. Routes from North receive local preference 200; routes from South receive local preference 150. Both providers receive the university’s aggregate. The South advertisement is prepended twice, while a provider community requests lower preference for selected regions. Public services use a stable aggregate, and a monitored more-specific announcement is reserved for controlled traffic engineering rather than normal operation.

Two edge routers peer internally with redundant route reflectors. The IGP carries loopback and infrastructure reachability. RPKI validation is enabled for received routes, with invalid routes rejected after a staged monitoring period. BFD is enabled only on links where failure-detection behavior has been tested.

Outcome

Under normal conditions, outbound traffic prefers North, while inbound traffic is more frequently attracted to North but remains reachable through South. When North is disconnected, the BGP session fails, the North routes are withdrawn, and South becomes the preferred exit. Monitoring confirms that the failover works without accepting unauthorized routes.

Learning points

The case illustrates that multihoming is a policy-and-operations problem, not merely a matter of adding a second cable. Route filters, attribute design, address planning, failure testing, and communication with providers are equally important. It also demonstrates that inbound traffic engineering is probabilistic and externally influenced rather than fully controllable.

11. Contemporary Developments and Professional Practice

Modern networks increasingly combine BGP with software-defined networking, cloud interconnection, EVPN, segment routing, and automated configuration pipelines. BGP communities and large communities act as policy APIs between providers and customers. Automation can validate intended prefixes, generate policies, compare pre- and post-change route states, and detect anomalies.

Artificial intelligence and machine learning may assist anomaly detection by identifying unusual route volumes, AS-path patterns, or timing behavior. Such systems should support, not replace, deterministic controls. A model that flags a legitimate event incorrectly can cause an outage if it automatically withdraws routes. Human approval, explainability, audit logs, and safe rollback are therefore important.

Best practice includes version-controlled configuration, peer review, lab testing, staged deployment, explicit allow lists, documented provider contracts, continuous monitoring, and periodic failure exercises. Operators should measure both control-plane behavior and actual application reachability.

Challenges and Limitations

BGP’s flexibility is also its main difficulty. Policies can conflict, route selection can be non-obvious, and a locally reasonable change can have global effects. Convergence is not instantaneous, complete path validation is not widely deployed, and inbound traffic cannot be perfectly controlled. Route reflectors improve scalability but may reduce visibility. Aggregation reduces table size but can cause black holes. RPKI improves origin security but does not prove the entire path.

These limitations imply that BGP engineering requires both technical competence and governance. Design decisions should be evaluated for correctness, resilience, security, operational workload, and impact on other networks.

Chapter Summary

BGP is the Internet’s principal inter-domain routing protocol. It connects autonomous systems while allowing each organization to apply policy. eBGP exchanges routes between ASes, whereas iBGP distributes external routes internally. BGP uses attributes such as AS_PATH, LOCAL_PREF, MED, NEXT_HOP, ORIGIN, and communities to select and control routes.

Route reflectors address iBGP scalability, while multihoming improves resilience but introduces policy and operational complexity. Outbound traffic is commonly influenced by local preference; inbound traffic may be influenced by prepending, MED, communities, and selective announcements, although remote policy limits control. Secure operation requires prefix filtering, maximum-prefix limits, session protection, monitoring, and RPKI-based origin validation. Convergence depends on detection, route processing, policy, propagation, and forwarding installation. Effective BGP practice combines protocol knowledge with testing, documentation, automation, and governance.

Key Terms

Autonomous System: A network under one administrative routing policy.

ASN: The number identifying an autonomous system in BGP.

BGP: A path-vector protocol used for inter-domain routing.

eBGP: BGP between different autonomous systems.

iBGP: BGP between routers in the same autonomous system.

AS_PATH: The sequence of ASNs traversed by a route.

LOCAL_PREF: An internal attribute used to choose an outbound path; higher is normally preferred.

MED: An attribute commonly used to suggest an entry point into an AS; lower is normally preferred.

NEXT_HOP: The address of the next router toward a destination.

Route reflector: An iBGP speaker that reflects routes between clients.

Community: A policy label attached to a BGP route.

Route aggregation: Advertisement of a summary prefix covering more-specific routes.

Multihoming: Connecting an organization to multiple providers or upstream paths.

RPKI: A public-key infrastructure supporting authorization of route origins.

ROA: A signed authorization allowing an ASN to originate a prefix.

Route leak: An unintended propagation of routes beyond their intended scope.

Convergence: The process by which routing systems reach a stable state after change.

Prefix filter: A rule controlling which prefixes may be accepted or advertised.

Graceful Restart: A mechanism intended to preserve forwarding during some control-plane restarts.

Review Questions

Short Answer Questions

  1. What is an autonomous system, and why is an ASN required?
  2. Distinguish eBGP from iBGP.
  3. What is the purpose of LOCAL_PREF?
  4. Why are route reflectors used?
  5. What does an RPKI-invalid route indicate?

Long Answer Questions

  1. Explain the BGP route-selection process and discuss why its exact order must be verified on a specific platform.
  2. Compare IGP routing with inter-domain BGP routing in terms of objectives, metrics, and convergence.
  3. Describe how a dual-provider enterprise could engineer outbound and inbound traffic.
  4. Explain the security limitations of BGP and evaluate the complementary roles of filtering and RPKI.
  5. Discuss the advantages and disadvantages of route reflection in a large service-provider network.

Analytical / Application Questions

  1. An enterprise receives equivalent routes from two providers and wants Provider A preferred for outbound traffic. Which attribute should it normally change, and why?
  2. A route reflector cluster is redundant, but clients report inconsistent paths after a policy change. Identify possible causes and propose an investigation sequence.
  3. A university’s public prefix is reachable through one provider but not the other after a new ROA is published. Analyze how an incorrect origin ASN or maximum length could produce this result and recommend corrective actions.

Multiple Choice Questions with Answers

Question 1

Which protocol is primarily used for routing between autonomous systems?

A. OSPF

B. IS-IS

C. BGP

D. RIP

Correct Answer: C. BGP

Question 2

What is the normal purpose of LOCAL_PREF in an AS?

A. To select an outbound path within the AS

B. To authenticate a TCP session

C. To identify the next-hop MAC address

D. To specify the BGP hold timer

Correct Answer: A. To select an outbound path within the AS

Question 3

Which BGP attribute is most directly associated with loop prevention?

A. MED

B. AS_PATH

C. NEXT_HOP

D. ORIGINATOR_ID

Correct Answer: B. AS_PATH

Question 4

A complete iBGP mesh contains how many sessions for 10 routers?

A. 10

B. 20

C. 45

D. 90

Correct Answer: C. 45

Question 5

Which statement about MED is generally correct?

A. Higher MED is always preferred

B. Lower MED is commonly preferred, subject to policy

C. MED is used only for authentication

D. MED prevents all route leaks

Correct Answer: B. Lower MED is commonly preferred, subject to policy

Question 6

What problem does a route reflector primarily solve?

A. IPv4 address exhaustion

B. The iBGP full-mesh scalability requirement

C. TCP port exhaustion on hosts

D. Physical link failures

Correct Answer: B. The iBGP full-mesh scalability requirement

Question 7

What does an RPKI ROA authorize?

A. A router to use TCP port 179

B. An ASN to originate a prefix within a specified maximum length

C. A provider to modify another AS’s LOCAL_PREF

D. A route reflector to change the IGP metric

Correct Answer: B. An ASN to originate a prefix within a specified maximum length

Question 8

Which technique most directly controls outbound path selection inside an enterprise?

A. Local preference

B. AS-path prepending sent to an upstream

C. Changing the remote provider’s MED

D. Increasing DNS TTL

Correct Answer: A. Local preference

Question 9

What is a major risk of advertising an unauthorized or overly broad prefix?

A. It can cause a route leak or hijack-like event

B. It automatically improves convergence

C. It disables all IGP adjacencies

D. It converts eBGP into iBGP

Correct Answer: A. It can cause a route leak or hijack-like event

Question 10

Which sequence best represents the main stages of failure recovery?

A. Propagation, detection, decision

B. Decision, forwarding, detection

C. Detection, decision, propagation

D. Authentication, aggregation, encryption

Correct Answer: C. Detection, decision, propagation

Advanced Networking
Chapter 5 of 15