FRRouting BGP on Linux: eBGP and iBGP Configuration - 夜莺博客

FRRouting BGP on Linux: eBGP and iBGP Configuration

FRRouting (FRR) is the de facto standard for running real routing protocols on Linux - it evolved from Quagga and powers everything from homelab routers to production BGP edge servers announcing prefixes to the Internet. Configuration happens in vtysh, a Cisco-style CLI, and the daemons file decides which protocols start. This guide walks through installing FRR, enabling bgpd, and configuring eBGP and iBGP sessions with prefix advertisement and filtering, based on the official FRR documentation.

Install FRR and Enable the BGP Daemon

# Ubuntu/Debian (using the FRR apt repo)
curl -s https://deb.frrouting.org/frr/keys.gpg | sudo tee /usr/share/keyrings/frrouting.gpg > /dev/null
echo "deb [signed-by=/usr/share/keyrings/frrouting.gpg] https://deb.frrouting.org/frr $(lsb_release -s -c) frr-stable" | sudo tee /etc/apt/sources.list.d/frr.list
sudo apt update && sudo apt install frr frr-pythontools

# enable only the daemons you need
sudo sed -i 's/bgpd=no/bgpd=yes/' /etc/frr/daemons
sudo systemctl restart frr

Basic eBGP Session

sudo vtysh
configure terminal
router bgp 65001
 bgp router-id 1.1.1.1
 neighbor 10.0.0.2 remote-as 65002
 neighbor 10.0.0.2 description Peer-AS65002
 address-family ipv4 unicast
  network 192.168.1.0/24
  neighbor 10.0.0.2 activate
 exit-address-family
exit
write memory

The network statement only advertises a prefix if it exists in the kernel routing table - originate it on a loopback or dummy interface (ip addr add 192.168.1.1/24 dev lo) or zebra will not announce it. Set no bgp default ipv4-unicast and explicit activate when running dual-stack or you will advertise IPv4 to every neighbor unintentionally.

iBGP Session (Full Mesh or Route Reflector)

router bgp 65001
 bgp router-id 1.1.1.1
 neighbor 2.2.2.2 remote-as 65001
 neighbor 2.2.2.2 update-source lo      ! peer over loopbacks
 address-family ipv4 unicast
  neighbor 2.2.2.2 activate
  neighbor 2.2.2.2 next-hop-self        ! needed when no IGP carries next-hops
 exit-address-family

iBGP requires full mesh or route reflectors. Turn a router into a reflector with neighbor X route-reflector-client under the address family.

Filtering with Prefix-Lists and Route-Maps

ip prefix-list ALLOW_ONLY seq 5 permit 192.168.1.0/24
ip prefix-list ALLOW_ONLY seq 10 deny 0.0.0.0/0 le 32
route-map FILTER_IN permit 10
 match ip address prefix-list ALLOW_ONLY
exit
router bgp 65001
 neighbor 10.0.0.2 route-map FILTER_IN in
exit

Verification Commands

show ip bgp summary
show ip bgp neighbors 10.0.0.2
show ip bgp
show running-config

Related Guides on This Site

BGP theory applies equally here: review the BGP best-path algorithm, route-reflector cluster-id for larger iBGP meshes, and route flap damping tuning for stability.

原文链接:https://oneuptime.com/blog/post/2026-03-20-bgp-linux-frrouting/view