Course contents

Chapter 8: RoutingLesson 14 of 16

Beyond CCNA (optional). This topic is not on the CCNA 200-301 exam. It is useful at work and in later study; skip it if you are preparing for the exam. (BGP is not an exam objective; only its administrative distance is useful to know.)

Where BGP fits

The protocol that connects separate networks across the internet, explained without the deep detail.

Intermediate · 6 min read

Technical definition

BGP (Border Gateway Protocol) is the path-vector routing protocol used to exchange routes between autonomous systems, the separately run networks that make up the internet. Each route carries an AS path listing the autonomous systems it has crossed, which BGP uses for loop prevention and path selection.

A second ISP for the company website

The company's website must stay online even if its ISP has an outage. So it signs up with a second ISP. Now the rest of the internet needs to know that the company's public addresses, 198.51.100.0/24, can be reached through either ISP. A static default route can't announce anything to the internet. This is BGP's job.

What BGP is

BGP (Border Gateway Protocol) is the routing protocol that connects separate networks into the internet. Each of those networks is an autonomous system (AS): a group of routers run by one organisation with one routing policy. Each AS has a number, an ASN. Here the company is AS 64500 and its ISPs are AS 64501 and AS 64502 (numbers reserved for documentation).

BGP is a path-vector protocol. Every route carries the AS path: the list of ASes it has passed through. A router that sees its own ASN in the path rejects the route, which stops loops between networks.

Diagram
The company announces its addresses to two ISPs
The company announces its addresses to two ISPs
eBGPeBGPR1AS 64500 · 198.51.100.0/24ISP-AAS 64501ISP-BAS 64502Rest of the internet

Device key: R1 (router) · ISP-A, ISP-B, Rest of the internet (network / service)

Lines show the example’s network connections. Thick links: uplinks/WAN, as labelled. The coloured path and envelope follow the current step; its text identifies the sender, receiver and traffic type. Blocked: forwarding prevented by a port or policy. Down: failed link. Read the step for the cause.

Reading the addresses

IP labels identify interfaces or destinations. Subnet labels identify networks; /n is the prefix length. A router ID (RID) identifies a routing process and need not be a reachable interface.

An IP address alone is not a URL. A web URL includes a scheme such as https://; an address on a router or printer does not imply a website.

  • R1: AS 64500 · 198.51.100.0/24
  • ISP-A: AS 64501
  • ISP-B: AS 64502
  1. 1. R1 announces the company's block to both ISPs. AS path so far: 64500.
  2. 2. The ISPs pass it on, each adding its own ASN to the path. The internet now knows two ways in.
  3. 3. ISP-A fails: its announcement is withdrawn, and traffic arrives through ISP-B instead.

eBGP and iBGP

Diagram
eBGP and iBGP
eBGP and iBGP
eBGP (external)iBGP (internal)
Neighbours are inDifferent ASesThe same AS
Used forExchanging routes with ISPs and partnersCarrying those routes across your own AS
Administrative distance20200
Read each row across: the left box names the item, the others describe it.

BGP neighbours, called peers, are configured by hand and talk over a TCP connection on port 179. Nothing is discovered automatically like OSPF's hellos.

Why BGP picks paths by policy, not speed

OSPF runs inside one network you control, so it simply finds the cheapest path. BGP runs between organisations that don't trust each other and have business rules: "use the cheaper ISP for outbound traffic", "never carry traffic between my two providers". So BGP chooses paths by policy, using attributes such as local preference and AS path length, rather than by speed. It is also built to carry about a million internet routes calmly, which no IGP is designed for.

Diagram
Why BGP picks paths by policy, not speed
Why BGP picks paths by policy, not speed
OSPFBGP
TypeIGP, link stateEGP, path vector
RunsInside one organisationBetween organisations (and inside large ones)
Picks paths byLowest costPolicy and attributes
NeighboursFound automaticallyConfigured by hand, over TCP 179
Read each row across: the left box names the item, the others describe it.

A minimal two-ISP configuration

Based on Cisco IOS / IOS XE documentation, not run on a lab device. Real ISP connections also need filters so you only announce your own prefix; that is beyond the CCNA.

ip route 198.51.100.0 255.255.255.0 Null0 router bgp 64500 bgp router-id 1.1.1.1 neighbor 203.0.113.1 remote-as 64501 neighbor 192.0.2.1 remote-as 64502 network 198.51.100.0 mask 255.255.255.0

On R1. BGP only announces a network that exists exactly in the routing table, so a static route to Null0 (a discard interface) holds the /24 in place.

Is the session up? Reading show ip bgp summary

This output is based on Cisco documentation, not run on a lab device.

Example output · based on Cisco documentation; exact format varies by platform and software version
R1#show ip bgp summary
BGP router identifier 1.1.1.1, local AS number 64500
BGP table version is 4, main routing table version 4
2 network entries using 496 bytes of memory
3 path entries using 408 bytes of memory

Neighbor        V           AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
192.0.2.1       4        64502      38      36        4    0    0 00:31:02        1
203.0.113.1     4        64501      45      42        4    0    0 00:35:10        1
A number in the last column means the session is up and that many prefixes were received (here, a default route from each ISP). A word such as Idle or Active there means the session is not up.

In practice, a peer stuck in Idle or Active is usually a session that can't be established at all: a mistyped neighbour address, the wrong remote AS number, or something on the path blocking TCP port 179. Check those before looking at any routing policy.

Test yourself on where BGP fits

Predict · scenario 1

Two routers in the same AS run BGP with each other. What is this called?

Predict · scenario 2

A BGP route arrives with AS path 64502 64500 at a router in AS 64500. What does the router do?