Implement network monitoring with SNMP and BGP metrics using FRRouting and Prometheus

Advanced 45 min Apr 28, 2026 94 views
Ubuntu 24.04 Debian 12 AlmaLinux 9 Rocky Linux 9

Set up comprehensive network monitoring with SNMP daemon, FRRouting BGP metrics, and Prometheus collection for real-time infrastructure visibility and alerting.

Prerequisites

  • Root or sudo access
  • Network devices supporting SNMP v2c
  • Basic understanding of BGP routing
  • Firewall access to monitoring ports

What this solves

Network monitoring with SNMP and BGP metrics gives you real-time visibility into your infrastructure performance, routing health, and network device status. This tutorial combines FRRouting for BGP protocol management, SNMP daemon for device monitoring, and Prometheus for metrics collection into a production-grade monitoring stack.

Step-by-step installation

Update system packages

Start by updating your package manager to ensure you have the latest security patches and package versions.

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

Install SNMP daemon and utilities

Install the SNMP daemon for device monitoring and utilities for testing and configuration management.

sudo apt install -y snmpd snmp snmp-mibs-downloader
sudo dnf install -y net-snmp net-snmp-utils

Install FRRouting for BGP support

FRRouting provides BGP protocol support and integrates with SNMP for metrics exposure. Add the official repository for the latest version.

curl -s https://deb.frrouting.org/frr/keys.asc | sudo apt-key add -
echo 'deb https://deb.frrouting.org/frr $(lsb_release -s -c) frr-stable' | sudo tee -a /etc/apt/sources.list.d/frr.list
sudo apt update
sudo apt install -y frr frr-pythontools
sudo dnf install -y epel-release
sudo dnf install -y frr frr-pythontools

Install Prometheus for metrics collection

Download and install Prometheus to collect and store SNMP and BGP metrics from your network infrastructure.

cd /tmp
wget https://github.com/prometheus/prometheus/releases/download/v2.47.0/prometheus-2.47.0.linux-amd64.tar.gz
tar xfz prometheus-2.47.0.linux-amd64.tar.gz
sudo cp prometheus-2.47.0.linux-amd64/prometheus /usr/local/bin/
sudo cp prometheus-2.47.0.linux-amd64/promtool /usr/local/bin/
sudo mkdir -p /etc/prometheus /var/lib/prometheus
sudo useradd --no-create-home --shell /bin/false prometheus
sudo chown prometheus:prometheus /etc/prometheus /var/lib/prometheus

Install SNMP Exporter for Prometheus

The SNMP Exporter translates SNMP data into Prometheus metrics format for collection and storage.

cd /tmp
wget https://github.com/prometheus/snmp_exporter/releases/download/v0.24.1/snmp_exporter-0.24.1.linux-amd64.tar.gz
tar xfz snmp_exporter-0.24.1.linux-amd64.tar.gz
sudo cp snmp_exporter-0.24.1.linux-amd64/snmp_exporter /usr/local/bin/
sudo mkdir -p /etc/snmp_exporter
sudo chown prometheus:prometheus /etc/snmp_exporter

Configure SNMP daemon security

Set up SNMP with read-only community access and security restrictions. Replace the default configuration with secure settings.

# System information
sysLocation Server Room A1
sysContact admin@example.com
sysServices 72

Read-only community with source restrictions

rocommunity monitoring 127.0.0.1 rocommunity monitoring 203.0.113.0/24

Disable default public community

rocommunity public localhost

Security settings

com2sec readonly default monitoring com2sec6 readonly default monitoring

Group definitions

group MyROGroup v1 readonly group MyROGroup v2c readonly group MyROGroup usm readonly

View definitions

view all included .1.3.6.1 view system included .1.3.6.1.2.1.1 view interfaces included .1.3.6.1.2.1.2

Access control

access MyROGroup "" any noauth exact all none none

Process monitoring

proc snmpd proc sshd

Disk monitoring

disk / 10% disk /var 15%

Load monitoring

load 12 14 14

Network interface monitoring

ignoreInterfaces lo

Configure FRRouting BGP daemon

Enable BGP daemon in FRRouting and configure basic BGP settings with SNMP integration support.

