einat implements full-cone style endpoint-independent NAT on Linux using eBPF on TC hooks. A Rust frontend handles interface changes, hairpin routing, and configuration.
Overview
einat is network address translation software for Linux that uses eBPF programs on traffic-control egress and ingress hooks. The eBPF layer provides endpoint-independent mapping and filtering for TCP, UDP, and ICMP, including IPv4 and IPv6 NAPT.
It can reserve part of the external port range for other services and includes a userspace frontend that reapplies settings when interface addresses change and sets up hairpin routes. The project documents CO-RE style deployment, static binaries via Nix flakes, OpenWrt packages, and systemd persistence examples.
Target kernels need BPF and BTF support from 5.15 onward; testing is described for x86-64 and aarch64. Operators attach the tool to an external interface, avoid conflicting nftables masquerade rules, and may need TCP MSS clamping on low-MTU tunnels.
Compared with kernel conntrack-based full-cone modules, einat builds its NAT engine directly on eBPF TC hooks to reduce interaction with address-dependent conntrack behavior.
Key features
- IPv4 and IPv6 NAPT in eBPF
- Endpoint-independent NAT for TCP UDP ICMP
- Configurable external port ranges
- Automatic reconfiguration on address changes
- Hairpin IP rule and route setup
- aya, libbpf, and libbpf-skel loaders
- Nix flake static binaries
- OpenWrt and LuCI packaging
Use cases
- Full-cone NAT on home routers
- OpenWrt gateway deployments
- PPPoE or tunnel interface NAT
- Self-hosted edge Linux gateways