Set up BGP routing with FRRouting for dynamic network routing and failover

Advanced 45 min Apr 03, 2026 60 views
Ubuntu 24.04 Ubuntu 22.04 Debian 12 AlmaLinux 9 Rocky Linux 9 Fedora 41

Configure BGP routing with FRRouting to implement dynamic network routing, automatic failover, and high availability for enterprise network infrastructure with route filtering and policy management.

Prerequisites

  • Root or sudo access
  • Multiple network interfaces
  • Basic understanding of routing concepts
  • Network connectivity to BGP peers

What this solves

BGP (Border Gateway Protocol) routing with FRRouting enables automatic network failover, dynamic route advertisement, and redundant connectivity for enterprise networks. This setup provides high availability by automatically switching traffic between multiple network paths when links fail, eliminating single points of failure. You need this when managing complex network topologies, connecting to multiple ISPs, or implementing redundant data center connectivity.

Step-by-step installation

Update system packages

Start by updating your package manager to ensure you get the latest versions of all packages.

sudo apt update && sudo apt upgrade -y
sudo dnf update -y

Install FRRouting

Install FRRouting daemon which provides BGP, OSPF, and other routing protocols. This installs the main routing engine and command-line tools.

sudo apt install -y frr frr-pythontools
sudo dnf install -y frr frr-pythontools

Enable BGP daemon

Configure FRRouting to enable the BGP daemon. Edit the daemons file to activate BGP routing capabilities.

bgpd=yes
ospfd=no
ospf6d=no
ripd=no
ripngd=no
isisd=no
pimd=no
ldpd=no
nhrpd=no
eigrpd=no
babeld=no
sharpd=no
pbrd=no
staticd=yes
bfdd=no
fabricd=no
vrrpd=no
pathd=no

Configure system IP forwarding

Enable IP forwarding to allow the router to forward packets between network interfaces. This is essential for BGP routing functionality.

echo 'net.ipv4.ip_forward=1' | sudo tee -a /etc/sysctl.conf
echo 'net.ipv6.conf.all.forwarding=1' | sudo tee -a /etc/sysctl.conf
sudo sysctl -p

Start and enable FRRouting

Start the FRRouting service and enable it to start automatically on boot. Verify the service is running correctly.

sudo systemctl enable --now frr
sudo systemctl status frr

Configure BGP peering and route advertisement

Access FRRouting shell

Connect to the FRRouting configuration shell to configure BGP settings. This provides a Cisco-like interface for router configuration.

sudo vtysh

Configure basic BGP settings

Set up your BGP router with autonomous system number and router ID. Replace AS65001 with your actual AS number and use your router's primary IP as router ID.

configure terminal
router bgp 65001
bgp router-id 203.0.113.1
bgp log-neighbor-changes

Configure BGP neighbors

Add BGP neighbors (peers) with their IP addresses and AS numbers. This example shows peering with two different routers for redundancy.

neighbor 203.0.113.10 remote-as 65002
neighbor 203.0.113.10 description "Primary ISP Router"
neighbor 203.0.113.20 remote-as 65003
neighbor 203.0.113.20 description "Secondary ISP Router"
neighbor 203.0.113.10 update-source 203.0.113.1
neighbor 203.0.113.20 update-source 203.0.113.1

Configure network advertisements

Advertise your network prefixes to BGP peers. Add the networks you want to announce to other routers.

network 192.168.1.0/24
network 10.0.0.0/16
exit

Set up route filtering and policies

Create prefix lists for filtering

Define prefix lists to control which routes are accepted or advertised. This improves security and prevents route leaks.

ip prefix-list ALLOW-LOCAL-NETS seq 10 permit 192.168.1.0/24
ip prefix-list ALLOW-LOCAL-NETS seq 20 permit 10.0.0.0/16
ip prefix-list DENY-DEFAULT seq 10 deny 0.0.0.0/0
ip prefix-list DENY-DEFAULT seq 20 permit any

Create route maps for policy control

Configure route maps to apply filtering policies and modify route attributes. This controls traffic flow and implements routing policies.

