Free tech learning for everyone, from basics to pro

Routing & SwitchingNetworking SecurityIntermediate

BGP fundamentals: autonomous systems, path vector routing, eBGP, iBGP and multihoming

In short: BGP is the routing protocol that connects autonomous systems, the separately run networks that make up the internet. It is a path vector protocol: each route carries the list of ASes it has crossed, which prevents loops and lets you apply policy. eBGP runs between ASes, iBGP inside one. Multihomed sites use BGP to control which links carry traffic.

What BGP is for

Interior gateway protocols (IGPs) such as OSPF and EIGRP find the fastest path inside one organisation. The internet is made of tens of thousands of separately managed networks, each called an autonomous system (AS). The Border Gateway Protocol (BGP), version 4 (RFC 4271), carries routes between them. It is built for scale and policy rather than speed: a full internet table holds around a million IPv4 prefixes, and the choice of path is often a business decision, such as preferring a cheaper provider.

BGP runs over TCP port 179, so neighbours (called peers) must be configured by hand and need IP reachability before they can talk.

Autonomous system numbers

Each AS has a number (ASN) assigned by a regional internet registry such as RIPE NCC or APNIC.

RangeUse
1 - 64495Public 2-byte ASNs
64496 - 64511 and 65536 - 65551Documentation and examples (RFC 5398)
64512 - 65534Private 2-byte ASNs
131072 upwards (to 4294967295)4-byte ASNs (RFC 6793), now the normal allocation
4200000000 - 4294967294Private 4-byte ASNs (RFC 6996)

Private ASNs work like private IP addresses: fine inside a provider or between a customer and its provider, but they must be removed before routes reach the internet. 4-byte ASNs can be written as a plain number or in "asdot" form, such as 2.10 for 131082.

Path vector and loop prevention

BGP is a path vector protocol. Each route carries an AS_PATH attribute listing every AS it has passed through. When a router receives a route whose AS_PATH already contains its own ASN, it rejects it, which prevents loops between ASes. The path also feeds policy: you can prefer, avoid or filter routes based on which networks they cross.

eBGP and iBGP

  • External BGP (eBGP): between routers in different ASes, normally on a directly connected link. Packets are sent with a TTL of 1 by default, and eBGP routes have an administrative distance of 20 on Cisco routers.
  • Internal BGP (iBGP): between routers in the same AS, often between loopback addresses reached through the IGP. iBGP routes have an administrative distance of 200.

iBGP has one special rule: a route learned from an iBGP peer is not advertised to another iBGP peer. Because the AS_PATH does not change inside an AS, this is how loops are avoided, but it means every iBGP router must peer with every other one (a full mesh), or you use route reflectors or confederations, covered in scaling iBGP.

When you need BGP

Ways to connect to the internetSingle-homed1 ISP, 1 linkDual-homed1 ISP, 2 linksSingle multihomed2 ISPs, 1 link eachDual multihomed2 ISPs, 2+ links each
Figure 1. The more links and providers you have, the more resilient you are, and the more likely you need BGP to control which path traffic uses.

A single-homed site with one link to one provider needs no BGP: a static default route is simpler. Dual-homed sites with two links to the same provider can often manage with static routes and tracking, though BGP gives better control. A multihomed site with two providers usually needs BGP and its own provider-independent address space and public ASN, so that both providers can announce the same prefix and traffic can fail over between them.

Real-world example: a regional online retailer outgrew a single internet provider after a fibre cut took its shop offline for half a day. It obtained a public ASN and a /24 of provider-independent IPv4 space, ordered links from two providers, and ran eBGP with both from two edge routers, with iBGP between the edge routers. When one provider later had an outage, its routes were withdrawn and customer traffic shifted to the other provider within a couple of minutes, without any DNS changes.

Practice

Which TCP port does BGP use?
TCP 179.
How does BGP stop routing loops between autonomous systems?
A router rejects any route whose AS_PATH already contains its own AS number.
Why does iBGP traditionally need a full mesh?
Routes learned from one iBGP peer are not advertised to other iBGP peers, so every iBGP router must peer directly with every other one unless route reflectors or confederations are used.

Key takeaways

  • BGP-4 connects autonomous systems and is built for scale and policy, not fast convergence.
  • BGP peers are configured manually and talk over TCP port 179.
  • The AS_PATH attribute prevents loops and supports policy decisions.
  • eBGP runs between ASes (AD 20); iBGP runs inside an AS (AD 200) and needs a full mesh or reflectors.
  • Multihoming to two providers is the classic reason an enterprise runs BGP.
Tracks your learning on this device only. See your progress on the learning paths.

About the author

Mohamed Fayas

Founder of FM TecHub. CCNA certified, with a BTEC HND in Network Engineering, and BEng (Hons) in Computer Networking and Cloud Security. He writes practical, plain-English guides on networking, security and cloud.

More about the author

Original content written by Mohamed Fayas for FM TecHub. © 2026 FM TecHub. You're welcome to share a link to this page; please don't copy the text elsewhere without permission.

Stay up to date by email

New notes, tools and security news from FM TecHub, explained simply. Free.

We only use your email to send these updates. See our privacy policy.