π₯ XDP-based firewall written in pure Rust π¦. Filters packets at kernel level before they hit your network stack.
Block unwanted traffic at the XDP layer - the earliest point in Linux networking. Malicious packets get dropped at the NIC, not in userspace.
NIC β XDP (filter here) β Network Stack β Your App
Fast. Efficient. Zero CPU waste on attack traffic.
- IPv4/IPv6 filtering (allowlist/blocklist)
- Port-based rules (drop/pass/log)
- Per-IP rate limiting
- Real-time statistics
- Pure Rust (no C)
# Start filtering
sudo xdp-fire --iface eth0
# Block port
xdp-fire add-rule -p 8080 -a Drop
# Rate limit (1000 pps per IP)
xdp-fire set-rate-limit -e true -l 1000 -w 1000
# Allowlist mode
xdp-fire set-ip-mode -m allowlist
xdp-fire add-ipv4 -i 192.168.1.100
# Stats
xdp-fire show-statsStandard Aya workspace β three crates, one build.
xdp-fire/
βββ xdp-fire-common/ # Shared types (kernel β userspace)
β βββ src/lib.rs # Action, LogLevel, IpFilterMode, RateLimitState
β # #![no_std] β must compile for both BPF and host targets
β
βββ xdp-fire-ebpf/ # eBPF program (runs inside the Linux kernel)
β βββ src/main.rs # Packet parsing, map lookups, XDP_PASS/XDP_DROP verdicts
β # #![no_std], #![no_main] β compiled to BPF bytecode
β
βββ xdp-fire/ # Userspace binary (loads eBPF, CLI, map management)
β βββ build.rs # Invokes aya_build to compile the eBPF crate
β βββ src/main.rs # CLI (clap), map pinning, stats display, XDP attach
β βββ tests/ # Integration tests β load eBPF, poke maps from userspace
β
βββ scripts/
βββ benchmark.sh # iperf3-based throughput comparison (baseline vs XDP)
How they connect: cargo build triggers xdp-fire/build.rs, which compiles xdp-fire-ebpf into BPF bytecode and embeds it into the final binary. At runtime, the userspace binary loads that bytecode into the kernel and communicates with it through eBPF maps pinned at /sys/fs/bpf/xdp-fire/.
# Requirements
rustup toolchain install stable
rustup toolchain install nightly --component rust-src
cargo install bpf-linker
# Build
cargo build --release
# Run (requires root)
sudo ./target/release/xdp-fire --iface <interface>25 tests covering eBPF loading, maps, and filtering logic.
cargo test --releaseStateless filtering only. No connection tracking, no config persistence, no GeoIP. Add them if you need them.
Built with Aya - pure Rust eBPF framework.
Kernel and userspace code both in Rust. No C required.
Userspace: MIT or Apache-2.0 eBPF: GPL-2 or MIT