Autonomous System
A network and its routers, managed under one routing policy.
Routing / Field note
Learn what BGP does, how autonomous systems and peers exchange routes, and then explore interactive route selection, configuration, and practice.
BGP stands for Border Gateway Protocol. It helps separate networks share information about which IP address ranges they can reach. These networks are called autonomous systems, or ASes.
Each AS has an autonomous system number (ASN). An ISP, a cloud provider, or a large business network can operate an AS. Its routers use routing policy to decide which routes to accept, prefer, and share.
BGP is often called a path-vector protocol. A route carries information about the ASes it has crossed, along with other path attributes. BGP uses those values and local policy to choose a route. It does not simply measure which cable is shortest or which path has the lowest delay.
A BGP route contains a destination prefix, such as the simulator's 192.0.2.0/24, and information that helps another router decide what to do with it. Important parts include:
BGP neighbors exchange routes after they establish a session over TCP port 179. The routers share a full set of routes when the session starts, then send updates when route information changes.
Both are BGP sessions. The difference is whether the neighbors belong to the same AS.
| Topic | eBGP | iBGP |
|---|---|---|
| Neighbors | Routers in different ASes | Routers in the same AS |
| Common use | Exchange routes between organizations or providers | Share external and internal BGP routes inside one network |
| AS_PATH | The local AS is added when a route is sent to another AS | The local AS is not added for a normal iBGP update |
| NEXT_HOP | Commonly set to the advertising router | Commonly kept as received; next-hop-self can change it |
| Re-advertising a learned route | A router may advertise an eligible route to another eBGP peer, subject to policy | A route learned from one iBGP peer is not normally sent to another iBGP peer |
The iBGP rule prevents routing loops. A small iBGP network can use a full mesh, where each router peers with every other router. Larger networks often use route reflectors to reduce the number of sessions.
In the learning topology, ISP-A (AS 64512) originates 192.0.2.0/24. It shares the route with ISP-B (AS 64520) and ISP-C (AS 64540). Corp-X (AS 64531) receives one candidate path through each provider. Its edge router checks policy and next-hop reachability before comparing both paths to the same prefix.
If the route wins, BGP can advertise it to eligible peers. The operating system also checks whether that route should be installed for packet forwarding. Filters, policy, or another routing source may affect those later decisions.
route update arrives
↓
check policy and route eligibility
↓
compare paths to the same prefix
↓
advertise the chosen route and install it when allowedAn internal routing protocol, such as OSPF or IS-IS, often gives routers inside one AS a way to reach each other and to reach BGP next hops. BGP can then exchange routes between ASes and apply policy to those routes.
This division is common, but each network chooses its design. BGP route selection and packet forwarding are related tasks, but they are not the same step.
Quick answers about BGP networks, peer types, and route sharing.
3 answersDoes BGP always choose the shortest route?
No. Policy values can decide the route before BGP compares AS_PATH length. A short AS_PATH also does not prove that the physical route is short or fast.
Do I need BGP inside every company network?
No. Many networks use an internal routing protocol and do not run BGP. BGP is useful when a network needs to exchange routes between ASes or apply detailed route policy.
No. iBGP is BGP between routers in the same AS. An IGP is an interior routing protocol, such as OSPF, that commonly provides routes between routers inside the AS.
Interactive route lab
Compare two routes to the same prefix. Adjust attributes, inspect the routing table, or take a provider link down.
Animated route walkthrough
Animated topology walkthrough for the default scenario. It illustrates the route flow; use the live lab above to change attributes or link state.
BGP field guide
Follow each concept with the interactive lab above this guide. The names, AS numbers, prefix, route values, and outcomes match the simulator.
A network and its routers, managed under one routing policy.
A network range. The lab advertises 192.0.2.0/24, a documentation example.
A BGP session between routers in different autonomous systems.
A BGP session between routers in the same autonomous system.
Read the topology
ISP-A originates the example prefix. It shares the route with two transit providers. Corp-X receives one route from each provider and compares them at its edge router.
Return to the interactive simulatorRouter A1 originates 192.0.2.0/24. The A1–A2 link shares the route inside ISP-A.
The route crosses eBGP from A1 to B1, then from B1 to Corp-X router X1.
The route crosses iBGP from A1 to A2, then eBGP from A2 to C1 and C1 to X1.
Router X1 compares the two available paths. Its chosen path appears in the RIB table and as the forwarding path.
How X1 compares routes
The lab follows this Cisco-style teaching order. Real devices can add settings or use a different order, so check the platform guide.
Higher wins. Cisco-specific and local to one router.
Higher wins. Shared inside an AS to guide outbound traffic.
A route created on this router can be preferred.
A shorter path is usually preferred.
IGP is preferred over EGP, then Incomplete.
Lower is preferred, usually between routes from the same neighbor AS.
An eBGP path is commonly preferred over an iBGP path.
A lower cost to the BGP next hop is preferred.
Some implementations prefer the older external path for stability.
A lower ID may break a remaining tie, depending on the platform.
A lower neighbor address may be the final tie-break.
The simulator gives both candidate routes an equal value for local origination and eBGP/iBGP, because both routes are learned from external peers at X1. Those checks therefore do not decide the default example.
Try the matching presets
The two paths have equal policy values.
Path A through ISP-B wins because its IGP cost is 10, compared with 20 for Path B.
Open the simulatorPath B receives Local Preference 200; Path A stays at 100.
Path B through ISP-C wins at the Local Preference check.
Open the simulatorThe simulator prepends Path A twice, making its example path longer.
Path B wins because its AS_PATH is shorter. Prepending may influence other networks, but it cannot guarantee their choice.
Open the simulatorPath A MED is 50 and Path B MED is 10.
Path B wins in this teaching scenario. The simulator enables comparison across the two provider ASes; routers commonly compare MED only for routes from the same neighboring AS.
Open the simulatorThe link from ISP-B router B1 to Corp-X router X1 is switched off.
Path A becomes unavailable, so forwarding moves to Path B through ISP-C.
Open the simulatorFailover here is an immediate teaching model. It does not run BGP, send a real withdrawal, or measure network convergence timers.
From neighbor to session
Two configured peers first need IP reachability and a TCP connection. They then use BGP messages to agree on a session and exchange reachable prefixes. A session can be up even when a policy rejects every route.
BGP is ready to start a connection.
The router is trying to complete a TCP connection to its peer.
The connection did not complete, so the router tries again.
TCP is up and the router has sent a BGP OPEN message.
The routers wait for a KEEPALIVE to confirm the session.
The session is ready to exchange route updates.
Timer values are negotiated and can be configured. Do not assume a fixed keepalive or hold time for every peer.
The BGP table can show more than one candidate. In this lab, `*` marks a usable route and `>` marks the selected best route. The forwarding-path label names the route the model currently uses.
Weight and Local Preference choose where your own network sends traffic. AS_PATH prepending and MED can influence how a neighboring network sends traffic toward you, but that network makes its own decision.
Use the route rules
Each round changes one part of the decision. Pick a route and see the reason before moving to the next one.
Practice route choice
Compare two routes to the same network. Look for the first rule that makes them different.
Your score
0 / 6
Decision 1 of 6
Decision rule
Cisco Weight
Destination prefix
192.0.2.0/24
Compare Weight first. This is a Cisco-specific value and stays on one router.
A lab before a live network
These command examples use a separate two-router practice lab; its names and addresses differ from the route simulator. Check interfaces, prefixes, and existing policy before applying them.
Choose your platform
These examples use Cisco IOS-XE and FRRouting. Read the lab note before copying a command.
! R1 — AS 65010. Loopback0: 192.0.2.1/24
router bgp 65010
bgp router-id 192.0.2.1
neighbor 198.51.100.2 remote-as 65020
network 192.0.2.0 mask 255.255.255.0
!
! R2 — AS 65020. Loopback0: 203.0.113.1/24
router bgp 65020
bgp router-id 203.0.113.1
neighbor 198.51.100.1 remote-as 65010
network 203.0.113.0 mask 255.255.255.0ip prefix-list LAB-DESTINATION seq 5 permit 203.0.113.0/24
route-map PREFER-ISP-B permit 10
match ip address prefix-list LAB-DESTINATION
set local-preference 200
!
router bgp 65010
neighbor 198.51.100.6 route-map PREFER-ISP-B in
!
! Re-evaluate received routes after the policy change:
clear ip bgp 198.51.100.6 soft in
show ip bgp 203.0.113.0! R1 — loopback 192.0.2.1, AS 65010
router bgp 65010
neighbor 192.0.2.2 remote-as 65010
neighbor 192.0.2.2 update-source Loopback0
neighbor 192.0.2.2 next-hop-self
!
! R2 — loopback 192.0.2.2, AS 65010
router bgp 65010
neighbor 192.0.2.1 remote-as 65010
neighbor 192.0.2.1 update-source Loopback0
!
! Confirm the IGP route to the remote loopback before checking BGP.
show ip route 192.0.2.2
show ip bgp summaryThese examples are for learning and need platform and version checks. Do not paste them into a production router without an approved change plan and route-policy review.
Look beyond the lab
Public tools show what their measurement points can see. They do not show every router's private policy or internal route table.
Continue reading
Configure a small two-router eBGP lab, advertise one route from each side, and check the session safely.
Learn how BGP compares routes to the same network, how policy changes the result, and how to check the selected path.
Reader signal
Your feedback helps shape the next field note and lab.
Views count when this page opens. You can change or remove your vote during this tab session.