Skip to content
LinkState
Go back

eBGP multihop over loopbacks without session roulette

#How update‑source, multihop TTL, next‑hop handling, and GTSM interact when eBGP is moved to loopbacks

Introduction

External BGP (eBGP) exchanges NLRI between routers in different autonomous systems using a TCP session on port 179. The protocol relies on several key attributes—Router ID, Hold Time, Optional Parameters, and the NEXT_HOP attribute—to select the best path and install routes in the FIB.

A loopback interface provides a stable, always‑up IP address that is not tied to any physical port. Using a loopback for eBGP transport offers:

Moving the BGP endpoint to a loopback, however, introduces dependencies on update‑source, multihop TTL, next‑hop handling, and the Generalized TTL Security Mechanism (GTSM). If these are not configured correctly, the session may flap or never reach ESTABLISHED even though basic IP reachability (e.g., ping) appears fine.


Update‑Source and Next‑Hop Handling

Update‑Source

The update‑source knob tells the BGP process which interface (or IP address) to use as the source IP for outgoing TCP packets. Without it, the router selects the primary IP of the outgoing physical interface that matches the route to the peer, based on the local RIB entry for the peer’s address.

Control‑plane trace (no update‑source)

  1. BGP initiates a TCP OPEN. 2. The TCP stack queries the FIB for the destination peer address.
  2. The FIB returns an outgoing interface (e.g., GigabitEthernet0/0/0).
  3. The TCP source address is chosen from the addresses configured on that interface (usually the lowest‑numbered IP).

With update‑source configured – step 4 is overridden and the specified address (often a loopback) is used instead.

Next‑Hop Attribute

The NEXT_HOP attribute in a BGP UPDATE indicates the IP address that should be used as the next hop toward the advertised prefix. For eBGP, the default NEXT_HOP is the IP address of the BGP speaker that sent the UPDATE (i.e., the neighbor’s source IP). The receiving router must resolve this NEXT_HOP via its IGP (or static routes) to a reachable outgoing interface before installing the route in the FIB.

Control‑plane trace

  1. Router A receives an UPDATE from Router B with NEXT_HOP = Router B’s BGP source IP.
  2. Router A performs a recursive lookup: it searches its RIB for a route to that NEXT_HOP.
  3. If a matching route exists, the corresponding outgoing interface and next‑hop MAC are programmed into the FIB.
  4. If the lookup fails, the route is marked unreachable and is not installed, even though the BGP session may be ESTABLISHED.

Interaction Between update‑source and Next‑Hop

When the BGP transport endpoint is moved to a loopback, the source IP of the TCP packets (controlled by update‑source) often differs from the interface IP used for ordinary data traffic. This can cause two distinct problems:

update‑source (local)  ==  neighbor address (remote)
IGP route to peer’s loopback exists  ==>  NEXT_HOP reachable

Multihop TTL and GTSM

Multihop TTL

By default, eBGP packets are sent with an IP TTL of 1 (RFC 4271, §8.2), limiting eBGP to directly connected peers. To allow eBGP over multiple hops, the multihop feature (often configured via neighbor ebgp-multihop or ttl) increases the TTL value in the outgoing IP header so packets can traverse the required number of routers before expiring.

Control‑plane trace

  1. BGP process constructs a TCP segment.
  2. IP layer sets the TTL field to the value specified by the multihop setting (or to 255 if GTSM is enabled).
  3. Each hop decrements TTL; if it reaches 0 before arriving at the peer, the packet is discarded and an ICMP Time‑Exceeded may be generated.
  4. The peer never sees the TCP SYN, so the session stays in Idle/Active state.

Generalized TTL Security Mechanism (GTSM)

Defined in RFC 5082, GTSM protects BGP sessions from spoofed or forged packets by expecting that legitimate BGP packets arrive with an IP TTL of 255 (or 255 − expected hop count when multihop is used).

GTSM Assumptions and Potential Issues GTSM assumes:

  1. Symmetric path length – the number of hops from sender to receiver equals the number from receiver to sender.
  2. Static TTL value – the sender always transmits with TTL = 255 (direct) or 255 − hop‑count (multihop).
  3. No TTL‑altering devices in the path – devices that rewrite TTL (e.g., certain firewalls, load balancers, or MPLS nodes with TTL propagation disabled) break the assumption.

