コンテンツにスキップ

Quagga Cheat Sheet

Overview

Quagga is an open-source routing software suite that implements major routing protocols including OSPF (Open Shortest Path First), BGP (Border Gateway Protocol), RIP (Routing Information Protocol), and IS-IS. Originally forked from GNU Zebra, Quagga turns a standard Linux or Unix machine into a capable multi-protocol router. It uses a modular architecture where each protocol runs as a separate daemon, all coordinated by the central zebra daemon which manages the kernel routing table and provides a unified interface.

Quagga’s configuration syntax closely mirrors Cisco IOS, making it accessible to network engineers familiar with enterprise routing equipment. Each protocol daemon exposes a VTY (Virtual TeleTYpe) shell accessible via telnet on distinct ports, allowing independent configuration and monitoring. Quagga is widely used in network labs, ISP edge deployments, route servers at Internet Exchange Points (IXPs), and academic research environments where commercial router hardware is cost-prohibitive.

Installation

Debian/Ubuntu

sudo apt update
sudo apt install quagga quagga-doc

# Enable IP forwarding
sudo sysctl -w net.ipv4.ip_forward=1
echo "net.ipv4.ip_forward=1" | sudo tee -a /etc/sysctl.conf

# Create config files from samples
sudo cp /usr/share/doc/quagga/examples/zebra.conf.sample /etc/quagga/zebra.conf
sudo cp /usr/share/doc/quagga/examples/ospfd.conf.sample /etc/quagga/ospfd.conf
sudo cp /usr/share/doc/quagga/examples/bgpd.conf.sample /etc/quagga/bgpd.conf