zebra=yes
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
bfdd=no
fabricd=no
vrrpd=no
vtysh_enable=yes
zebra_options="-A 127.0.0.1 -s 90000000"
bgpd_options="-A 127.0.0.1"
vtysh_options="-A 127.0.0.1"

Configure BGP routing settings

Set up basic BGP configuration with ASN, router ID, and neighbor definitions. Adjust these values for your network topology.

frr version 8.4
frr defaults traditional
hostname frr-monitor
service integrated-vtysh-config
!
router bgp 65001
 bgp router-id 203.0.113.10
 bgp log-neighbor-changes
 neighbor 203.0.113.1 remote-as 65000
 neighbor 203.0.113.1 description "Upstream Provider"
 neighbor 203.0.113.1 soft-reconfiguration inbound
 !
 address-family ipv4 unicast
  network 203.0.113.0/24
  neighbor 203.0.113.1 activate
 exit-address-family
!
ip forwarding
!
snmp-server agentx
snmp-server oid-prefix .1.3.6.1.4.1.3317.1.2.2
snmp-server location "Network Operations Center"
snmp-server contact "netops@example.com"
!
line vty

Configure SNMP Exporter

Create configuration for SNMP Exporter to collect metrics from network devices and BGP status information.

auths:
  public_v2:
    community: monitoring
    security_level: noAuthNoPriv
    auth_protocol: MD5
    priv_protocol: DES
    version: 2

modules:
  if_mib:
    walk:
      - 1.3.6.1.2.1.2.2.1.2  # ifDescr
      - 1.3.6.1.2.1.2.2.1.3  # ifType
      - 1.3.6.1.2.1.2.2.1.5  # ifSpeed
      - 1.3.6.1.2.1.2.2.1.8  # ifOperStatus
      - 1.3.6.1.2.1.2.2.1.10 # ifInOctets
      - 1.3.6.1.2.1.2.2.1.16 # ifOutOctets
    metrics:
      - name: ifInOctets
        oid: 1.3.6.1.2.1.2.2.1.10
        type: counter
      - name: ifOutOctets
        oid: 1.3.6.1.2.1.2.2.1.16
        type: counter
      - name: ifOperStatus
        oid: 1.3.6.1.2.1.2.2.1.8
        type: gauge

  bgp4_mib:
    walk:
      - 1.3.6.1.2.1.15.3.1.2  # bgpPeerState
      - 1.3.6.1.2.1.15.3.1.9  # bgpPeerFsmEstablishedTime
      - 1.3.6.1.2.1.15.3.1.10 # bgpPeerInUpdates
      - 1.3.6.1.2.1.15.3.1.11 # bgpPeerOutUpdates
    metrics:
      - name: bgpPeerState
        oid: 1.3.6.1.2.1.15.3.1.2
        type: gauge
      - name: bgpPeerFsmEstablishedTime
        oid: 1.3.6.1.2.1.15.3.1.9
        type: gauge
      - name: bgpPeerInUpdates
        oid: 1.3.6.1.2.1.15.3.1.10
        type: counter

Configure Prometheus scraping

Set up Prometheus to scrape SNMP metrics from your devices and BGP metrics from FRRouting via SNMP Exporter.

global:
  scrape_interval: 30s
  evaluation_interval: 30s

rule_files:
  - "/etc/prometheus/rules/*.yml"

scrape_configs:
  - job_name: 'prometheus'
    static_configs:
      - targets: ['localhost:9090']

  - job_name: 'snmp-devices'
    static_configs:
      - targets:
        - 203.0.113.10  # FRRouting host
        - 203.0.113.1   # Network device
    metrics_path: /snmp
    params:
      module: [if_mib]
      auth: [public_v2]
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - target_label: __address__
        replacement: localhost:9116

  - job_name: 'bgp-metrics'
    static_configs:
      - targets:
        - 203.0.113.10
    metrics_path: /snmp
    params:
      module: [bgp4_mib]
      auth: [public_v2]
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - target_label: __address__
        replacement: localhost:9116

  - job_name: 'node-exporter'
    static_configs:
      - targets: ['localhost:9100']

Create systemd service files