When these assumptions are violated, legitimate BGP packets are dropped, causing the session to flap or never reach ESTABLISHED. Common misconfigurations include:


Moving eBGP to Loopbacks

Motivations

Configuration Examples

The examples below assume AS 65001 (local) peering with AS 65002 (remote) using loopback 0 addresses 10.0.0.1/32 and 10.0.0.2/32 respectively. The physical path consists of two hops (local → transit → remote). #### Cisco IOS / IOS‑XE

! Local router (AS 65001)
interface Loopback0
 ip address 10.0.0.1 255.255.255.255!
router bgp 65001
 neighbor 10.0.0.2 remote-as 65002 neighbor 10.0.0.2 update-source Loopback0   ! source TCP from loopback
 neighbor 10.0.0.2 ebgp-multihop 2          ! allow 2 hops neighbor 10.0.0.2 ttl-security hops 2      ! enable GTSM for 2‑hop path
!
! Ensure IGP (OSPF/IS‑IS) advertises the loopbackrouter ospf 1
 network 10.0.0.1 0.0.0.0 area 0

Juniper Junos

# Local router (AS 65001)
set interfaces lo0 unit 0 family inet address 10.0.0.1/32
set protocols bgp group ext-peers type external
set protocols bgp group ext-peers peer-as 65002
set protocols bgp group ext-peers neighbor 10.0.0.2 local-address 10.0.0.1
set protocols bgp group ext-peers neighbor 10.0.0.2 multihop ttl 2
set protocols bgp group ext-peers neighbor 10.0.0.2 multihop
set protocols bgp group ext-peers neighbor 10.0.0.2 ttl-security
# OSPF to advertise loopback
set protocols ospf area 0.0.0.0 interface lo0.0

FRR (Free Range Routing) ```bash

! Local router (AS 65001) interface lo ip address 10.0.0.1/32 ! router bgp 65001 neighbor 10.0.0.2 remote-as 65002 neighbor 10.0.0.2 update-source lo neighbor 10.0.0.2 ebgp-multihop 2 neighbor 10.0.0.2 ttl-security hops 2 ! ! OSPF example router ospf ospf router-id 10.0.0.1 network 10.0.0.1/32 area 0


**Key points**  

* `update-source` (or `local-address`) forces the TCP source to be the loopback.  
* `ebgp-multihop` (or `multihop ttl`) raises the outgoing TTL to allow the required number of hops.  * `ttl-security` (or `ttl-security hops`) enables GTSM and tells the router the expected hop count; the router will then only accept incoming packets with TTL = 255 − hop‑count.  

### Verification (Cisco example)  

```bash
show bgp neighbors 10.0.0.2

Expected output snippet:

BGP neighbor is 10.0.0.2, remote AS 65002, external link
  BGP version 4, remote router ID 10.0.0.2
  BGP state = Established, up for 00:15:23
  Last read 00:00:02, last write 00:00:02
  Hold time is 180, keepalive interval is 60
  Received 1200 packets, sent 1180 packets
  ...
  Local host: 10.0.0.1, Local port: 179
  Foreign host: 10.0.0.2, Foreign port: 54321```

---

## Conclusion  

Moving eBGP to loopback interfaces improves stability and simplifies policy, but it hinges on the correct interplay of four mechanisms:

1. **update‑source** – must match the neighbor’s configured peer address.  
2. **next‑hop resolution** – the advertised loopback must be reachable via the IGP.  
3. **multihop TTL** – must be set high enough for the actual path length.  
4. **GTSM** – must be enabled consistently on both sides with the correct hop‑count expectation.  

Misconfiguring any of these can leave the session stuck in Idle/Active or cause it to flap, even when basic IP reachability (ping) appears successful. Proper verification—checking BGP state, confirming IGP routes to loopbacks, and validating TTL/GTSM settings—is essential for a reliable eBGP-over‑loopback deployment.

Share this post on:

Previous Post
Recursive next-hop resolution that selects a dead exit
Next Post
Session up, prefixes zero, and the silent policy mismatch