Lab: configuring eBGP in FRR
Time for real configuration. This lab uses FRRouting (FRR), the open-source routing suite used in SONiC, Cumulus, VyOS and many Linux-based routers. Its syntax is close to Cisco IOS, so it transfers well.
Two routers, each in its own AS, each originating one prefix. The goal: an Established session and each router learning the other's prefix.
To build this yourself, two FRR containers on a shared Docker network are enough (or use containerlab). Enable bgpd=yes in /etc/frr/daemons, drop in the configs below and run vtysh.
The verification output below was captured from these exact two configs running on FRR 10.2.1.
Hover or click an annotation to highlight the lines it refers to.
frr version 10.2
frr defaults traditional
hostname R1
!
interface eth0
description Link to R2 (AS 64501)
ip address 192.0.2.1/30
!
interface lo
ip address 10.255.0.1/32
!
ip route 198.51.100.0/24 Null0
!
router bgp 64500
bgp router-id 10.255.0.1
no bgp ebgp-requires-policy
neighbor 192.0.2.2 remote-as 64501
neighbor 192.0.2.2 description R2-AS64501
!
address-family ipv4 unicast
network 198.51.100.0/24
exit-address-family
!- Lines 1–2:
frr defaults traditionalkeeps classic timers (60s keepalive / 180s hold). Thedatacenterprofile uses aggressive 3s/9s timers. - Lines 5–7: The point-to-point link to R2. eBGP peers are normally directly connected — the default eBGP TTL is 1.
- Lines 9–10: A loopback gives the router a stable identity that never goes down with a physical interface.
- Line 12: A static discard route.
networkonly advertises a prefix that exists in the RIB, so we anchor the aggregate to Null0. - Line 14: Start the BGP process for local AS 64500. One BGP process per router.
- Line 15: Pin the router ID explicitly. If you don't, it is chosen from the highest loopback/interface IP and may change.
- Line 16: FRR follows RFC 8212: eBGP routes are not exchanged without a policy. We disable that here to get the session working, and add real policy in the next section.
- Lines 17–18: Define the peer.
remote-asdifferent from our AS means this is eBGP. - Lines 20–22: Activate the IPv4 unicast address family and originate our prefix.
frr version 10.2
frr defaults traditional
hostname R2
!
interface eth0
description Link to R1 (AS 64500)
ip address 192.0.2.2/30
!
interface lo
ip address 10.255.0.2/32
!
ip route 203.0.113.0/24 Null0
!
router bgp 64501
bgp router-id 10.255.0.2
no bgp ebgp-requires-policy
neighbor 192.0.2.1 remote-as 64500
neighbor 192.0.2.1 description R1-AS64500
!
address-family ipv4 unicast
network 203.0.113.0/24
exit-address-family
!- Lines 14–17: The mirror image of R1: local AS 64501, neighbor 192.0.2.1 in AS 64500. Both sides must agree on each other's AS number or the OPEN is rejected with a NOTIFICATION (Bad Peer AS).
R1# show bgp ipv4 unicast summary
BGP router identifier 10.255.0.1, local AS number 64500 VRF default vrf-id 0
BGP table version 2
RIB entries 3, using 384 bytes of memory
Peers 1, using 17 KiB of memory
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt Desc
192.0.2.2 4 64501 5 5 2 0 0 00:00:24 1 2 R2-AS64501
Total number of neighbors 1
R1# show bgp ipv4 unicast
BGP table version is 2, local router ID is 10.255.0.1, vrf id 0
Default local pref 100, local AS 64500
Status codes: s suppressed, d damped, h history, u unsorted, * valid, > best, = multipath,
i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
Network Next Hop Metric LocPrf Weight Path
*> 198.51.100.0/24 0.0.0.0 0 32768 i
*> 203.0.113.0/24 192.0.2.2 0 0 64501 i
Displayed 2 routes and 2 total paths- Line 2: Router ID and local AS — the first thing to sanity-check.
- Lines 7–8: A number in State/PfxRcd means Established and shows prefixes received. A word here (Idle, Active, Connect) means the session is down. PfxSnt is 2 because FRR also advertises R2's own prefix back to it, with path
64500 64501; R2 discards it on sight, since its own ASN is in the path (AS_PATH loop prevention). - Line 22:
*>= valid and best. Next hop 0.0.0.0 means locally originated; weight 32768 is the default for local routes. - Line 23: Learnt from R2: next hop is R2's link address and the AS_PATH is just 64501.