route-map FILTER-OUT permit 10
match ip address prefix-list ALLOW-LOCAL-NETS
set local-preference 200
exit
route-map FILTER-IN permit 10
match ip address prefix-list DENY-DEFAULT
set weight 100
exit

Apply filters to BGP neighbors

Apply the route maps to BGP neighbors to control inbound and outbound route advertisements.

router bgp 65001
neighbor 203.0.113.10 route-map FILTER-OUT out
neighbor 203.0.113.10 route-map FILTER-IN in
neighbor 203.0.113.20 route-map FILTER-OUT out
neighbor 203.0.113.20 route-map FILTER-IN in

Implement BGP failover and redundancy

Configure BGP timers for faster failover

Reduce BGP keepalive and hold timers for faster detection of neighbor failures. This improves failover speed but increases network overhead.

neighbor 203.0.113.10 timers 10 30
neighbor 203.0.113.20 timers 10 30

Set path preferences with local preference

Configure different local preferences to control primary and backup path selection. Higher values are preferred for outbound traffic.

route-map PRIMARY-PATH permit 10
set local-preference 200
exit
route-map BACKUP-PATH permit 10
set local-preference 100
exit
neighbor 203.0.113.10 route-map PRIMARY-PATH in
neighbor 203.0.113.20 route-map BACKUP-PATH in

Configure MED for inbound traffic control

Use Multi-Exit Discriminator (MED) to influence how external networks reach you. Lower MED values are preferred by remote routers.

route-map SET-MED-PRIMARY permit 10
set metric 50
exit
route-map SET-MED-BACKUP permit 10
set metric 100
exit
neighbor 203.0.113.10 route-map SET-MED-PRIMARY out
neighbor 203.0.113.20 route-map SET-MED-BACKUP out

Enable BGP graceful restart

Configure graceful restart to maintain forwarding during BGP session restarts. This reduces traffic loss during maintenance or brief outages.

bgp graceful-restart
bgp graceful-restart stalepath-time 360
bgp graceful-restart restart-time 120

Save configuration

Save the running configuration to ensure changes persist after reboot.

write memory
exit

Monitor BGP sessions and troubleshoot

Set up BGP logging

Configure detailed BGP logging to monitor session states and troubleshoot issues. This helps identify routing problems and track changes.

sudo vtysh -c "configure terminal" -c "log file /var/log/frr/bgp.log" -c "log record-priority" -c "write memory"

Configure log rotation

Set up log rotation to prevent BGP logs from consuming excessive disk space.

/var/log/frr/*.log {
    daily
    missingok
    rotate 14
    compress
    notifempty
    create 644 frr frr
    postrotate
        systemctl reload frr
    endscript
}
Warning: BGP misconfigurations can cause routing loops or blackhole traffic. Always test configuration changes in a lab environment before applying to production networks. Coordinate with upstream providers before making BGP changes.

Verify your setup

sudo vtysh -c "show ip bgp summary"
sudo vtysh -c "show ip bgp neighbors"
sudo vtysh -c "show ip route bgp"
sudo vtysh -c "show ip bgp"
ping -c 4 203.0.113.10
traceroute 8.8.8.8

Common issues

SymptomCauseFix
BGP neighbors in Idle stateFirewall blocking TCP 179Configure firewall: sudo ufw allow 179
Routes not being advertisedNetworks not in routing tableAdd static routes or configure IGP
Slow failover timesDefault BGP timers too highReduce timers with timers 10 30
Route filtering not workingIncorrect prefix-list syntaxVerify with show ip prefix-list
Session flappingNetwork instability or timer mismatchCheck network connectivity and timer configuration
Memory usage highToo many routes in tableImplement route filtering and summarization

Next steps

Automated install script

Run this to automate the entire setup

#frrouting #bgp #dynamic-routing #network-failover #route-advertisement

Need help?

Don't want to manage this yourself?

We handle infrastructure for businesses that depend on uptime. From initial setup to ongoing operations.

Talk to an engineer