Nftables: Difference between revisions

From Alpine Linux
(→‎See also: Uncomplicated Firewall)
 
(9 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{DISPLAYTITLE:nftables}}The {{Pkg|nftables}} package provides user-space tools to control the Linux nftables subsystem.
{{DISPLAYTITLE:nftables}}The [https://netfilter.org/projects/nftables nftables] project provides user-space tools to control the Linux nftables subsystem.


A service that loads the rules from {{path|/etc/nftables.d}} can be enabled with:
== Installation ==


rc-update add nftables boot
To use {{ic|nft}} command from {{Pkg|nftables}} package, install it first:{{Cmd|# apk add {{Pkg|nftables}}}}
rc-service nftables start


The default rules shipped will block all incoming connections.
== Configuration ==


= See also =
The default <code>nftable</code> rules shipped will block all incoming connections. A service that loads the rules from {{path|/etc/nftables.d}} folder can be enabled with: {{Cmd|<nowiki># rc-update add nftables boot
# rc-service nftables start</nowiki>}}


If {{ic|nftables}} rules are in {{Path|/usr/share/nftables.avail}} folder, they must be symlinked to {{path|/etc/nftables.d}} folder to enable them. For e.g if there is a rule {{Path|/usr/share/nftables.avail/sshd.nft}}, issue the below command:{{Cmd|# ln -s /usr/share/nftables.avail/sshd.nft /etc/nftables.d/sshd.nft}}
== Packaged rules ==
Server software packages that are accompanied by an <code>-nftrules</code> package includes the typical default rules to expose the server. For example, {{pkg|openssh-nftrules}} package will open the default port(s) used by {{pkg|openssh}}. These rules are not active upon package installation. They are installed in the <code>/usr/share/nftables.avail/</code> directory. The user can either symlink them individually to <code>/etc/nftables.d/</code>, or add this configuration line <code>include "/usr/share/nftables.avail/*.nft"</code> to <code>/etc/nftables.nft</code>.
== See also ==
* [https://wiki.nftables.org/wiki-nftables/index.php/Main_Page nftables project Wiki]
* [https://wiki.archlinux.org/title/Nftables nftables - ArchWiki]
* [https://wiki.archlinux.org/title/Nftables nftables - ArchWiki]
* [https://netfilter.org/projects/nftables/ nftables project homepage]
* [[Uncomplicated Firewall]] Firewall program with higher level abstractions
* [[Uncomplicated Firewall]]


[[Category:Networking]]
[[Category:Firewall]]

Latest revision as of 06:11, 20 August 2025

The nftables project provides user-space tools to control the Linux nftables subsystem.

Installation

To use nft command from nftables package, install it first:

# apk add nftables

Configuration

The default nftable rules shipped will block all incoming connections. A service that loads the rules from /etc/nftables.d folder can be enabled with:

# rc-update add nftables boot # rc-service nftables start

If nftables rules are in /usr/share/nftables.avail folder, they must be symlinked to /etc/nftables.d folder to enable them. For e.g if there is a rule /usr/share/nftables.avail/sshd.nft, issue the below command:

# ln -s /usr/share/nftables.avail/sshd.nft /etc/nftables.d/sshd.nft

Packaged rules

Server software packages that are accompanied by an -nftrules package includes the typical default rules to expose the server. For example, openssh-nftrules package will open the default port(s) used by openssh. These rules are not active upon package installation. They are installed in the /usr/share/nftables.avail/ directory. The user can either symlink them individually to /etc/nftables.d/, or add this configuration line include "/usr/share/nftables.avail/*.nft" to /etc/nftables.nft.

See also