A high-performance, line-rate Linux kernel firewall and per-IP rate limiter built in Rust using the Aya eBPF framework.
Production Purpose: Defend Linux servers, container clusters, and cloud workloads against volumetric DDoS and Layer-3/Layer-4 network floods directly at the Network Interface Card (NIC) driver level, before packets touch the OS network stack.
cargo install xdp-guard
# or via install script
curl -sSf https://raw.githubusercontent.com/rahadbhuiya/xdp-guard/main/install.sh | sudo sh- Driver-Level Packet Filtering (
XDP_DROP): Discards unwanted or malicious packets with near-zero CPU overhead at line rate. - Layer-4 Stateful TCP SYN Flood Mitigation: Dedicated LRU token bucket tracking TCP SYN handshake rates per IP to neutralize SYN-flood connection table exhaustion before reaching OS socket backlogs.
- UDP Amplification & Reflection Defense: In-kernel detection and throttling of oversized reflection traffic from well-known vector ports (DNS 53, NTP 123, SSDP 1900, Memcached 11211, CLDAP 389).
- Two-Tier Rate Limiting: Layered rate limiting combining a
/24subnet aggregate token bucket with per-IP LRU token buckets to suppress host-rotating floods. - Ingress Admission Control: Shared admission token bucket for unseen sources preventing randomized-IP floods from bypassing limits or churning state tables.
- Cloud-Native Prometheus Exporter: Native async HTTP metrics daemon (
xdp-guard exporter) exposing standard Prometheus metrics on:9184/metricsand health endpoints. - Kubernetes DaemonSet Architecture: Turnkey Helm-compatible DaemonSet manifest and ServiceMonitor for cluster-wide worker node protection across multi-cloud and bare-metal environments.
- Enterprise Grafana Dashboards: Out-of-the-box Grafana JSON dashboard delivering real-time visualization of passed vs dropped PPS, bandwidth savings, and multi-vector threat categorization.
- IEEE 802.1Q (VLAN & QinQ) Parsing: Inspects encapsulated packets to eliminate L2 evasion vectors.
- Drift-Free Fractional Refills: Preserves sub-millisecond residual nanoseconds across arrivals for precise token refills at line rate.
- Dynamic BPF Maps: Update firewall rules (blocklist and allowlist) on the fly from the userspace CLI without stopping or recompiling the kernel program.
- Pure Rust: Powered by Aya eliminating C compiler toolchain dependencies for application builds.
+-----------------------------------------+
| Incoming Network Packet |
+-----------------------------------------+
|
v
[NIC RX Queue] ------------> +---------------------------+
| eBPF / XDP Hook | <--- (Runs in Kernel Driver)
+---------------------------+
/ | \
(In Blocklist) (In Allowlist) (Rate-Limited?)
/ | \
v | v
[ XDP_DROP ] | [ XDP_DROP ]
(Zero CPU Overhead) | (Over-limit Flood)
v
[ XDP_PASS ]
|
v
+---------------------------+
| Linux Kernel TCP/IP Stack |
| (Sockets, Nginx, App) |
+---------------------------+
xdp-guard-common/: Shared memory structs (#[repr(C)]) between kernel and userspace (PacketStats,RuleValue,RateLimitState).xdp-guard-ebpf/: The core eBPF program executed inside the Linux kernel on packet arrival.xdp-guard/: The userspace management CLI and metrics telemetry engine.xtask/: Cross-compilation orchestrator for packaging eBPF bytecode.
Install required Linux dependencies:
sudo apt update && sudo apt install -y pkg-config libelf-dev clang llvm linux-headers-$(uname -r)
rustup target add bpfel-unknown-none# Build the eBPF kernel bytecode
cargo xtask build-ebpf
# Build userspace CLI
cargo build --release -p xdp-guard# 1. Attach protection to an interface
sudo ./target/release/xdp-guard attach --iface eth0 --mode skb
# 2. Block an IP in real-time
sudo ./target/release/xdp-guard block 192.168.1.50
# 3. Allowlist trusted traffic
sudo ./target/release/xdp-guard allow 10.0.0.1
# 4. View live terminal telemetry
sudo ./target/release/xdp-guard stats
# 5. Run Prometheus metrics exporter daemon
sudo ./target/release/xdp-guard exporter --listen 0.0.0.0:9184
# 6. Deploy cluster-wide on Kubernetes
kubectl apply -f k8s/daemonset.yaml
kubectl apply -f k8s/service-monitor.yamlBelow is live telemetry captured directly from the kernel STATS_MAP during integration testing on Linux veth pairs, demonstrating instantaneous line-rate XDP_DROP when an attacker IP is inserted into BLOCKLIST_MAP:
TIMESTAMP PASSED (PKTS) DROPPED (PKTS) DROP RATIO
-----------------------------------------------------------------
09:56:56 | Pass: 1 (30.2 KB) | Drop: 0 (0 B) | Ratio: 0.00%
[!] Inserting IP 10.10.0.2 into BLOCKLIST_MAP... [SUCCESS]
09:56:57 | Pass: 0 (30.2 KB) | Drop: 1 (98 B) | Ratio: 100.00%
09:56:58 | Pass: 0 (30.2 KB) | Drop: 1 (196 B) | Ratio: 100.00%
...
09:57:55 | Pass: 0 (30.2 KB) | Drop: 1 (5.7 KB)| Ratio: 100.00%
Removing IP 10.10.0.2 from BLOCKLIST_MAP... [SUCCESS]
09:57:56 | Pass: 1 (30.3 KB) | Drop: 0 (5.7 KB)| Ratio: 0.00%
All drops occur directly inside the XDP driver hook with zero CPU cycles spent passing packets to the kernel network stack or socket layer.
- Rahad Bhuiya (@rahadbhuiya)
- Core contributor to
aya-rs/aya(Linux Kernel eBPF Framework) - Author of Exploidus OS and Yolish Language
- Core contributor to
If you use xdp-guard or reference its in-kernel architecture in your research, please cite:
@software{bhuiya_xdp_guard_2026,
author = {Rahad Bhuiya},
title = {xdp-guard: Memory-Safe In-Kernel XDP Firewall \& Per-IP Rate Limiter in Pure Rust},
month = oct,
year = 2026,
publisher = {Zenodo},
version = {v0.1.0},
doi = {10.5281/zenodo.23120995},
url = {https://doi.org/10.5281/zenodo.23120995}
}xdp-guard is dual-licensed under open-source and commercial terms:
For open-source projects, academic benchmarking, and non-commercial edge protection, this software is licensed under the GNU Affero General Public License v3.0 or later (AGPL-3.0-or-later).
Under this license, any cloud hosting provider, datacenter operator, SaaS platform, or security vendor incorporating or linking xdp-guard into network-facing workloads must make their complete source code available under compatible copyleft terms when distributed or deployed over a network. See LICENSE for the full text.
For cloud infrastructure vendors, managed security service providers (MSSPs), hosting companies, and proprietary networking appliance manufacturers who wish to embed xdp-guard within proprietary closed-source infrastructure or commercial security suites without AGPLv3 copyleft obligations:
- Commercial licenses are available without copyleft requirements.
- Includes custom eBPF map tuning, hardware offload acceleration, dedicated BPF kernel integration, and SLA support.
- For commercial licensing terms, custom deployments, and volume licensing, contact:
rahadbhuiya2021@gmail.com.