This guide covers the setup and installation of the eBPF Network Monitor server.
The eBPF Network Monitor is a modular system that uses eBPF programs to monitor network connections and packet drops in real-time. It features:
- Unified Event API: Single
/api/eventsendpoint for all monitoring data - Modular Architecture: Clean separation between core interfaces, event system, and programs
- Real-time Monitoring: Live event streaming from kernel space
- Interactive Documentation: Built-in Swagger UI for API exploration
- System Requirements
- Dependencies
- Installation
- Configuration
- Running the Server
- Verification
- Troubleshooting
- Linux kernel 4.18+ with eBPF support
- Supported distributions:
- Ubuntu 18.04+
- Debian 10+
- CentOS 8+
- RHEL 8+
- Fedora 30+
- x86_64 architecture (required for current eBPF programs)
- Minimum 2GB RAM (4GB+ recommended for production)
- Root/sudo privileges (required for eBPF program loading)
Verify your kernel supports the required eBPF features:
# Check kernel version
uname -r
# Verify eBPF support
zgrep CONFIG_BPF_SYSCALL /proc/config.gz
zgrep CONFIG_BPF_JIT /proc/config.gz
# Check if BTF is enabled (recommended)
zgrep CONFIG_DEBUG_INFO_BTF /proc/config.gzsudo apt update
sudo apt install -y \
golang-go \
clang \
llvm \
libbpf-dev \
linux-headers-$(uname -r) \
build-essential \
git \
make# CentOS 8/RHEL 8
sudo dnf install -y \
golang \
clang \
llvm \
libbpf-devel \
kernel-headers \
kernel-devel \
make \
git
# Fedora
sudo dnf install -y \
golang \
clang \
llvm \
libbpf-devel \
kernel-headers \
kernel-devel \
make \
git- Go 1.23+ is required
- Verify installation:
go version
# Ubuntu/Debian
sudo apt install -y \
bpftool \
linux-tools-common \
linux-tools-$(uname -r)
# CentOS/RHEL/Fedora
sudo dnf install -y bpftoolgit clone https://github.com/srodi/ebpf-server.git
cd ebpf-server# Compile eBPF bytecode
make build-bpf# Build production binary
make build
# Or build development binary with debug logging
make build-devls -la bin/
# Should show ebpf-server binaryThe server supports these command-line options:
# Start server on custom address/port
./bin/ebpf-server -addr=":9090"
# Default is :8080
./bin/ebpf-serverConfigure logging and debugging:
# Logging configuration (handled by logger package)
export EBPF_LOG_LEVEL=debug # debug, info, warn, error (default: info)
# For development debugging
export EBPF_DEBUG=1 # Enable debug modeThe current version uses command-line configuration. Future versions may support:
# config.yaml (not yet implemented)
server:
host: "0.0.0.0"
port: 8080
logging:
level: "info"
format: "json"# Run with debug logging
sudo ./bin/ebpf-server-dev
# Run on custom port
sudo ./bin/ebpf-server-dev -addr=":9090"# Run production server (default port 8080)
sudo ./bin/ebpf-server
# Run on custom address/port
sudo ./bin/ebpf-server -addr="0.0.0.0:8080"# Run as background service
sudo nohup ./bin/ebpf-server > /var/log/ebpf-server.log 2>&1 &# Build Docker image
docker build -t ebpf-server .
# Run with required privileges
docker run --privileged \
-p 8080:8080 \
-v /sys/kernel/debug:/sys/kernel/debug:ro \
-v /proc:/host/proc:ro \
ebpf-serverCreate /etc/systemd/system/ebpf-server.service:
[Unit]
Description=eBPF Network Monitor Server
After=network.target
[Service]
Type=simple
User=root
ExecStart=/usr/local/bin/ebpf-server -addr=":8080"
Restart=always
RestartSec=5
StandardOutput=journal
StandardError=journal
Environment=EBPF_LOG_LEVEL=info
[Install]
WantedBy=multi-user.target# Install and start service
sudo cp bin/ebpf-server /usr/local/bin/
sudo systemctl daemon-reload
sudo systemctl enable ebpf-server
sudo systemctl start ebpf-server# Check if server is running
curl http://localhost:8080/health
# Expected response:
# {"service":"ebpf-server","status":"healthy","version":"v1.0.0"}# List active programs
curl http://localhost:8080/api/programs
# Check eBPF programs in kernel
sudo bpftool prog list | grep ebpf-server# Test unified events API
curl "http://localhost:8080/api/events?limit=10"
# Test connection events specifically
curl "http://localhost:8080/api/events?type=connection&limit=5"
# Test packet drop events specifically
curl "http://localhost:8080/api/events?type=packet_drop&limit=5"
# Test events with time filter
curl "http://localhost:8080/api/events?since=2023-01-01T00:00:00Z&limit=10"
# Test events for specific process
curl "http://localhost:8080/api/events?pid=1234&limit=10"# Open Swagger documentation in browser
xdg-open http://localhost:8080/docs/
# View available endpoints
curl http://localhost:8080/
# Access Swagger JSON directly
curl http://localhost:8080/docs/swagger.jsonThe server provides these endpoints:
Core Unified APIs (Recommended):
GET /api/events- Query all events with filteringGET /api/programs- List eBPF program statusGET /health- Health check
Legacy Specific APIs:
POST /api/connection-summary- Connection statisticsPOST /api/packet-drop-summary- Packet drop statisticsGET /api/list-connections- List connection eventsGET /api/list-packet-drops- List packet drop events
Documentation:
GET /docs/- Interactive Swagger UIGET /- API overview and endpoint list
# Error: permission denied loading eBPF program
# Solution: Run with sudo/root privileges
sudo ./bin/ebpf-server# Error: cannot find kernel headers
# Solution: Install kernel headers for your kernel version
sudo apt install linux-headers-$(uname -r) # Ubuntu/Debian
sudo dnf install kernel-devel kernel-headers # CentOS/RHEL/Fedora# Check kernel logs for eBPF verifier errors
sudo dmesg | grep bpf
# Common solutions:
# 1. Update to newer kernel version
# 2. Check eBPF program complexity
# 3. Verify struct alignment# Error: address already in use
# Solution: Change port using command-line flag or kill existing process
sudo ./bin/ebpf-server -addr=":8081"
# Or
sudo lsof -i :8080
sudo kill <PID># Check if eBPF programs are loaded and attached
sudo bpftool prog list | grep -E "(connection|packet_drop)"
sudo bpftool link list
# Check program status via API
curl http://localhost:8080/api/programs
# Check specific tracepoints exist
sudo ls /sys/kernel/debug/tracing/events/syscalls/ | grep sys_enter_connect
sudo ls /sys/kernel/debug/tracing/events/skb/ | grep kfree_skb
# Generate some test traffic
ping google.com &
curl http://google.com
killall ping
# Check for events
curl "http://localhost:8080/api/events?limit=5"
# Enable more verbose logging
export EBPF_DEBUG=1
sudo -E ./bin/ebpf-server-dev# List loaded eBPF programs
sudo bpftool prog list
# Show program details
sudo bpftool prog show id <ID>
# List eBPF maps
sudo bpftool map list
# View map contents
sudo bpftool map dump id <MAP_ID># View kernel trace events
sudo cat /sys/kernel/debug/tracing/trace_pipe
# Enable specific tracepoints
echo 1 | sudo tee /sys/kernel/debug/tracing/events/net/net_dev_queue/enable# Monitor system resources
htop
iostat 1
netstat -tlnp | grep 8080
# Check system logs
journalctl -u ebpf-server -f# Monitor event processing performance
curl "http://localhost:8080/api/programs" | jq '.programs[] | {name, event_count}'
# Check for dropped events in system logs
journalctl -u ebpf-server | grep -i "dropped\|full\|overflow"# Pin server to specific CPUs for consistent performance
taskset -c 0,1 ./bin/ebpf-server
# Set memory limits for production
ulimit -m 1048576 # 1GB limit
# Increase ring buffer size if experiencing drops (future enhancement)
# Currently ring buffer size is compiled into eBPF programs# Use specific filters to reduce data transfer
curl "http://localhost:8080/api/events?type=connection&limit=100"
# Use time-based filtering for better performance
curl "http://localhost:8080/api/events?since=$(date -d '1 hour ago' -Iseconds)"export EBPF_LOG_LEVEL=debug
sudo ./bin/ebpf-server-dev 2>&1 | tee debug.log"eBPF program loaded successfully"- Program loaded correctly"Failed to attach eBPF program"- Attachment failed, check permissions"Ring buffer event received"- Events are being processed"Event channel full"- Consider increasing buffer sizes
- Check logs: Review server logs for error messages
- Verify system: Ensure all dependencies are installed
- Test incrementally: Start with basic functionality
- Check documentation: Review API documentation at
/docs - Community support: Report issues on GitHub
For additional support, please check: