3.2.c Configure and verify eBGP between directly connected neighbors

ENCOR 350-401 v1.2 · 3.0 Infrastructure

BGP is the routing protocol of the Internet: it exchanges prefixes between autonomous systems (AS), choosing routes by attributes and policy rather than by a simple metric. eBGP is BGP between routers in different ASes. For ENCOR you configure it between directly connected neighbors and explain how the best path is picked.

What you must know

Neighbor relationships

BGP runs over TCP port 179, so two routers must reach each other by IP first. Neighbors are configured by hand (they are not discovered). eBGP packets are sent with a TTL of 1 by default, which is why eBGP neighbors are normally directly connected; ebgp-multihop relaxes that.

router bgp 65001
 bgp router-id 1.1.1.1
 neighbor 192.0.2.2 remote-as 65002
 network 203.0.113.0 mask 255.255.255.0
StateWhat it means
IdleNot trying yet, or backing off after a failure.
Connect / ActiveTrying to open the TCP connection. Staying here usually means no IP reachability, a wrong neighbor address, or a filter blocking port 179.
OpenSent / OpenConfirmTCP is up and the routers are exchanging OPEN messages. A mismatch (wrong remote AS, bad authentication) shows here.
EstablishedNeighbors are exchanging prefixes.

Best path selection

When a router hears several routes to the same prefix it picks one, using these steps in order (Cisco IOS XE). Stop at the first one that decides:

  1. Highest weight (Cisco-specific, local to this router).
  2. Highest local preference (default 100; shared across the whole AS).
  3. Prefer routes the router originated itself.
  4. Shortest AS path.
  5. Lowest origin code (IGP, then EGP, then incomplete).
  6. Lowest MED (by default compared only between routes from the same neighboring AS).
  7. Prefer eBGP over iBGP.
  8. Lowest IGP metric to the next hop.
  9. Final tie-breakers: oldest eBGP route, then lowest router ID.

To influence outbound traffic, raise local preference (or weight) on the route you prefer. To influence inbound traffic from outside, the usual tools are AS-path prepending and MED.

route-map PREFER-B permit 10
 set local-preference 200
!
router bgp 65000
 neighbor 192.0.2.5 route-map PREFER-B in

Loop prevention and administrative distance

A router rejects any route whose AS path already contains its own AS number, which prevents loops between ASes. eBGP routes have an administrative distance of 20, iBGP routes 200.

Commands

show ip bgp summaryEach neighbor, its AS, uptime and state (a number means prefixes received and the session is Established).
show ip bgpThe BGP table, with the best path marked >.
show ip bgp 198.51.100.0Every path to one prefix and which one was chosen.
show ip route bgpBGP routes that made it into the routing table.
clear ip bgp * softRe-apply policy without tearing the sessions down.

Exam traps

Check yourself

Your eBGP session to a directly connected neighbor stays in Active. List two things to check.
IP reachability to the neighbor address, that the neighbor address and remote-as are right on both sides, and that nothing filters TCP 179.
Two paths to a prefix have weight 0, local preference 100, same origin and the same AS-path length. One is eBGP and one is iBGP. Which wins?
The eBGP path, at the step where eBGP is preferred over iBGP. That comes before any IGP metric or router-ID tie-break.
How would you make all traffic to the Internet leave through ISP-B while keeping ISP-A as a backup?
Set a higher local preference (for example 200) on routes learned from ISP-B, using an inbound route map, so best-path selection prefers them. If ISP-B fails, ISP-A's routes remain.

Labs

Try it live: eBGP peering and best-path selection

More topics in 3.0 Infrastructure