-
Notifications
You must be signed in to change notification settings - Fork 462
ExaBGP CLI
Thomas Mangin edited this page Nov 15, 2025
·
4 revisions
The ExaBGP command-line interface (CLI) provides tools for running, testing, and managing ExaBGP instances. This guide covers all CLI options and usage patterns.
- Overview
- Basic Usage
- Command-Line Arguments
- Configuration Validation
- Environment Variables
- Interactive Mode
- Operational Commands
- Debugging Options
- Best Practices
- See Also
Important: ExaBGP does NOT manipulate the routing table (RIB/FIB). The CLI tool is used to start ExaBGP, validate configurations, and control operational behavior.
exabgp [options] <configuration-file>-
Start ExaBGP:
exabgp /etc/exabgp/exabgp.conf -
Validate config:
exabgp --test /etc/exabgp/exabgp.conf -
Enable debugging:
exabgp --debug /etc/exabgp/exabgp.conf -
Check version:
exabgp --version
# Start with configuration file
exabgp /etc/exabgp/exabgp.conf
# Start with full path
exabgp /etc/exabgp/exabgp.conf
# Start in foreground (no daemon)
exabgp /etc/exabgp/exabgp.conf
# Start with environment overrides
env exabgp.daemon.daemonize=false exabgp /etc/exabgp/exabgp.conf# Start via systemd
sudo systemctl start exabgp
# Enable on boot
sudo systemctl enable exabgp
# Check status
sudo systemctl status exabgp
# View logs
sudo journalctl -u exabgp -f# Run ExaBGP in Docker
docker run -v /etc/exabgp:/etc/exabgp:ro \
-v /var/run/exabgp:/var/run/exabgp \
--net=host \
exa-networks/exabgp:latest \
/etc/exabgp/exabgp.conf# Display ExaBGP version
exabgp --version
# Output:
# ExaBGP 5.0.0# Display help message
exabgp --help
# Display detailed help
exabgp --help-all# Specify configuration file (required)
exabgp /etc/exabgp/exabgp.conf
# Using environment variable
export EXABGP_CONF=/etc/exabgp/exabgp.conf
exabgp $EXABGP_CONF# Validate configuration without starting ExaBGP
exabgp --test /etc/exabgp/exabgp.conf
# Output on success:
# configuration validated
# Output on error:
# Error: syntax error in configuration file# Enable debug output
exabgp --debug /etc/exabgp/exabgp.conf
# Enable specific debug categories
env exabgp.log.level=DEBUG exabgp /etc/exabgp/exabgp.conf
# Debug network traffic
env exabgp.log.network=true exabgp /etc/exabgp/exabgp.conf# Decode BGP packets from file
exabgp --decode /path/to/bgp-packets.bin
# Decode with specific address family
exabgp --decode /path/to/bgp-packets.bin --family ipv4# Run without forking (for containerized environments)
env exabgp.daemon.daemonize=false exabgp /etc/exabgp/exabgp.conf
# Disable privileges drop (not recommended)
env exabgp.daemon.user='' exabgp /etc/exabgp/exabgp.conf# Validate configuration syntax
exabgp --test /etc/exabgp/exabgp.conf
# Exit codes:
# 0 = configuration valid
# 1 = configuration invalid#!/bin/bash
# /usr/local/bin/validate-and-reload.sh
CONFIG="/etc/exabgp/exabgp.conf"
# Validate configuration
if exabgp --test "$CONFIG"; then
echo "Configuration valid"
systemctl reload exabgp
echo "ExaBGP reloaded"
else
echo "Configuration invalid - NOT reloading"
exit 1
fi#!/bin/bash
# /usr/local/bin/pre-deploy-check.sh
set -e
CONFIG="/etc/exabgp/staging/exabgp.conf"
echo "=== ExaBGP Configuration Pre-Deployment Check ==="
# 1. Syntax validation
echo -n "Checking syntax... "
if exabgp --test "$CONFIG" > /dev/null 2>&1; then
echo "✓ PASS"
else
echo "✗ FAIL"
exabgp --test "$CONFIG"
exit 1
fi
# 2. Check for required files
echo -n "Checking included files... "
MISSING=$(grep "^include" "$CONFIG" | awk '{print $2}' | sed 's/;$//' | while read f; do
[ ! -f "$f" ] && echo "$f"
done)
if [ -z "$MISSING" ]; then
echo "✓ PASS"
else
echo "✗ FAIL - Missing files:"
echo "$MISSING"
exit 1
fi
# 3. Check for duplicate neighbors
echo -n "Checking for duplicate neighbors... "
DUPLICATES=$(grep -h "^neighbor" "$CONFIG" /etc/exabgp/conf.d/*.conf 2>/dev/null | awk '{print $2}' | sort | uniq -d)
if [ -z "$DUPLICATES" ]; then
echo "✓ PASS"
else
echo "✗ FAIL - Duplicate neighbors:"
echo "$DUPLICATES"
exit 1
fi
echo "=== All checks passed ==="ExaBGP behavior can be controlled via environment variables.
# Enable all logging
export exabgp.log.all=true
# Set log level (CRITICAL, ERROR, WARNING, INFO, DEBUG)
export exabgp.log.level=INFO
# Log to file
export exabgp.log.destination=/var/log/exabgp/exabgp.log
# Enable specific log categories
export exabgp.log.network=true
export exabgp.log.routes=true
export exabgp.log.timers=false# Disable daemonization (run in foreground)
export exabgp.daemon.daemonize=false
# PID file location
export exabgp.daemon.pid=/var/run/exabgp/exabgp.pid
# User to run as
export exabgp.daemon.user=exabgp# Enable ACK feature (ExaBGP 5.x)
export exabgp.api.ack=true
# API encoder (text or json)
export exabgp.api.encoder=text# Disable BGP capabilities
export exabgp.bgp.openwait=60
# Maximum routes to accept
export exabgp.bgp.maximum_routes=10000#!/bin/bash
# /usr/local/bin/exabgp-with-env.sh
# Logging
export exabgp.log.all=true
export exabgp.log.level=INFO
export exabgp.log.destination=/var/log/exabgp/exabgp.log
# Daemon
export exabgp.daemon.daemonize=false
export exabgp.daemon.user=exabgp
# API
export exabgp.api.ack=true
export exabgp.api.encoder=text
# Start ExaBGP
exec exabgp /etc/exabgp/exabgp.confExaBGP doesn't have a traditional interactive shell, but you can send commands via stdin.
# ExaBGP listens for commands on stdin
echo "announce route 198.51.100.0/24 next-hop 192.0.2.10" | socat - UNIX-CONNECT:/var/run/exabgp/exabgp.sock# Create named pipe
mkfifo /var/run/exabgp/commands
# ExaBGP reads from pipe (in configuration)
# process commands {
# run /bin/cat /var/run/exabgp/commands;
# }
# Send commands
echo "announce route 198.51.100.0/24 next-hop self" > /var/run/exabgp/commands# Send SIGHUP to reload configuration
sudo systemctl reload exabgp
# Or manually
kill -HUP $(cat /var/run/exabgp/exabgp.pid)# Graceful shutdown via systemd
sudo systemctl stop exabgp
# Or manually
kill -TERM $(cat /var/run/exabgp/exabgp.pid)# Force kill (not recommended - may leave routes advertised)
sudo systemctl kill -s KILL exabgp
# Or manually
kill -9 $(cat /var/run/exabgp/exabgp.pid)# Check if ExaBGP is running
if pgrep -x exabgp > /dev/null; then
echo "ExaBGP is running"
else
echo "ExaBGP is not running"
fi
# Check via systemd
systemctl is-active exabgp
# Get process details
ps aux | grep exabgp# Debug all categories
env exabgp.log.level=DEBUG exabgp /etc/exabgp/exabgp.conf
# Debug specific categories
env exabgp.log.network=true \
exabgp.log.routes=true \
exabgp.log.level=DEBUG \
exabgp /etc/exabgp/exabgp.conf# Capture BGP packets with tcpdump
sudo tcpdump -i any -n port 179 -w /tmp/bgp-packets.pcap
# Decode with ExaBGP
exabgp --decode /tmp/bgp-packets.pcap# Run with verbose output
exabgp --debug /etc/exabgp/exabgp.conf 2>&1 | tee /tmp/exabgp-debug.log# Test configuration without affecting running instance
exabgp --test /etc/exabgp/exabgp.conf.new
# Compare configurations
diff /etc/exabgp/exabgp.conf /etc/exabgp/exabgp.conf.new# ALWAYS validate first
exabgp --test /etc/exabgp/exabgp.conf
# Only deploy if validation passes
if [ $? -eq 0 ]; then
systemctl reload exabgp
fi# /etc/systemd/system/exabgp.service
[Unit]
Description=ExaBGP
Documentation=https://github.com/Exa-Networks/exabgp/wiki
After=network.target
[Service]
Type=simple
User=exabgp
Group=exabgp
# Environment variables
Environment=exabgp.log.all=true
Environment=exabgp.log.destination=/var/log/exabgp/exabgp.log
Environment=exabgp.daemon.daemonize=false
ExecStart=/usr/local/bin/exabgp /etc/exabgp/exabgp.conf
ExecReload=/bin/kill -HUP $MAINPID
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target# Tail logs in real-time
tail -f /var/log/exabgp/exabgp.log
# Filter for errors
tail -f /var/log/exabgp/exabgp.log | grep -i error
# Monitor via journalctl
journalctl -u exabgp -f# Ansible example
- name: Deploy ExaBGP configuration
template:
src: exabgp.conf.j2
dest: /etc/exabgp/exabgp.conf
validate: 'exabgp --test %s'
notify: Reload ExaBGP#!/bin/bash
# /usr/local/bin/check-exabgp-health.sh
# Check if ExaBGP is running
if ! pgrep -x exabgp > /dev/null; then
echo "CRITICAL: ExaBGP is not running"
exit 2
fi
# Check if BGP sessions are up
SESSION_COUNT=$(grep "Peer.*up" /var/log/exabgp/exabgp.log | tail -10 | wc -l)
if [ "$SESSION_COUNT" -eq 0 ]; then
echo "WARNING: No BGP sessions established"
exit 1
fi
echo "OK: ExaBGP is running with $SESSION_COUNT session(s)"
exit 0# Systemd service with automatic restart
[Service]
Restart=always
RestartSec=10
StartLimitInterval=200
StartLimitBurst=5# Track configuration changes
cd /etc/exabgp
git init
git add exabgp.conf
git commit -m "Initial configuration"
# Before changes
git diff exabgp.conf
# After changes
git add exabgp.conf
git commit -m "Add new BGP neighbor"- Configuration Syntax - Complete configuration reference
- Debugging - Troubleshooting guide
- Security Best Practices - Security hardening
- Healthcheck Module - Built-in health checking
- Installation Guide - Installing ExaBGP
👻 Ghost written by Claude (Anthropic AI)
Getting Started
Configuration
- Configuration Syntax
- Neighbor Configuration
- Directives A-Z
- Templates
- Environment Variables
- Process Configuration
API
- API Overview
- Text API Reference
- JSON API Reference
- API Commands
- Writing API Programs
- Error Handling
- Production Best Practices
Address Families
- Overview
- IPv4 Unicast
- IPv6 Unicast
- FlowSpec
- EVPN
- L3VPN
- BGP-LS
- VPLS
- SRv6 / MUP
- Multicast
- RT Constraint
Features
Use Cases
Tools
Operations
Reference
- Architecture
- Design
- Attribute Reference
- Command Reference
- BGP State Machine
- Capabilities
- Communities
- Examples Index
- Glossary
- RFC Support
Integration
Migration
Community
External