Create systemd service definitions for Prometheus and SNMP Exporter to ensure they start automatically on boot.

[Unit]
Description=Prometheus
Wants=network-online.target
After=network-online.target

[Service]
User=prometheus
Group=prometheus
Type=simple
ExecStart=/usr/local/bin/prometheus \
    --config.file=/etc/prometheus/prometheus.yml \
    --storage.tsdb.path=/var/lib/prometheus/ \
    --web.console.templates=/etc/prometheus/consoles \
    --web.console.libraries=/etc/prometheus/console_libraries \
    --web.listen-address=0.0.0.0:9090 \
    --web.enable-lifecycle \
    --storage.tsdb.retention.time=90d

[Install]
WantedBy=multi-user.target

Create SNMP Exporter service

Set up the SNMP Exporter systemd service to run as the prometheus user with proper security isolation.

[Unit]
Description=SNMP Exporter
Wants=network-online.target
After=network-online.target

[Service]
User=prometheus
Group=prometheus
Type=simple
ExecStart=/usr/local/bin/snmp_exporter \
    --config.file=/etc/snmp_exporter/snmp.yml \
    --web.listen-address=:9116
Restart=always
RestartSec=5

[Install]
WantedBy=multi-user.target

Configure firewall access

Open required ports for SNMP, Prometheus, and monitoring services. Adjust source IP ranges for your network.

sudo ufw allow from 203.0.113.0/24 to any port 161 comment 'SNMP'
sudo ufw allow from 203.0.113.0/24 to any port 9090 comment 'Prometheus'
sudo ufw allow from 203.0.113.0/24 to any port 9116 comment 'SNMP Exporter'
sudo ufw allow 179/tcp comment 'BGP'
sudo ufw reload
sudo firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="203.0.113.0/24" port protocol="udp" port="161" accept'
sudo firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="203.0.113.0/24" port protocol="tcp" port="9090" accept'
sudo firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="203.0.113.0/24" port protocol="tcp" port="9116" accept'
sudo firewall-cmd --permanent --add-port=179/tcp
sudo firewall-cmd --reload

Start and enable services

Enable and start all monitoring services in the correct order to establish dependencies properly.

sudo systemctl daemon-reload
sudo systemctl enable --now snmpd
sudo systemctl enable --now frr
sudo systemctl enable --now snmp-exporter
sudo systemctl enable --now prometheus

Create monitoring rules

Set up Prometheus alerting rules for BGP peer states and network interface monitoring.

groups:
  - name: bgp.rules
    rules:
      - alert: BGPPeerDown
        expr: bgpPeerState != 6
        for: 2m
        labels:
          severity: critical
        annotations:
          summary: "BGP peer {{ $labels.instance }} is down"
          description: "BGP peer {{ $labels.instance }} state is {{ $value }}, expected 6 (Established)"

  - name: interface.rules
    rules:
      - alert: InterfaceDown
        expr: ifOperStatus == 2
        for: 1m
        labels:
          severity: warning
        annotations:
          summary: "Network interface {{ $labels.ifDescr }} is down"
          description: "Interface {{ $labels.ifDescr }} on {{ $labels.instance }} has been down for more than 1 minute"

      - alert: HighNetworkTraffic
        expr: rate(ifInOctets[5m]) * 8 > 800000000
        for: 5m
        labels:
          severity: warning
        annotations:
          summary: "High network traffic on {{ $labels.ifDescr }}"
          description: "Interface {{ $labels.ifDescr }} on {{ $labels.instance }} has sustained >800Mbps for 5 minutes"

Verify your setup

Test your monitoring stack to ensure all components are working correctly and collecting metrics as expected.

# Check service status
sudo systemctl status snmpd frr prometheus snmp-exporter

Test SNMP access

snmpwalk -v2c -c monitoring localhost 1.3.6.1.2.1.1.1

Test SNMP Exporter

curl -s http://localhost:9116/snmp?target=localhost&module=if_mib&auth=public_v2

Check Prometheus targets

curl -s http://localhost:9090/api/v1/targets | jq '.data.activeTargets[] | {job: .labels.job, health: .health}'

Verify BGP status

sudo vtysh -c "show bgp summary"

