Skip to content

BGP with FRR: peering, prefix advertisement, and route policy basics

How to bring up BGP on Linux with FRR, the four pieces every session needs, basic prefix policy with route-maps, and the verification commands that catch silent peerings.

BGP is the routing protocol that runs the internet, and it also runs inside data centres as the control plane for EVPN, anycast deployments, and Kubernetes-fabric integrations like Cilium and Calico. FRR (Free Range Routing, the fork of Quagga) is the Linux implementation everyone uses; its config syntax is close enough to Cisco IOS that an engineer with a CCNP background is productive within an hour. This article covers the four pieces that make up a BGP session, an eBGP and iBGP example, and the route-map basics for filtering and tagging.

How to verify

Inspect BGP state through vtysh:

vtysh -c 'show ip bgp summary'
vtysh -c 'show ip bgp neighbors <peer-ip>'
vtysh -c 'show ip bgp'
vtysh -c 'show ip route bgp'
vtysh -c 'show running-config'
vtysh -c 'show ip bgp neighbors <peer-ip> advertised-routes'
vtysh -c 'show ip bgp neighbors <peer-ip> received-routes'

show ip bgp summary is the first command after every config change. The “State/PfxRcd” column shows Established once the session is up, and a count of prefixes received from the peer. Idle (Admin) means you shut the neighbour; Active or Connect means TCP cannot complete; numerics in parentheses indicate retry counters.

What’s happening

BGP sessions are TCP connections on port 179 between two routers. Each side has:

  • An AS number — for public BGP, assigned by your RIR; for private use, anything in 64512–65534 (16-bit) or 4200000000–4294967294 (32-bit).
  • A router-id — a 32-bit identifier, usually an IPv4 loopback address. Must be unique across the BGP graph.
  • A neighbour statement for each peer — the peer’s IP and AS, plus optional knobs like update-source, password, multihop.
  • A prefix policy — what you advertise outbound and what you accept inbound, expressed via route-maps.

Two flavours:

  • eBGP — peers in different ASes. The session has full path-vector behaviour: the receiving AS sees the full AS-path the prefix traversed, can apply policy, and announces with its own AS prepended.
  • iBGP — peers in the same AS. Full mesh of sessions, or use route reflectors. iBGP does not prepend AS, and routes received over iBGP are not re-advertised to other iBGP peers (split-horizon) unless route reflection is configured.

FRR runs bgpd as a daemon; configuration lives in /etc/frr/frr.conf or per-daemon files like /etc/frr/bgpd.conf. Most engagements use the integrated single-file approach.

The procedure

  1. Install FRR and enable bgpd.

    apt install frr frr-pythontools
    sed -i 's/^bgpd=no/bgpd=yes/' /etc/frr/daemons
    systemctl restart frr
  2. Set router-id and bring up an eBGP session. Our AS 65001 peering with provider AS 64500 over 198.51.100.0/30:

    ! /etc/frr/frr.conf
    router bgp 65001
     bgp router-id 10.0.0.1
     no bgp default ipv4-unicast
    
     neighbor 198.51.100.1 remote-as 64500
     neighbor 198.51.100.1 password Sup3rSecret
     neighbor 198.51.100.1 description "transit-provider-A"
    
     address-family ipv4 unicast
      neighbor 198.51.100.1 activate
      neighbor 198.51.100.1 prefix-list ROUTES-OUT out
      neighbor 198.51.100.1 prefix-list ROUTES-IN in
      network 203.0.113.0/24
     exit-address-family
    !
    ip prefix-list ROUTES-OUT seq 10 permit 203.0.113.0/24
    ip prefix-list ROUTES-OUT seq 20 deny any
    ip prefix-list ROUTES-IN seq 10 permit 0.0.0.0/0 le 24
    ip prefix-list ROUTES-IN seq 20 deny any

    Apply:

    vtysh -c 'write memory'
    systemctl reload frr
  3. Verify session state and learned prefixes.

    vtysh -c 'show ip bgp summary'
    vtysh -c 'show ip bgp neighbors 198.51.100.1 received-routes'
    vtysh -c 'show ip route bgp'
  4. Add an iBGP mesh inside AS 65001. Two internal routers R1 (10.0.0.1) and R2 (10.0.0.2):

    ! On R1
    router bgp 65001
     neighbor 10.0.0.2 remote-as 65001
     neighbor 10.0.0.2 update-source lo
     neighbor 10.0.0.2 next-hop-self
    
     address-family ipv4 unicast
      neighbor 10.0.0.2 activate
     exit-address-family

    Mirror on R2. next-hop-self is critical — without it, iBGP routes received from eBGP keep the eBGP peer’s IP as next-hop, which other iBGP routers cannot reach.

  5. Apply a route-map to set communities or MEDs on a specific peer.

    route-map TO-PROVIDER permit 10
     match ip address prefix-list ROUTES-OUT
     set community 65001:100 additive
     set metric 100
    !
    router bgp 65001
     address-family ipv4 unicast
      neighbor 198.51.100.1 route-map TO-PROVIDER out
     exit-address-family
  6. Enable BFD for fast failure detection. Default BGP hold-time is 180 seconds — a peer takes 3 minutes to be declared dead. BFD brings detection under a second:

    router bgp 65001
     neighbor 198.51.100.1 bfd
    
    bfd
     peer 198.51.100.1
      receive-interval 300
      transmit-interval 300

Operational notes

  • Always pair eBGP with prefix-lists in both directions. A missing inbound filter means you accept the entire DFZ from a provider, blowing kernel routing-table memory. A missing outbound filter means you advertise everything you have, including private prefixes — and someone will route to them.
  • no bgp default ipv4-unicast prevents IPv4 prefixes from being announced automatically on every neighbour. Combined with explicit activate per address-family, this avoids accidental leakage.
  • Route-server vs full-mesh vs route-reflectors. For more than 4–5 internal routers, full-mesh iBGP becomes painful. Route reflectors are the standard answer.
  • TCP MD5 password (neighbor X password) is the cheap authentication option; modern deployments prefer TCP-AO, but most peers do not support it yet.
  • reset-time doctrine. Soft-reconfiguration inbound lets you re-apply policy without bouncing the session. Enable it on every eBGP peer where you might change inbound filters: neighbor X soft-reconfiguration inbound.

In the engagements we run, BGP shows up in three places: edge routers peering with transit/transport providers, K8s nodes with Calico or Cilium running BGP to a ToR, and EVPN data-centre fabrics. The skeleton above is the minimal working shape. From there we add BFD, route-maps for community-based traffic steering, and bgp graceful-restart for upgrades — each captured in our Ansible role library and operated as part of the managed-operations practice. The OSPF article covers the IGP that BGP sits on top of in most fabrics.