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
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
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
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
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
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
| Symptom | Cause | Fix |
|---|---|---|
| SNMP Exporter returns no metrics | SNMP community mismatch or firewall blocking port 161 | Check /etc/snmp/snmpd.conf community settings and firewall rules |
| BGP peer shows as down in metrics | BGP configuration error or network connectivity | Run sudo vtysh -c "show bgp summary" and check neighbor config |
| Prometheus cannot scrape targets | Service not running or incorrect target addresses | Verify services with systemctl status and check target IPs |
| Permission denied errors | Incorrect file ownership for prometheus user | sudo chown -R prometheus:prometheus /etc/prometheus /var/lib/prometheus |
| SNMP timeout errors | SNMP daemon not responding or community string wrong | Test with snmpwalk -v2c -c monitoring localhost 1.3.6.1.2.1.1.1 |
| Grafana cannot connect to Prometheus | Prometheus not running or firewall blocking port 9090 | Check Prometheus status and firewall rules for port 9090 |
Next steps
- Configure Prometheus alerting rules for cgroup metrics monitoring and container resource alerts
- Configure BIRD BGP routing daemon for advanced routing policies and network automation
- Set up network monitoring with Nagios Core 4.5 and SNMP for infrastructure alerting
- Integrate SNMP monitoring with InfluxDB and Telegraf for time-series analysis
- Implement SNMP trap monitoring and alerting system for proactive network management
Running this in production?
Automated install script
Run this to automate the entire setup
#!/usr/bin/env bash
set -euo pipefail
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'
# Configuration
PROMETHEUS_VERSION="2.47.0"
SNMP_EXPORTER_VERSION="0.24.1"
COMMUNITY_STRING="${1:-monitoring}"
NETWORK_RANGE="${2:-127.0.0.1}"
usage() {
echo "Usage: $0 [community_string] [network_range]"
echo "Example: $0 monitoring 192.168.1.0/24"
exit 1
}
log_info() {
echo -e "${GREEN}[INFO]${NC} $1"
}
log_warn() {
echo -e "${YELLOW}[WARN]${NC} $1"
}
log_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
cleanup() {
log_error "Installation failed. Cleaning up..."
systemctl stop prometheus snmp_exporter 2>/dev/null || true
userdel prometheus 2>/dev/null || true
rm -rf /etc/prometheus /var/lib/prometheus /etc/snmp_exporter /usr/local/bin/prometheus /usr/local/bin/promtool /usr/local/bin/snmp_exporter 2>/dev/null || true
}
trap cleanup ERR
# Check root privileges
if [[ $EUID -ne 0 ]]; then
log_error "This script must be run as root"
exit 1
fi
# Auto-detect distribution
if [ -f /etc/os-release ]; then
. /etc/os-release
case "$ID" in
ubuntu|debian)
PKG_MGR="apt"
PKG_INSTALL="apt install -y"
PKG_UPDATE="apt update && apt upgrade -y"
SNMP_PACKAGES="snmpd snmp snmp-mibs-downloader"
FRR_PACKAGES="frr frr-pythontools"
;;
almalinux|rocky|centos|rhel|ol|fedora)
PKG_MGR="dnf"
PKG_INSTALL="dnf install -y"
PKG_UPDATE="dnf update -y"
SNMP_PACKAGES="net-snmp net-snmp-utils"
FRR_PACKAGES="frr frr-pythontools"
;;
amzn)
PKG_MGR="yum"
PKG_INSTALL="yum install -y"
PKG_UPDATE="yum update -y"
SNMP_PACKAGES="net-snmp net-snmp-utils"
FRR_PACKAGES="frr frr-pythontools"
;;
*)
log_error "Unsupported distribution: $ID"
exit 1
;;
esac
else
log_error "Cannot detect distribution"
exit 1
fi
log_info "[1/8] Updating system packages"
$PKG_UPDATE
log_info "[2/8] Installing SNMP daemon and utilities"
$PKG_INSTALL $SNMP_PACKAGES
log_info "[3/8] Installing FRRouting for BGP support"
if [[ "$PKG_MGR" == "apt" ]]; then
curl -s https://deb.frrouting.org/frr/keys.asc | apt-key add -
echo "deb https://deb.frrouting.org/frr $(lsb_release -s -c) frr-stable" > /etc/apt/sources.list.d/frr.list
apt update
$PKG_INSTALL $FRR_PACKAGES
else
$PKG_INSTALL epel-release
$PKG_INSTALL $FRR_PACKAGES
fi
log_info "[4/8] Installing Prometheus"
cd /tmp
wget -q https://github.com/prometheus/prometheus/releases/download/v${PROMETHEUS_VERSION}/prometheus-${PROMETHEUS_VERSION}.linux-amd64.tar.gz
tar xfz prometheus-${PROMETHEUS_VERSION}.linux-amd64.tar.gz
cp prometheus-${PROMETHEUS_VERSION}.linux-amd64/prometheus /usr/local/bin/
cp prometheus-${PROMETHEUS_VERSION}.linux-amd64/promtool /usr/local/bin/
chmod 755 /usr/local/bin/prometheus /usr/local/bin/promtool
mkdir -p /etc/prometheus /var/lib/prometheus
useradd --no-create-home --shell /bin/false prometheus || true
chown prometheus:prometheus /etc/prometheus /var/lib/prometheus
log_info "[5/8] Installing SNMP Exporter"
cd /tmp
wget -q https://github.com/prometheus/snmp_exporter/releases/download/v${SNMP_EXPORTER_VERSION}/snmp_exporter-${SNMP_EXPORTER_VERSION}.linux-amd64.tar.gz
tar xfz snmp_exporter-${SNMP_EXPORTER_VERSION}.linux-amd64.tar.gz
cp snmp_exporter-${SNMP_EXPORTER_VERSION}.linux-amd64/snmp_exporter /usr/local/bin/
chmod 755 /usr/local/bin/snmp_exporter
mkdir -p /etc/snmp_exporter
chown prometheus:prometheus /etc/snmp_exporter
log_info "[6/8] Configuring SNMP daemon"
if [[ "$PKG_MGR" == "apt" ]]; then
SNMPD_CONF="/etc/snmp/snmpd.conf"
else
SNMPD_CONF="/etc/snmp/snmpd.conf"
fi
cat > $SNMPD_CONF << EOF
sysLocation Server Room
sysContact admin@example.com
sysServices 72
rocommunity ${COMMUNITY_STRING} ${NETWORK_RANGE}
com2sec readonly default ${COMMUNITY_STRING}
group MyROGroup v1 readonly
group MyROGroup v2c readonly
view all included .1.3.6.1
access MyROGroup "" any noauth exact all none none
proc snmpd
disk / 10%
load 12 14 14
EOF
chmod 644 $SNMPD_CONF
log_info "[7/8] Configuring FRRouting"
cat > /etc/frr/daemons << EOF
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"
EOF
chmod 644 /etc/frr/daemons
chown frr:frr /etc/frr/daemons
cat > /etc/prometheus/prometheus.yml << EOF
global:
scrape_interval: 15s
scrape_configs:
- job_name: 'snmp'
static_configs:
- targets:
- 127.0.0.1
metrics_path: /snmp
params:
module: [if_mib]
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: 127.0.0.1:9116
EOF
chown prometheus:prometheus /etc/prometheus/prometheus.yml
chmod 644 /etc/prometheus/prometheus.yml
cat > /etc/systemd/system/prometheus.service << EOF
[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
[Install]
WantedBy=multi-user.target
EOF
cat > /etc/systemd/system/snmp_exporter.service << EOF
[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
[Install]
WantedBy=multi-user.target
EOF
chmod 644 /etc/systemd/system/prometheus.service /etc/systemd/system/snmp_exporter.service
log_info "[8/8] Starting and enabling services"
systemctl daemon-reload
systemctl enable snmpd frr prometheus snmp_exporter
systemctl start snmpd frr prometheus snmp_exporter
# Verification
log_info "Verifying installation..."
sleep 5
if systemctl is-active --quiet snmpd; then
log_info "✓ SNMP daemon is running"
else
log_error "✗ SNMP daemon failed to start"
fi
if systemctl is-active --quiet frr; then
log_info "✓ FRRouting is running"
else
log_error "✗ FRRouting failed to start"
fi
if systemctl is-active --quiet prometheus; then
log_info "✓ Prometheus is running on port 9090"
else
log_error "✗ Prometheus failed to start"
fi
if systemctl is-active --quiet snmp_exporter; then
log_info "✓ SNMP Exporter is running on port 9116"
else
log_error "✗ SNMP Exporter failed to start"
fi
log_info "Installation completed successfully!"
log_info "Access Prometheus at: http://localhost:9090"
log_info "SNMP community string: ${COMMUNITY_STRING}"
log_info "Monitoring network range: ${NETWORK_RANGE}"
Review the script before running. Execute with: bash install.sh