Check FRRouting SNMP integration

snmpwalk -v2c -c monitoring localhost 1.3.6.1.2.1.15

Configure Grafana dashboards

Install Grafana

Add Grafana repository and install for visualization of your network metrics and BGP status.

wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -
echo "deb https://packages.grafana.com/oss/deb stable main" | sudo tee /etc/apt/sources.list.d/grafana.list
sudo apt update
sudo apt install -y grafana
sudo tee /etc/yum.repos.d/grafana.repo << 'EOF'
[grafana]
name=grafana
baseurl=https://packages.grafana.com/oss/rpm
repo_gpgcheck=1
enabled=1
gpgcheck=1
gpgkey=https://packages.grafana.com/gpg.key
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
EOF
sudo dnf install -y grafana

Configure Grafana data source

Add Prometheus as a data source in Grafana for network monitoring dashboards.

sudo systemctl enable --now grafana-server

Wait for Grafana to start

sleep 10

Add Prometheus data source

curl -X POST \ http://admin:admin@localhost:3000/api/datasources \ -H 'Content-Type: application/json' \ -d '{ "name": "Prometheus", "type": "prometheus", "url": "http://localhost:9090", "access": "proxy", "isDefault": true }'

Import network monitoring dashboard

Create a custom dashboard for network interface and BGP monitoring with key performance indicators.

{
  "dashboard": {
    "title": "Network Monitoring",
    "tags": ["network", "snmp", "bgp"],
    "timezone": "browser",
    "panels": [
      {
        "title": "BGP Peer Status",
        "type": "stat",
        "targets": [
          {
            "expr": "bgpPeerState",
            "legendFormat": "{{instance}}"
          }
        ],
        "fieldConfig": {
          "defaults": {
            "mappings": [
              {"options": {"1": {"text": "Idle"}}, "type": "value"},
              {"options": {"2": {"text": "Connect"}}, "type": "value"},
              {"options": {"6": {"text": "Established"}}, "type": "value"}
            ]
          }
        },
        "gridPos": {"h": 8, "w": 12, "x": 0, "y": 0}
      },
      {
        "title": "Network Traffic",
        "type": "graph",
        "targets": [
          {
            "expr": "rate(ifInOctets[5m]) * 8",
            "legendFormat": "{{ifDescr}} In"
          },
          {
            "expr": "rate(ifOutOctets[5m]) * 8",
            "legendFormat": "{{ifDescr}} Out"
          }
        ],
        "yAxes": [
          {
            "unit": "bps"
          }
        ],
        "gridPos": {"h": 8, "w": 12, "x": 12, "y": 0}
      }
    ],
    "time": {
      "from": "now-1h",
      "to": "now"
    },
    "refresh": "30s"
  }
}

Import the dashboard

Load the network monitoring dashboard into Grafana for immediate visualization of your network metrics.

curl -X POST \
  http://admin:admin@localhost:3000/api/dashboards/db \
  -H 'Content-Type: application/json' \
  -d @/tmp/network-dashboard.json

Common issues

SymptomCauseFix
SNMP Exporter returns no metricsSNMP community mismatch or firewall blocking port 161Check /etc/snmp/snmpd.conf community settings and firewall rules
BGP peer shows as down in metricsBGP configuration error or network connectivityRun sudo vtysh -c "show bgp summary" and check neighbor config
Prometheus cannot scrape targetsService not running or incorrect target addressesVerify services with systemctl status and check target IPs
Permission denied errorsIncorrect file ownership for prometheus usersudo chown -R prometheus:prometheus /etc/prometheus /var/lib/prometheus
SNMP timeout errorsSNMP daemon not responding or community string wrongTest with snmpwalk -v2c -c monitoring localhost 1.3.6.1.2.1.1.1
Grafana cannot connect to PrometheusPrometheus not running or firewall blocking port 9090Check Prometheus status and firewall rules for port 9090

Next steps

Running this in production?

Want this handled for you? Running this at scale adds a second layer of work: capacity planning, failover drills, cost control, and on-call. Our managed platform covers monitoring, backups and 24/7 response by default.

Automated install script

Run this to automate the entire setup

Need help?

Don't want to manage this yourself?

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