iBGP between loopbacks
Move the session to the loopbacks. Three things change on each router:
- OSPF on both links, plus the passive loopback, so each router learns the other's /32 over both paths.
- The neighbor is the other router's loopback (198.51.100.2 from R1's point of view).
update-source: send from our own loopback. Without it, R1 would source the TCP connection from whichever link it left by, R2 would see a connection from an address it isn't configured to peer with, and reject it.
Note the order: until OSPF has converged, the session sits in Active, because R1 has no route to 198.51.100.2 yet. A loopback session is only as good as the IGP underneath it.
Once it's up, look at the route to 203.0.113.0/24. Its BGP next hop is R2's loopback, and that resolves through OSPF to both links: equal-cost multipath (ECMP) from a single session.
Now break link A again, exactly as before. R1 stops hearing OSPF hellos on eth0, and after the OSPF dead interval (40 seconds by default) it drops the adjacency. The route to R2's loopback now has one next hop, link B. The BGP session never notices: same uptime, same routes, no withdrawals, and traffic flows over link B.
Between the failure and the dead interval expiring, traffic that hashes onto link A is still lost. That window is now 40 seconds instead of 180 plus "forever", and BFD (section 6) cuts it to under a second.
set protocols ospf parameters router-id '198.51.100.1'
set protocols ospf interface lo area '0'
set protocols ospf interface lo passive
set protocols ospf interface eth0 area '0'
set protocols ospf interface eth0 network 'point-to-point'
set protocols ospf interface eth1 area '0'
set protocols ospf interface eth1 network 'point-to-point'
delete protocols bgp neighbor 192.0.2.1
set protocols bgp neighbor 198.51.100.2 remote-as 'internal'
set protocols bgp neighbor 198.51.100.2 description 'R2 loopback'
set protocols bgp neighbor 198.51.100.2 update-source '198.51.100.1'
set protocols bgp neighbor 198.51.100.2 address-family ipv4-unicast- Lines 1–7: OSPF on both links, plus the loopback as a passive interface.
- Line 8: Remove the old interface-address session.
- Lines 9–10: The new neighbor: R2's loopback.
- Line 11: Source the session from R1's loopback.
- Line 12: Enable IPv4 unicast for the neighbor.
set protocols ospf parameters router-id '198.51.100.2'
set protocols ospf interface lo area '0'
set protocols ospf interface lo passive
set protocols ospf interface eth0 area '0'
set protocols ospf interface eth0 network 'point-to-point'
set protocols ospf interface eth1 area '0'
set protocols ospf interface eth1 network 'point-to-point'
delete protocols bgp neighbor 192.0.2.0
set protocols bgp neighbor 198.51.100.1 remote-as 'internal'
set protocols bgp neighbor 198.51.100.1 description 'R1 loopback'
set protocols bgp neighbor 198.51.100.1 update-source '198.51.100.2'
set protocols bgp neighbor 198.51.100.1 address-family ipv4-unicast- Lines 9–11: R2 sources from its own loopback and peers with R1's.
vyos@R1:~$ show ip ospf neighbor
Neighbor ID Pri State Up Time Dead Time Address Interface RXmtL RqstL DBsmL
198.51.100.2 1 Full/- 14.192s 35.778s 192.0.2.1 eth0:192.0.2.0 0 0 0
198.51.100.2 1 Full/- 14.191s 35.779s 192.0.2.3 eth1:192.0.2.2 0 0 0
vyos@R1:~$ show ip route 198.51.100.2
Routing entry for 198.51.100.2/32
Known via "ospf", distance 110, metric 1, best
Last update 00:00:10 ago
Flags: Selected
Status: Installed
* 192.0.2.1, via eth0, weight 1
* 192.0.2.3, via eth1, weight 1
vyos@R1:~$ show ip bgp summary
IPv4 Unicast Summary:
BGP router identifier 198.51.100.1, local AS number 64500 VRF default vrf-id 0
BGP table version 5
RIB entries 1, using 160 bytes of memory
Peers 1, using 30 KiB of memory
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt Desc
198.51.100.2 4 64500 4 3 5 0 0 00:00:10 1 0 R2 loopback
Total number of neighbors 1
vyos@R1:~$ show ip route 203.0.113.0/24
Routing entry for 203.0.113.0/24
Known via "bgp", distance 200, metric 0, best
Last update 00:00:09 ago
Flags: Recursion iBGP Selected
Status: Installed
198.51.100.2 (recursive), weight 1
* 192.0.2.1, via eth0, weight 1
* 192.0.2.3, via eth1, weight 1- Lines 4–5: One OSPF adjacency per link.
- Lines 13–14: R2's loopback is reachable over both links.
- Line 25: One BGP session, between loopbacks.
- Line 34: The BGP next hop is the loopback…
- Lines 35–36: …which resolves to both links: ECMP.
vyos@R1:~$ show ip ospf neighbor
Neighbor ID Pri State Up Time Dead Time Address Interface RXmtL RqstL DBsmL
198.51.100.2 1 Full/- 1m16s 33.778s 192.0.2.3 eth1:192.0.2.2 0 0 0
vyos@R1:~$ show ip bgp summary
IPv4 Unicast Summary:
BGP router identifier 198.51.100.1, local AS number 64500 VRF default vrf-id 0
BGP table version 5
RIB entries 1, using 160 bytes of memory
Peers 1, using 30 KiB of memory
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt Desc
198.51.100.2 4 64500 5 4 5 0 0 00:01:11 1 0 R2 loopback
Total number of neighbors 1
vyos@R1:~$ show ip bgp neighbors 198.51.100.2 | match "BGP state"
BGP state = Established, up for 00:01:12
vyos@R1:~$ show ip route 203.0.113.0/24
Routing entry for 203.0.113.0/24
Known via "bgp", distance 200, metric 0, best
Last update 00:00:07 ago
Flags: Recursion iBGP Selected
Status: Installed
198.51.100.2 (recursive), weight 1
* 192.0.2.3, via eth1, weight 1
vyos@R1:~$ ping 203.0.113.1 count 3
PING 203.0.113.1 (203.0.113.1) 56(84) bytes of data.
64 bytes from 203.0.113.1: icmp_seq=1 ttl=64 time=1.81 ms
64 bytes from 203.0.113.1: icmp_seq=2 ttl=64 time=3.19 ms
64 bytes from 203.0.113.1: icmp_seq=3 ttl=64 time=2.56 ms
--- 203.0.113.1 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2009ms
rtt min/avg/max/mdev = 1.811/2.522/3.191/0.564 ms- Line 4: OSPF has dropped the link A adjacency.
- Line 15: The BGP session is untouched: up 1m11s, longer than the time since the failure.
- Lines 26–27: Same next hop, now resolved via link B only.
- Lines 31–33: Traffic flows.
Check your understanding
In the loopback design, why didn't the BGP session go down when link A failed?
- BGP was configured with a longer hold timer
- OSPF moved the route to R2's loopback onto link B, so the TCP session's packets kept getting through
- iBGP sessions can't go down
- Because of ECMP, half the keepalives still got through