Server Network — Centralised Subnets and Firewall
Purpose
The network module coordinates network subnet definitions and firewall rules.
Subnets come from the shared data/network.nix file and apply to every server host.
Entry Point
- Main file:
modules/nixos/server/network.nix
Options
server.network.openPortsForSubnet.tcp
| Type | list of 16 bit unsigned integer; between 0 and 65535 (both inclusive) |
| Default | [ ] |
List of TCP ports to open on the firewall for each subnet.
server.network.openPortsForSubnet.udp
| Type | list of 16 bit unsigned integer; between 0 and 65535 (both inclusive) |
| Default | [ ] |
List of UDP ports to open on the firewall for each subnet.
Architecture / Services / Scope
- Subnets are read directly from
self.data.network.subnets, documented in Shared Data. There is no per-host subnet option. - The module generates
ip saddr/ip6 saddraccept rules for the specified ports, allowing traffic only from the defined subnets. - These rules are appended to the
nftablesinput chain through thenetworking.firewall.extraInputRulesoption. They apply to new and untracked flows only; established connections are accepted earlier byconntrack.
Operational Notes / Assumptions
- Subnets are declared in
data/network.nix; hosts do not declare them. - Per-host open ports are declared through
server.network.openPortsForSubnet.