Firewall: Difference between revisions
imported>N8henrie m Incorrectly says it is based on ntfables, which is not true by default. |
imported>Skylark State that iptables is the default |
||
Line 1: | Line 1: | ||
NixOS provides an interface to configure the firewall through the option <code>networking.firewall</code>. | NixOS provides an interface to configure the firewall through the option <code>networking.firewall</code>. | ||
The default firewall uses [https://www.netfilter.org/ iptables]. To use the newer [https://www.nftables.org/ nftables] instead, set <code>networking.nftables.enable = true;</code> | |||
== Enable == | == Enable == | ||
To enable the firewall, | To enable the firewall, add the following into your system configuration: | ||
{{file|/etc/nixos/configuration.nix|nix|<nowiki> | {{file|/etc/nixos/configuration.nix|nix|<nowiki> | ||
Line 15: | Line 15: | ||
== Configuration == | == Configuration == | ||
To allow specific TCP/UDP ports or port ranges on all interfaces, | To allow specific TCP/UDP ports or port ranges on all interfaces, use following syntax: | ||
<syntaxhighlight lang="nix> | <syntaxhighlight lang="nix> | ||
Line 28: | Line 28: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{note|Many services also provide an option to open required firewall ports automatically. For example, the media server Jellyfin offers the option <code><nowiki>services.jellyfin.openFirewall = true;</nowiki></code> which will open required TCP ports.}} | {{note|Many services also provide an option to open the required firewall ports automatically. For example, the media server Jellyfin offers the option <code><nowiki>services.jellyfin.openFirewall = true;</nowiki></code> which will open the required TCP ports.}} | ||
Interface specific firewall rules can be applied like this | Interface-specific firewall rules can be applied like this: | ||
<syntaxhighlight lang="nix> | <syntaxhighlight lang="nix> | ||
Line 40: | Line 40: | ||
== Warning == | == Warning == | ||
Firewall rules may be overwritten by | Firewall rules may be overwritten by Docker, as per https://github.com/NixOS/nixpkgs/issues/111852 |