# Set ownership
sudo chown quagga:quagga /etc/quagga/*.conf
sudo chmod 640 /etc/quagga/*.conf

CentOS/RHEL

sudo yum install quagga
sudo sysctl -w net.ipv4.ip_forward=1

# Disable SELinux for quagga or set appropriate booleans
sudo setsebool -P zebra_write_config 1

From Source

git clone https://git.savannah.gnu.org/git/quagga.git
cd quagga
./bootstrap.sh
./configure --enable-vtysh --enable-user=quagga --enable-group=quagga
make
sudo make install

Daemon Architecture

DaemonProtocolDefault VTY PortConfig File
zebraKernel/RIB2601zebra.conf
ripdRIPv22602ripd.conf
ripngdRIPng2603ripngd.conf
ospfdOSPFv22604ospfd.conf
ospf6dOSPFv32606ospf6d.conf
bgpdBGP-42605bgpd.conf
isisdIS-IS2608isisd.conf

Enable Daemons

# Edit /etc/quagga/daemons
zebra=yes
bgpd=yes
ospfd=yes
ripd=no
ripngd=no
ospf6d=no
isisd=no

Start Services

sudo systemctl start zebra
sudo systemctl start ospfd
sudo systemctl start bgpd
sudo systemctl enable zebra ospfd bgpd

VTY Shell (vtysh)

# Enter unified shell
sudo vtysh

# Connect to specific daemon
telnet localhost 2601   # zebra
telnet localhost 2604   # ospfd
telnet localhost 2605   # bgpd

Common VTY Commands

CommandDescription
show ip routeDisplay routing table
show ip ospf neighborShow OSPF neighbor adjacencies
show ip bgp summaryBGP peer summary
show running-configShow current configuration
write memorySave config to file
configure terminalEnter config mode
show interfaceDisplay interface details
show ip ospf databaseShow OSPF link-state database
show ip bgpDisplay BGP routing table
debug ospf packet allEnable OSPF packet debugging

OSPF Configuration

sudo vtysh
configure terminal

router ospf
  ospf router-id 1.1.1.1
  network 10.0.0.0/24 area 0
  network 192.168.1.0/24 area 1
  passive-interface eth0
  area 1 stub
  redistribute connected
  redistribute static
  timers throttle spf 200 1000 5000
exit

interface eth1
  ip ospf cost 10
  ip ospf hello-interval 10
  ip ospf dead-interval 40
  ip ospf priority 100
  ip ospf authentication message-digest
  ip ospf message-digest-key 1 md5 MySecret
exit

write memory

OSPF Verification

show ip ospf neighbor
show ip ospf interface
show ip ospf database
show ip ospf border-routers
show ip ospf route

BGP Configuration

configure terminal

router bgp 65001
  bgp router-id 2.2.2.2
  neighbor 10.0.0.2 remote-as 65002
  neighbor 10.0.0.2 description upstream-provider
  neighbor 10.0.0.2 password SecretPass
  neighbor 10.0.0.2 update-source eth0
  neighbor 10.0.0.2 timers 30 90

  address-family ipv4 unicast
    network 192.168.0.0/16
    neighbor 10.0.0.2 soft-reconfiguration inbound
    neighbor 10.0.0.2 prefix-list INBOUND in
    neighbor 10.0.0.2 prefix-list OUTBOUND out
    neighbor 10.0.0.2 route-map IMPORT in
  exit-address-family
exit

ip prefix-list INBOUND seq 5 permit 0.0.0.0/0 le 24
ip prefix-list INBOUND seq 10 deny any
ip prefix-list OUTBOUND seq 5 permit 192.168.0.0/16
ip prefix-list OUTBOUND seq 10 deny any

route-map IMPORT permit 10
  match ip address prefix-list INBOUND
  set local-preference 200
exit

write memory

BGP Verification

show ip bgp summary
show ip bgp neighbors 10.0.0.2
show ip bgp neighbors 10.0.0.2 advertised-routes
show ip bgp neighbors 10.0.0.2 received-routes
show ip bgp regexp _65002_
clear ip bgp 10.0.0.2 soft in

RIP Configuration

configure terminal

router rip
  version 2
  network 10.0.0.0/8
  network 192.168.1.0/24
  no auto-summary
  redistribute ospf
  passive-interface eth0
  timers basic 30 180 120 240
  distance 120
exit

write memory

Route Filtering and Policy

Access Lists

access-list 10 permit 192.168.1.0 0.0.0.255
access-list 10 deny any

ip prefix-list MY_NETS seq 5 permit 10.0.0.0/8 le 24
ip prefix-list MY_NETS seq 10 permit 172.16.0.0/12 le 24
ip prefix-list MY_NETS seq 100 deny 0.0.0.0/0 le 32

Route Maps

route-map REDISTRIBUTE permit 10
  match ip address prefix-list MY_NETS
  set metric 100
  set tag 1000
exit

route-map REDISTRIBUTE deny 20
exit

Advanced Usage

Static Routes with Zebra

configure terminal
ip route 10.10.0.0/16 192.168.1.1
ip route 0.0.0.0/0 10.0.0.1 200
ipv6 route 2001:db8::/32 fe80::1 eth0

Route Redistribution

router ospf
  redistribute bgp metric 100 metric-type 1 route-map BGP_TO_OSPF
exit

router bgp 65001
  redistribute ospf route-map OSPF_TO_BGP
exit

BGP Communities

router bgp 65001
  neighbor 10.0.0.2 send-community both

route-map SET_COMMUNITY permit 10
  set community 65001:100 additive
exit

Logging

# In zebra.conf or vtysh
log file /var/log/quagga/zebra.log
log facility local7
log record-priority
log timestamp precision 3

Troubleshooting

IssueSolution
Daemons won’t startCheck /etc/quagga/daemons file enables them
OSPF neighbors stuck in INITVerify hello/dead timers match, check area config
BGP session not establishingCheck TCP/179 firewall rules, verify AS numbers
Routes not in kernel tableEnsure zebra daemon is running and healthy
Permission denied on config filesRun chown quagga:quagga /etc/quagga/*.conf
vtysh shows no configVerify service integrated-vtysh-config is set
OSPF DR/BDR election issuesCheck ip ospf priority on interfaces
BGP routes not advertisedConfirm network statement matches exactly

Debug Commands

debug ospf event
debug ospf packet all
debug bgp updates
debug bgp events
debug zebra rib
debug zebra kernel
terminal monitor

# Disable debugging
no debug all
undebug all

Log Locations

/var/log/quagga/zebra.log
/var/log/quagga/ospfd.log
/var/log/quagga/bgpd.log
/var/log/syslog          # fallback if file logging not configured