fix(vds-nftables): open SSH on all interfaces, not just tailscale0

Owner correction 2026-10-10: "не помню, чтобы просил ограничивать
22 порт". The previous T3 fix (5796786) restricted SSH to
iifname "tailscale0" based on a comment in the original vds.nix
that said "SSH is reachable only over Tailscale". The owner
did not actually request this restriction.

This commit:
- Changes  to
   (all interfaces, no iifname filter)
- Removes the  reference
- Updates comments to reflect the actual owner intent
  (SSH open everywhere, managed via nftables)
- Keeps the core R1.6 fix: explicit  on chain
  input, no firewall.* + nftables.* conflict (firewall.enable = false
  with lib.mkForce on shadow rules)
- Keeps Xray REALITY (443), ICMP, traceroute, log+drop
- Keeps port 80 closed (no nginx on otreca)

SSH on otreca is now reachable on:
  - Tailscale IP (100.64.1.0 or whatever current)
  - Public IP (109.248.161.5) on ens3
  - Any loopback

Deployment: otreca rebuild + nft verify.
This commit is contained in:
2026-10-10 17:08:15 +03:00
parent fafd3e2df7
commit 4dc4849d71
+29 -26
View File
@@ -3,19 +3,22 @@
# The host record lives in configurations/default.nix; this file is only the # The host record lives in configurations/default.nix; this file is only the
# module body. `xlib` (identity, dirs, helpers) arrives as a module argument. # module body. `xlib` (identity, dirs, helpers) arrives as a module argument.
# #
# T3 FIX APPLIED 2026-10-10 (Option A from # T3 FIX (minimal, R1.6 only) 2026-10-10:
# .agent/decisions/proposals/vds-nftables-fix.md): # - Explicit `policy drop` on chain input (R1.6 fix — original ruleset
# - Explicit `policy drop` on chain input (R1.6 fix) # had no policy, so it was implicit accept)
# - Removed `firewall.enable = true` to eliminate the # - Removed `firewall.enable = true` to eliminate the
# `firewall.*` + `nftables.*` conflict (R1.6) # `firewall.*` + `nftables.*` conflict (R1.6)
# - SSH on port 22 limited to tailscale0 via nftables iifname # - SSH (22) open on ALL interfaces (no iifname restriction)
# - ICMP + traceroute explicitly accepted # - Xray REALITY (443) open
# - Xray REALITY on 443 accepted # - ICMP + traceroute (33434-33534) for diagnostics
# - 80/HTTP closed by default (no nginx here, otreca is relay) # - 80/HTTP closed by default
# - Log + drop at the end (nft-drop: prefix) for diagnostics # - Log + drop at the end (nft-drop: prefix) for diagnostics
# #
# On otreca: Tailscale-only management. Public attack surface is # CORRECTED 2026-10-10: removed `iifname "tailscale0"` restriction on
# Xray REALITY on 443 only. Everything else is tailnet-internal. # SSH — owner did not ask for that. SSH is open on ens3 too.
#
# On otreca: management via Tailscale OR public SSH. Public attack
# surface is SSH (22) + Xray REALITY (443).
{ {
lib, lib,
modulesPath, modulesPath,
@@ -56,19 +59,20 @@
}; };
host.ssh.enable = true; host.ssh.enable = true;
# SSH is reachable only over Tailscale (not on the public internet). # SSH is reachable on all interfaces (public + Tailscale). The
# This otreca VDS is reached by deploy-rs and by oqyude over the # nftables ruleset below opens 22 explicitly. `openFirewall = false`
# tailnet, so exposing 22 to ens3 is pure attack surface. # because we manage the firewall via nftables, not the NixOS
# firewall module (see `firewall.enable = false` further down).
services.openssh.openFirewall = false; services.openssh.openFirewall = false;
services.tailscale = { services.tailscale = {
enable = true; enable = true;
openFirewall = true; openFirewall = true;
}; };
# NOTE: networking.firewall.interfaces.tailscale0.allowedTCPPorts = [ 22 ]; # REMOVED 2026-10-10: networking.firewall.interfaces.tailscale0.allowedTCPPorts = [ 22 ].
# REMOVED 2026-10-10 (T3 Option A): the old `firewall.enable = true` setup # SSH is now opened on ALL interfaces via the nftables ruleset below
# conflicted with the custom nftables ruleset (R1.6). The new ruleset # (`tcp dport 22 accept` — no iifname restriction).
# opens 22 on tailscale0 directly via `iifname "tailscale0" tcp dport 22 accept`. # Owner corrected: "не помню, чтобы просил ограничивать 22 порт".
networking = { networking = {
nameservers = [ nameservers = [
@@ -81,18 +85,17 @@
enable = true; enable = true;
IPv6rs = false; IPv6rs = false;
}; };
# T3 Option A: `firewall.enable = false` to eliminate the # T3 (R1.6 fix): `firewall.enable = false` eliminates the
# firewall.* + nftables.* conflict (R1.6). The mkForce on # `firewall.*` + `nftables.*` conflict. The `lib.mkForce` on
# allowedTCPPorts and interfaces ensures the NixOS firewall # `allowedTCPPorts` and `interfaces` prevents the NixOS firewall
# module does not silently add rules that would shadow our # module from silently injecting rules that would shadow our
# nftables ruleset. All filtering is now done by the ruleset below. # nftables ruleset. All filtering is now done by the ruleset below.
firewall.enable = false; firewall.enable = false;
firewall.allowedTCPPorts = lib.mkForce [ ]; firewall.allowedTCPPorts = lib.mkForce [ ];
firewall.interfaces = lib.mkForce { }; firewall.interfaces = lib.mkForce { };
# allowPing removed 2026-10-10 (T3 Option A): with firewall.enable = false, # `networking.allowPing` was removed because with firewall.enable = false
# `networking.allowPing` no longer exists as a top-level option. ICMP # it no longer exists as a top-level option. ICMP accept is handled
# accept is now handled by the nftables ruleset below # by the nftables ruleset below (`ip protocol icmp accept`).
# (`ip protocol icmp accept`).
nftables = { nftables = {
enable = true; enable = true;
ruleset = '' ruleset = ''
@@ -113,8 +116,8 @@
# traceroute # traceroute
udp dport 33434-33534 accept udp dport 33434-33534 accept
# SSH — Tailscale only (R1.6: never on the public interface) # SSH (22) — open on all interfaces (owner: no iifname restriction)
iifname "tailscale0" tcp dport 22 accept tcp dport 22 accept
# Xray REALITY inbound (treca acts as relay from sapphira via XHTTP) # Xray REALITY inbound (treca acts as relay from sapphira via XHTTP)
tcp dport 443 accept tcp dport 443 accept