Sub topic 12
Interior and Exterior Routing, and Where BGP Fits
This chapter assumes you know how a routing table, longest-prefix match and administrative distance work, and that you have seen OSPF or RIP at a basic level. Here you will see why routing is split into interior and exterior parts, and what BGP does that OSPF does not.
Autonomous systems
An autonomous system (AS) is a set of IP networks run by one organization under a single routing policy. Examples are a company network, a university or an internet service provider (ISP). Each AS is identified by an AS number (ASN), which is assigned by a regional internet registry.
Routing inside an AS and routing between ASes solve different problems, so different protocols handle them.
- An interior gateway protocol (IGP) runs inside one AS. OSPF, IS-IS, RIP and EIGRP are IGPs. Their goal is to find the best path using a metric such as cost or hop count.
- An exterior gateway protocol (EGP) runs between ASes. Today this means BGP, the Border Gateway Protocol. Its goal is to apply policy: which neighbors to prefer, which routes to advertise, and which to refuse.
Why BGP is different
OSPF is a link-state protocol: every router learns the full topology and runs a shortest-path calculation. That does not scale to the whole internet, and it would force every network to reveal its internal layout. BGP is a path-vector protocol. Each route carries the list of ASes it has crossed, called the AS path.
The AS path has two uses. It prevents loops, because a router rejects any route whose AS path already contains its own ASN. It also acts as a rough metric, since a shorter AS path is usually preferred. Real BGP decisions rely mostly on policy attributes, such as local preference, applied before path length is compared.
| Property | IGP (for example OSPF) | BGP |
|---|---|---|
| Scope | Inside one AS | Between ASes, and across an AS |
| Main goal | Fastest or cheapest path | Policy and reachability |
| Algorithm type | Link-state or distance-vector | Path-vector |
| Convergence | Seconds or faster | Slower, by design |
| Transport | Own protocol or IP directly | TCP port 179 |
eBGP and iBGP
BGP sessions come in two kinds. External BGP (eBGP) connects routers in different ASes. Internal BGP (iBGP) connects routers in the same AS so that they share what they learned from outside. iBGP does not replace the IGP. The IGP still carries the paths between internal routers, and iBGP carries the external prefixes.
Cisco IOS gives eBGP routes an administrative distance of 20 and iBGP routes 200. This means an eBGP route beats an OSPF route (110) for the same prefix, while an iBGP route loses to it.
A minimal eBGP configuration
! Cisco IOS on R2 (AS 65001): peer with R3 in AS 65002 and advertise one prefix
router bgp 65001
neighbor 192.0.2.2 remote-as 65002
network 10.1.0.0 mask 255.255.0.0The network statement advertises the prefix only if a matching route already exists in the routing table, often a static route or an OSPF route. You can check the session and the learned routes with show ip bgp summary and show ip bgp.
Where static and dynamic routing fit
Small networks often have a static default route toward the ISP and an IGP inside. A network with more than one ISP usually runs eBGP to each provider, so it can choose paths by policy and survive the loss of one provider.
Exercise
A router learns 10.50.0.0/16 from OSPF (AD 110) and from eBGP (AD 20). Which route enters the routing table, and what would change if the BGP route came from iBGP?
Show answer
The eBGP route enters the table because its administrative distance of 20 is lower than 110. If the route came from iBGP (AD 200), the OSPF route would win.