Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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

Typelist 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

Typelist 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 saddr accept rules for the specified ports, allowing traffic only from the defined subnets.
  • These rules are appended to the nftables input chain through the networking.firewall.extraInputRules option. They apply to new and untracked flows only; established connections are accepted earlier by conntrack.

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.

References