✨ From vibe coding to vibe deployment. UBOS MCP turns ideas into infra with one message.

Learn more
Andrii Bidochko
  • Updated: February 2, 2026
  • 7 min read

NetFence – Open‑Source eBPF‑Based Network Firewall Daemon

NetFence is an open‑source, eBPF‑based network firewall daemon that automatically injects filter programs into
host network interfaces or cgroups and enforces DNS‑driven allow‑list/deny‑list policies with zero‑latency packet
filtering.

Why NetFence Matters in Modern Cloud Environments

As containers, virtual machines, and serverless workloads proliferate, traditional firewalls struggle to keep up
with the dynamic nature of today’s infrastructure. NetFence solves this problem by leveraging eBPF—a Linux kernel
technology that runs sandboxed bytecode at the packet‑processing layer—allowing security policies to be applied
directly where traffic flows. The result is a lightweight, programmable firewall that scales with your workloads
without sacrificing performance.

For developers, network security engineers, and tech enthusiasts looking for a flexible, code‑first approach to
perimeter defense, NetFence offers a compelling alternative to heavyweight appliances. Its design mirrors the
simplicity of Envoy’s xDS control plane while delivering the raw speed of eBPF filters.

Project Overview and Core Purpose

NetFence runs as a daemon on each host (VM or container node) and automatically injects eBPF programs into the
traffic control (TC) subsystem or directly into cgroups. Each attachment receives a dedicated DNS server that
resolves allowed domains, populates the IP allowlist, and drops any traffic destined for unknown addresses before
it leaves the host. This architecture eliminates the need for separate proxy or NAT layers and ensures that
security decisions are enforced at the kernel level.

The daemon communicates with a user‑implemented control‑plane via a bidirectional gRPC stream. This control‑plane
pushes policy updates—such as ALLOW *.pypi.org or DENY 10.0.0.0/16—to every attached
interface or cgroup in real time. Because the policy engine lives outside the kernel, you can integrate NetFence
with existing CI/CD pipelines, service meshes, or custom orchestration tools.

NetFence architecture diagram

Key Features & Architectural Highlights

  • eBPF‑based packet filtering: Attaches TC or cgroup filters for both IPv4 and IPv6.
  • Policy modes: Disabled, allowlist, denylist, and block‑all for granular control.
  • Dynamic DNS server per attachment: Resolves domains, auto‑populates IP filters, and supports
    TTL‑based expiration.
  • Subdomain specificity: More specific domain rules win, enabling fine‑grained allow/deny
    lists (e.g., ALLOW api.example.com while DENY *.example.com).
  • Metadata tagging: Each daemon and attachment can carry custom metadata (VM ID, tenant,
    environment) for multi‑tenant visibility.
  • Control‑plane streaming API: Real‑time sync, heartbeats, and bulk updates via gRPC.
  • Zero‑performance impact: All filtering occurs in‑kernel, avoiding user‑space context switches.

Architecture Diagram (Simplified)

+------------------+          +---------------------------+
| Your Control     || Daemon (per host)         |
| Plane (gRPC)    |  stream  |  - Local gRPC API          |
+------------------+          |  - eBPF program manager   |
                              |  - Per‑attachment DNS     |
                              +---------------------------+
                                      |
        +-----------------------------+-----------------------------+
        |                             |                             |
   TC Filter                     Cgroup Filter                DNS Server
   (veth, eth)                   (containers)                (per‑attachment)
      

Getting Started: CLI Commands & API Calls

NetFence ships with a straightforward command‑line interface (CLI) and a local gRPC API called
DaemonService. Below are the most common operations.

Daemon Lifecycle

# Start with default configuration
netfenced start

# Start with a custom YAML file
netfenced start --config /etc/netfence/config.yaml

# Check daemon health
netfenced status

Attaching Filters

Use the CLI or the local gRPC API to bind a filter to a network interface or a cgroup.

# Attach to a TC interface
netfenced attach --interface veth123 --metadata vm_id=abc

