-
Notifications
You must be signed in to change notification settings - Fork 64
nftables Setup
Network isolation (restricted/allowlist modes) requires nftables. If you see the error "nft is not available or passwordless sudo is not configured", you have two options.
This page covers the egress-isolation firewall (the FORWARD-chain rules that enforce network modes). The separate ruleset used by the security monitor is documented in nftables Monitoring Internals.
# ~/.coi/config.toml
[network]
mode = "open"This disables egress filtering but allows you to work immediately. If you also want Coi to never invoke sudo for network operations, add use_sudo = false (see Running without sudo).
nftables provides the FORWARD chain filtering needed for network isolation. Re-running install.sh sets this up automatically, or do it manually:
# 1. Install nftables (Ubuntu/Debian)
sudo apt install nftables
# 2. Allow Coi to manage firewall rules (passwordless sudo for nft)
echo "$USER ALL=(ALL) NOPASSWD: /usr/sbin/nft" | sudo tee /etc/sudoers.d/coi-nft
sudo chmod 0440 /etc/sudoers.d/coi-nft(If nft lives elsewhere on your distro, use the path from command -v nft in the sudoers rule — that is what install.sh does.)
- nftables plus passwordless sudo for
nftmust be available for network isolation to work - Coi adds nftables rules to the FORWARD chain to filter container traffic
- Rules are scoped by container IP address for precise filtering
- Rules are removed when containers are stopped/deleted
- Coi gets the container's IP address from Incus
- nftables rules are applied per container IP, with allow rules ordered before reject rules
- Restricted mode: Allow gateway, block RFC1918, allow all else
- Allowlist mode: Allow gateway, allow specific IPs, block RFC1918, block all else
- If
nftis unavailable and the host's FORWARD policy is DROP, Coi falls back to iptables bridge rules so container traffic can still be forwarded
Coi automatically manages firewall resources to prevent accumulation of stale configurations:
-
Cleanup on all termination paths: Firewall rules are cleaned up during normal exit,
coi shutdown,coi kill, and when the security responder auto-kills a container -
Orphaned resource detection:
coi clean --orphansscans for and removes:- Orphaned veth interfaces (no master bridge)
- Orphaned nft rules (for non-existent container IPs)
- Orphaned IPv6 block rules (for containers no longer running)
- Orphaned nftables monitoring rules and chains (when nftables monitoring is enabled)
- Orphaned iptables bridge rules (coi-bridge-forward rules with no Coi containers running)
This prevents nftables from accumulating stale rules over time, which could otherwise cause configuration bloat and potential conflicts.
Manual cleanup:
# Clean up all orphaned resources (veths and stale nft/iptables rules)
coi clean --orphans
# Dry run to see what would be cleaned
coi clean --orphans --dry-run- Network Isolation - the network modes these rules enforce
- nftables Monitoring Internals - the separate monitoring ruleset and chains
-
System Health Check - verifies
nftand the sudoers rule are configured - Troubleshooting - firewall rule accumulation and related issues
Home · Getting Started · Configuration · Migration Guide · GitHub · Issues
Getting Started
Setup
Configuration & Usage
- Best Practices
- Configuration
- Profiles
- Supported Tools
- Container Lifecycle & Sessions
- Container Operations
- Snapshot Management
- File Transfer
- Port Publishing
- Tmux Automation
- Headless Orchestration
- Image Management
- Resource & Time Limits
- Resource Usage (coi top)
Security
- Threat Model: Containment Limits
- Security Monitoring
- Audit Log
- Session Logs
- Security Best Practices
- Network Isolation
Maintenance
Help & Reference