Verify rules using nft list ruleset
In this step, you will explore nftables
, the successor to iptables
. nftables
provides a more flexible and unified framework for packet filtering and network address translation (NAT). While iptables
is still widely used, nftables
is becoming the default on newer Linux distributions.
You can view the active nftables
ruleset using the nft
command with the list ruleset
option.
Open your terminal and type the following command:
sudo nft list ruleset
Press Enter.
You will see output similar to this, which shows the current nftables
configuration:
table ip filter {
chain INPUT {
type filter hook input priority 0; policy accept;
}
chain FORWARD {
type filter hook forward priority 0; policy accept;
}
chain OUTPUT {
type filter hook output priority 0; policy accept;
}
}
This output shows the default filter table with INPUT
, FORWARD
, and OUTPUT
chains, similar to iptables
. The policy accept
indicates that traffic is allowed by default in these chains.
The nft
command is the primary tool for interacting with nftables
. The list ruleset
option displays the entire active ruleset. Again, sudo
is necessary to view the firewall configuration.
Comparing the output of iptables -L
and nft list ruleset
can sometimes reveal differences if both are configured or if one is managing rules that the other doesn't directly control. In a typical setup, one system (either iptables
or nftables
) will be the primary firewall manager.
You have now learned how to check the status of ufw
, list iptables
rules, and view the nftables
ruleset. These are fundamental skills for understanding and managing firewalls in Linux.
Click Continue to complete this lab.