Documentation
¶
Overview ¶
Package firewall provides a backend abstraction for port-mapping and NAT rules that auto-detects nftables vs iptables at runtime.
On Linux in 2026, modern distributions (Fedora 40+, Ubuntu 24.04+, RHEL 10, openSUSE Leap 16+) ship nftables only and no longer provide iptables-legacy. Older systems (Debian 11, Ubuntu 22.04) provide iptables-legacy. This shim probes both and picks the first one that is functional, with a hard preference for nftables when available.
iptables backend implementation for the firewall Manager.
This is the legacy path used by older distros (Debian 11, Ubuntu 22.04 with iptables-legacy) and by hosts where nft is not available.
nftables backend implementation for the firewall Manager.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNoBackend = errors.New("no firewall backend available (nft or iptables)")
ErrNoBackend is returned when neither nft nor iptables is available.
Functions ¶
This section is empty.
Types ¶
type Manager ¶
type Manager interface {
Backend() Backend
Apply(ctx context.Context, rule Rule) error
Remove(ctx context.Context, rule Rule) error
List(ctx context.Context) ([]Rule, error)
Reload(ctx context.Context) error
Close() error
}
Manager is the firewall backend abstraction. Implementations must be safe for concurrent use.
type Options ¶
type Options struct {
// Preferred forces a specific backend. Empty = auto-detect.
Preferred Backend
// TableName is the nftables table or iptables chain prefix.
// Default: "doki".
TableName string
// Family is "inet" (nftables) or "ipv4"/"ipv6" (iptables).
// Default: "inet" for nftables, "ipv4" for iptables.
Family string
// IPv6 enables the ipv6 backend as well. Default: true.
IPv6 bool
}
Options configures the firewall manager.