28 lines
2.6 KiB
Markdown
28 lines
2.6 KiB
Markdown
# nftables script for system-service installs: summary (2026-10-05)
|
|||
|
|
|
||
|
|
Plan: [2026-10-05_NFT_Firewall_PLAN.md](2026-10-05_NFT_Firewall_PLAN.md). Guide: [Firewall, NAT and forwarding](../Deployment/Scenario2_System_Services.md#firewall-nat-and-forwarding).
|
||
|
|
|
||
|
|
## Done
|
||
|
|
|
||
|
|
| Item | Result |
|
||
|
|
|---|---|
|
||
|
|
| `deploy/native/firewall.sh` | Commands `apply` (default), `status`, `remove`; options `--dry-run`, `--vpn-net`, `--vpn-if`, `--out-if`, `--ttl`/`--no-ttl`, `--mss`/`--no-mss`, `--no-persist`, `--yes`, `--force` |
|
||
|
|
| Interface detection | VPN network: `--vpn-net` -> `server` line of the OpenVPN config -> address of the VPN interface. VPN interface: `--vpn-if` -> interface with an address in the VPN network -> `dev` line -> `tun*`. Other networks: every interface except `lo` and the VPN one (listed with MTU, state, addresses) |
|
||
|
|
| Rules (table `ip ovpmon`, one atomic transaction) | masquerade, `ip ttl set N` at egress (default 64), TCP MSS clamp of SYN/SYN-ACK in both directions (`rt mtu` or a fixed value); counters on every rule |
|
||
|
|
| Safety | other tables and the distribution's nftables service untouched; `nft -c` before applying; stops when the VPN network overlaps with an uplink network; warns about disabled forwarding, duplicate iptables MASQUERADE, strict `rp_filter` with policy routing, other `policy drop` chains (PMTUD/ICMP) |
|
||
|
|
| Persistence | `/etc/ovpmon/nftables.nft` (marker line, a foreign file is never overwritten) loaded by the service `ovpmon-nft`: `DOCS/General/systemd/ovpmon-nft.service`, `DOCS/General/openrc/ovpmon-nft`; applied parameters recorded as `FIREWALL_*` in `deploy.state` |
|
||
|
|
| `nftables` package | installed on request only; not added to the install package list |
|
||
|
|
| Documentation | Scenario 2 guide (new section, layout table), README (quick start, change table), hints of `install.sh`, header note of `lib.sh` |
|
||
|
|
|
||
|
|
## Differences from the plan
|
||
|
|
|
||
|
|
- Interfaces are read with `ip -o` (plain text) instead of `ip -j`: it works with the BusyBox `ip` of Alpine and needs no JSON parsing.
|
||
|
|
- The automated test (`test-firewall.sh`) was **not** written: the owner verifies the script by hand on a live system.
|
||
|
|
|
||
|
|
## Verification
|
||
|
|
|
||
|
|
Checked by the owner by hand on a live **Alpine** host (OpenRC): the script worked as intended. **Not verified:** Debian/Ubuntu (systemd unit `ovpmon-nft.service`) and the Hysteria2 host (specific environment, out of scope of this change).
|
||
|
|
|
||
|
|
## Out of scope
|
||
|
|
|
||
|
|
Filtering policy (INPUT/FORWARD, ports, anti-leak), IPv6, replacing the distribution's `nftables.service`, migration of the manual iptables rules of the Hysteria2 chain; options are not remembered between runs.
|