From point A to point B
Point A: you have eBGP sessions up with 2-byte and 4-byte ASNs, and you look at show ip bgp without being sure which table you are reading. Point B: you know where each route lives (Adj-RIB-In, Loc-RIB, Adj-RIB-Out), where each policy acts, how to filter a prefix from one neighbor, and how to carry the Internet routes to the last router in your AS with iBGP.
Jesús puts it plainly: this architecture is half of understanding BGP. Once you master it, troubleshooting and policies stop feeling like magic.
- Adj-RIB-In, Loc-RIB and Adj-RIB-Out, and where inbound and outbound policies come in.
- A dual-homed scenario and why BGP doesn't look at bandwidth.
received-routes,advertised-routesandsoft-reconfiguration inbound.- eBGP loop prevention with the AS_PATH and an inbound filter with a prefix-list and a route-map.
- iBGP between loopbacks over OSPF,
next-hop-self, the iBGP loop prevention rule and full mesh.
The three BGP tables
Some books say BGP handles four tables. The class is more precise: BGP manages three and injects information into a fourth, the routing table, which doesn't depend on BGP. You can have a routing table with static routes only. RFC 4271 describes those three parts like this:
- Adj-RIB-In: everything each neighbor advertises to you in its UPDATEs, unprocessed. There is one per peer.
- Loc-RIB: the BGP table you see with
show ip bgp. It holds the valid routes, the best path algorithm runs here, and the best route comes out of here. - Adj-RIB-Out: what you are going to advertise to each neighbor. There is also one per peer.
Only the best route in the Loc-RIB goes to the routing table (show ip route) with code B. And the routing table is what the router uses to forward packets.
One Adj-RIB-In and one Adj-RIB-Out per neighbor; the inbound policy acts before the Loc-RIB and the outbound policy before the Adj-RIB-Out. Diagram: The House of Routing.
Each peer is a virtual session: a logical cable over TCP that doesn't depend on the physical connections. That is why you can have granular policies per neighbor and per direction. An inbound policy filters or changes what arrives before it lands in the Loc-RIB. An outbound policy decides what is advertised to each neighbor. Whenever you build a filter, ask yourself: inbound or outbound?
Dual-homed: one prefix, two paths
With the R2–R4 and R1–R3 sessions up, R4 stands for the ACME.com corporation: a company with two Internet providers. In show ip bgp you see 11.11.11.0 twice: via 172.16.3.2 (AS_PATH 200 100) and via 172.16.4.3 (AS_PATH 1.1 100).
Both routes are valid, but only one is best, and only that one enters the routing table. Here BGP chose the one via 172.16.3.2. Why? Because BGP sees autonomous systems and attributes, not routers or bandwidth. Behind AS 200 there may be one router or hundreds. If your own fiber link goes through the other provider, BGP doesn't know. That is where routing policies begin.
show ip bgp summary), then how many prefixes you receive, then debug and messages, and finally the BGP table and the routing table. With address families, the same summary is show ip bgp ipv4 unicast summary: ipv4 is the AFI and unicast the SAFI.received-routes and advertised-routes
R1 advertises two more loopbacks, 22.22.22.0/24 and 33.33.33.0/24. Now R4 receives four prefixes from each provider.
R1(config)# interface loopback 22
R1(config-if)# ip address 22.22.22.22 255.255.255.0
R1(config)# interface loopback 33
R1(config-if)# ip address 33.33.33.33 255.255.255.0
R1(config)# router bgp 100
R1(config-router)# network 22.22.22.0 mask 255.255.255.0
R1(config-router)# network 33.33.33.0 mask 255.255.255.0
To see the Adj-RIB-Out you use advertised-routes. Toward R2, R4 advertises 11, 20, 22, 30, 33 and 40. Only 40 is its own; it passes the rest along, because that is how BGP works.
To see the Adj-RIB-In you use received-routes. On Cisco, that command needs soft-reconfiguration inbound on the neighbor. With it, the router stores that peer's UPDATEs unmodified, regardless of the inbound policy. You configure it neighbor by neighbor.
! Adj-RIB-Out: what R4 advertises to R2
R4# show ip bgp neighbor 172.16.3.2 advertised-routes
! Adj-RIB-In: Cisco needs soft-reconfiguration inbound, per neighbor
R4(config)# router bgp 1.2
R4(config-router)# neighbor 172.16.3.2 soft-reconfiguration inbound
R4# show ip bgp neighbor 172.16.3.2 received-routes
! Loc-RIB and routing table
R4# show ip bgp
R4# show ip route
eBGP loop prevention: the AS_PATH
Follow 40.40.40.0, which R4 originates. It leaves with AS_PATH 1.2 toward R3. R3 advertises it to R1 with 1.1 1.2. R1 passes it to R2 with 100 1.1 1.2. And R2 sends it back to R4 with 200 100 1.1 1.2. The same happens in the other direction.
When that UPDATE reaches R4, the router checks the AS_PATH, finds its own AS and drops the route. That is why 40.40.40.0 never shows up in R4's table as learned from its neighbors. This is the eBGP loop prevention rule: if you see your own AS in the AS_PATH, the route doesn't get in.
An inbound filter with a route-map
The company asks for something specific. 11.11.11.0 is the network of a VIP customer, and its traffic must not leave through R2: it must go through R3. That is traffic engineering. You could solve it with local preference or AS_PATH prepend, which you will see later. Here the solution is an inbound filter on neighbor 172.16.3.2.
To pick the prefix you could use an access list or a distribute-list. Jesús picks a prefix-list, which is handier, and ties it to a route-map. The route-map is the most scalable and flexible tool for filtering and routing policies, inbound or outbound.
R4(config)# ip prefix-list PL-DENY-11 seq 10 deny 11.11.11.0/24
R4(config)# ip prefix-list PL-DENY-11 seq 20 permit 0.0.0.0/0 le 32
R4(config)# route-map DENY-11 permit 10
R4(config-route-map)# match ip address prefix-list PL-DENY-11
R4(config-route-map)# exit
R4(config)# router bgp 1.2
R4(config-router)# neighbor 172.16.3.2 route-map DENY-11 in
R4# clear ip bgp 172.16.3.2 soft in
R4# show ip bgp
R4# show ip route
R4# ping 11.11.11.11 source 40.40.40.40
The prefix-list denies 11.11.11.0/24 and permits everything else. Without that permit line, the implicit deny at the end would block every prefix. The route-map has a single permit entry: whatever the prefix-list denies doesn't match it and falls into the route-map's implicit deny.
Then you apply the change without dropping the session using clear ip bgp 172.16.3.2 soft in. You read the result in the three tables:
received-routesstill shows 11.11.11.0: the Adj-RIB-In stores what arrives.show ip bgpnow has 11.11.11.0 only via 172.16.4.3: the policy removed it before the Loc-RIB.show ip routeand the ping from 40.40.40.40 confirm that traffic leaves through R3.
iBGP between loopbacks over OSPF
The border is done. Now it is the inside of AS 1.2: R4, R5 and R6. The real-world rule is to run iBGP between loopbacks, not physical interfaces, and to let the IGP advertise those loopbacks. Here the IGP is OSPF area 0.
R4(config)# interface GigabitEthernet0/1
R4(config-if)# ip address 172.16.5.4 255.255.255.0
R4(config-if)# ip ospf 1 area 0
R4(config)# interface loopback 0
R4(config-if)# ip ospf 1 area 0
R4(config)# router ospf 1
R4(config-router)# router-id 0.0.0.4
R4(config)# router bgp 1.2
R4(config-router)# neighbor 50.50.50.50 remote-as 1.2
R4(config-router)# neighbor 50.50.50.50 update-source loopback 0
R4(config-router)# neighbor 60.60.60.60 remote-as 1.2
R4(config-router)# neighbor 60.60.60.60 update-source loopback 0
R5(config)# interface loopback 0
R5(config-if)# ip address 50.50.50.50 255.255.255.0
R5(config-if)# ip ospf 1 area 0
R5(config)# interface GigabitEthernet0/0
R5(config-if)# ip address 172.16.5.5 255.255.255.0
R5(config-if)# ip ospf 1 area 0
R5(config-if)# no shutdown
R5(config)# router ospf 1
R5(config-router)# router-id 0.0.0.5
R5# show ip ospf neighbor
R5# show ip route | include O
R5(config)# router bgp 1.2
R5(config-router)# bgp router-id 50.50.50.50
R5(config-router)# bgp asnotation dot
R5(config-router)# neighbor 40.40.40.40 remote-as 1.2
R5(config-router)# neighbor 40.40.40.40 update-source loopback 0
Three ideas from this part:
- iBGP is a
remote-aswith your own AS, andupdate-source loopback 0makes the session leave from the loopback. - Best practice is to advertise prefixes from the border router. In the lab
networkis used on any router, but in production you advertise at the edge. And remember: if the prefix isn't in the routing table,networkdoesn't advertise it. - BGP doesn't need redistribution in the vast majority of cases. OSPF only provides reachability between the internal routers.
On R5 the OSPF adjacency didn't come up. The cause: OSPF was on the wrong interface. An orderly troubleshooting finds it in minutes. And a warning from Jesús: clear ip bgp * is a hard reset. Use it freely in the lab; not in production.
iBGP doesn't change the next hop
R5 receives six prefixes from R4, but the Internet ones show up as valid, not best, and they don't reach the routing table. 11.11.11.0 shows next hop 172.16.4.3.
The explanation is at the border. R3, being eBGP, changes the next hop to its own IP, 172.16.4.3. R4 has two faces: eBGP outward and iBGP inward. By default, when it advertises to an iBGP neighbor it doesn't change the next hop. R5 doesn't know the 172.16.4.0/24 network in OSPF, so it can't resolve that next hop.
Without next-hop-self, R5 gets a next hop it can't reach; with next-hop-self, the next hop is R4's loopback, which OSPF does know. Diagram: The House of Routing.
The fix is neighbor 50.50.50.50 next-hop-self on R4 plus an outbound soft refresh, which updates the neighbor without resetting the peering. Now the next hop is 40.40.40.40, OSPF reaches it and the routes become best. R5 advertises its loopback 50.50.50.0, and the ping to 22.22.22.22 sourced from 50.50.50.50 replies.
R4(config)# router bgp 1.2
R4(config-router)# neighbor 50.50.50.50 next-hop-self
R4# clear ip bgp 50.50.50.50 soft out
R5# show ip bgp
R5# show ip route
R5(config)# router bgp 1.2
R5(config-router)# network 50.50.50.0 mask 255.255.255.0
R5# ping 22.22.22.22 source 50.50.50.50
iBGP loop prevention and full mesh
R6 is still missing. You configure OSPF with R5 and an iBGP session between loopbacks. The session stays in Idle on one side and Active on the other: R6's loopback wasn't in OSPF and R5 had no way to reach it. Once it is added, the session comes up.
Two reading details on R6:
- 50.50.50.50 arrives through OSPF and through iBGP. With the same prefix and different protocols, the lowest administrative distance wins: OSPF (110) over iBGP (200).
- In
show ip bgpthere are two different "i" letters: the one on the left marks a route learned through iBGP; the one at the end of the path is the IGP origin, that is, advertised withnetwork.
Then comes the surprise: R6 receives only one prefix from R5. This is the iBGP loop prevention rule: a route learned from an iBGP neighbor is not advertised to another iBGP neighbor. In eBGP the AS_PATH prevents loops; inside the AS the AS_PATH doesn't change, so BGP uses this rule instead.
The consequence is the full mesh: every iBGP router must have a session with all the others. R4 already had neighbor 60.60.60.60 configured; R6 adds 40.40.40.40. The R4–R6 session goes through R5, because it is a logical one. With next-hop-self toward R6 and a soft refresh, R6 installs the Internet routes. R6 advertises 60.60.60.0; R1 sees it with administrative distance 20, the eBGP one, and the ping to 60.60.60.60 from 22.22.22.22 replies.
! R5: iBGP toward R6
R5(config)# router bgp 1.2
R5(config-router)# neighbor 60.60.60.60 remote-as 1.2
R5(config-router)# neighbor 60.60.60.60 update-source loopback 0
! R6: OSPF with R5 and iBGP between loopbacks
R6(config)# interface loopback 0
R6(config-if)# ip address 60.60.60.60 255.255.255.0
R6(config-if)# ip ospf 1 area 0
R6(config)# router bgp 1.2
R6(config-router)# bgp router-id 6.6.6.6
R6(config-router)# neighbor 50.50.50.50 remote-as 1.2
R6(config-router)# neighbor 50.50.50.50 update-source loopback 0
! full mesh: R6 also peers with R4
R6(config-router)# neighbor 40.40.40.40 remote-as 1.2
R6(config-router)# neighbor 40.40.40.40 update-source loopback 0
R6(config-router)# network 60.60.60.0 mask 255.255.255.0
! R4: next hop for R6, then a soft refresh toward it
R4(config)# router bgp 1.2
R4(config-router)# neighbor 60.60.60.60 next-hop-self
R4# clear ip bgp 60.60.60.60 soft out
With 3 routers the full mesh is 3 sessions; with n routers it is n(n-1)/2. That growth doesn't scale. The way out is the route reflector and confederations, which open the 2nd Marathon and the next chapter.
Class videos
These are the three parts of the 1st BGP Marathon that go with this chapter. Jesús recorded them live on February 26, 2021, with Cisco IOSv routers in GNS3. The audio is in Spanish, with subtitles in Spanish, English, French and Portuguese.
- Day 1 · Part 6AS_TRANS 23456, dual-homing and Adj-RIB-In / Loc-RIB / Adj-RIB-OutWatch video
- Day 1 · Part 7Loop prevention, route-map filters and iBGP between loopbacksWatch video
- Day 1 · Part 8next-hop-self, iBGP full mesh and the close of the 1st marathonWatch video
Recorded live; Spanish audio with Spanish, English, French and Portuguese subtitles. When you play it, the video loads from YouTube. Day 1 playlist on YouTube
Test what you learned
1. You run show ip bgp neighbors 172.16.3.2 received-routes and the router doesn't show the routes. What is missing on a Cisco router?
Answer. You are missing neighbor 172.16.3.2 soft-reconfiguration inbound. With it, the router stores that neighbor's UPDATEs unmodified, which is what received-routes shows. It is configured per neighbor.
2. You apply the DENY-11 route-map inbound. In which table does 11.11.11.0 from R2 still appear, and in which one is it gone?
Answer. It is still in the Adj-RIB-In (received-routes), which stores what arrives. It is gone from the Loc-RIB (show ip bgp) for that neighbor, because the inbound policy acts before the Loc-RIB.
3. R4 advertises 40.40.40.0 and the route comes back to it through both providers. Why doesn't it install it?
Answer. Because it finds its own AS (1.2) in the AS_PATH. That is eBGP loop prevention.
4. R5 has 11.11.11.0 in the BGP table as valid but not best, and doesn't see it in show ip route. What do you check first?
Answer. The next hop. R4 passed it unchanged (172.16.4.3) and R5 can't reach it through OSPF. The fix is next-hop-self on R4 toward R5.
5. R6 has an iBGP session with R5 but receives only one prefix. Why, and how do you fix it in the lab?
Answer. Because of the iBGP rule: what is learned from an iBGP neighbor is not advertised to another iBGP neighbor. You fix it with a full mesh, an R4–R6 session with next-hop-self. At larger scale, with a route reflector or confederations.
Key takeaways
- BGP manages three tables: Adj-RIB-In and Adj-RIB-Out per neighbor, and the Loc-RIB (
show ip bgp) where the best path runs. Only the best route goes toshow ip route. - Inbound policies act before the Loc-RIB; outbound policies, before the Adj-RIB-Out.
- BGP doesn't look at bandwidth: if you want another path, you decide it with policies.
- In eBGP, seeing your own AS in the AS_PATH drops the route.
- A route-map with a prefix-list filters prefixes per neighbor; apply it with a soft refresh, not with
clear ip bgp *. - iBGP runs between loopbacks advertised by the IGP, with
update-source, and doesn't change the next hop: usenext-hop-selfat the border. - What is learned through iBGP isn't advertised to another iBGP peer: full mesh today, route reflector and confederations tomorrow.
Official resources
- RFC 4271: A Border Gateway Protocol 4 (BGP-4)rfc-editor.org
- Examine Border Gateway Protocol Case Studies (Cisco)cisco.com
- BGP Configuration Guide: Configuring a Basic BGP Network (Cisco IOS XE)cisco.com
- Block One or More Networks From a BGP Peer (Cisco)cisco.com
- Configure iBGP and eBGP with or without a Loopback Address (Cisco)cisco.com
- Understand Administrative Distance (Cisco)cisco.com
- RFC 4456: BGP Route Reflectionrfc-editor.org
Source and credits. Chapter written from the BGP Masterclass that Jesús Espinoza recorded live in 2021. Text drafted with AI assistance and reviewed; original diagrams by The House of Routing. Technical details and configuration were checked against official Cisco documentation and IETF RFCs.