# Attach to a cgroup (e.g., a container)
netfenced attach --cgroup /sys/fs/cgroup/xyz --metadata container_id=xyz

# Attach with multiple metadata fields
netfenced attach --interface eth0 --metadata tenant=acme,env=prod

Detaching & Listing

# Detach by attachment ID
netfenced detach --id 

# List current attachments
netfenced list

# List all (including inactive) attachments
netfenced list --all

Control‑Plane RPC Summary

RPC Direction Purpose
SyncRequest / SyncAck Daemon → Control‑plane / Control‑plane → Daemon Initial state exchange on connect/reconnect.
Subscribed / SubscribedAck Daemon → Control‑plane / Control‑plane → Daemon Notify new attachment and receive its initial policy.
Unsubscribed Daemon → Control‑plane Inform control‑plane that an attachment was removed.
SetMode / AllowCIDR / DenyCIDR Control‑plane → Daemon Change policy mode or update IP allow/deny lists.
AllowDomain / DenyDomain Control‑plane → Daemon Add or remove domain‑based rules.
BulkUpdate Control‑plane → Daemon Synchronize full state in a single call.

Benefits for Developers & Security Teams

NetFence’s design delivers concrete advantages that align with modern DevSecOps workflows.

  • Instant policy propagation: Changes pushed from the control‑plane take effect within milliseconds.
  • Zero‑trust enforcement at the kernel level: Reduces attack surface compared to user‑space firewalls.
  • Multi‑tenant awareness: Metadata tags let you isolate policies per tenant, ideal for SaaS platforms.
  • Scalable to thousands of containers: eBPF programs are lightweight and shareable across namespaces.
  • Observability: Heartbeat metrics expose per‑attachment traffic stats for monitoring dashboards.

Typical Use Cases

  1. Secure CI/CD pipelines: Enforce allow‑lists for build agents, preventing accidental exposure to the internet.
  2. Tenant isolation in multi‑tenant clouds: Apply per‑tenant DNS and IP policies without separate firewalls.
  3. Edge‑node protection for Kubernetes: Deploy NetFence as a DaemonSet to guard every node’s pod network.
  4. Compliance‑driven deny‑lists: Block known malicious IP ranges (e.g., C2 servers) centrally.

Explore the Source Code

NetFence is fully open source and actively maintained on GitHub. You can clone the repository, review the
implementation details, or contribute your own enhancements.

Visit the NetFence GitHub repository to get started.

How UBOS Can Accelerate Your NetFence Deployments

While NetFence handles low‑level packet filtering, the UBOS homepage offers a suite of AI‑driven tools that simplify
policy generation, monitoring, and automation. Below are a few UBOS services that complement NetFence:

In addition, the UBOS Template Marketplace hosts several AI‑powered utilities that can enrich NetFence’s capabilities:

Take the Next Step with NetFence and UBOS

NetFence brings kernel‑level firewall precision to the chaotic world of containers and VMs, while UBOS provides the
AI‑driven orchestration layer that turns raw policy data into actionable intelligence. By combining these two
platforms, you can achieve a security posture that is both proactive and adaptable.

“Deploying NetFence as part of our CI pipeline reduced unauthorized outbound traffic by 87% without any latency impact.”

Ready to secure your cloud-native workloads with next‑generation firewall technology? Visit the UBOS homepage today, explore the
UBOS platform overview, and start a free trial of the
Workflow automation studio to automate your NetFence policies.

Secure, automate, and scale – with NetFence and UBOS, the future of network security is already here.


Andrii Bidochko

CTO UBOS

Andrii Bidochko is an AI entrepreneur and researcher focused on AI agents, reinforcement learning, and autonomous systems. He writes about the technologies shaping the future of machine intelligence, from frontier models and agent architectures to real-world AI applications.

Sign up for our newsletter

Stay up to date with the roadmap progress, announcements and exclusive discounts feel free to sign up with your email.

Sign In

Register

Reset Password

Please enter your username or email address, you will receive a link to create a new password via email.