List iptables rules with iptables -L
In this step, you will learn how to view the current firewall rules using the iptables
command. iptables
is a traditional command-line utility used to configure the Linux kernel firewall.
Firewalls are essential for network security. They control incoming and outgoing network traffic based on a set of rules. These rules determine whether to allow or block specific connections.
To list the current iptables
rules, you will use the -L
option. This option tells iptables
to list the rules in the specified chains.
Open the terminal if you haven't already. Type the following command and press Enter:
sudo iptables -L
You need to use sudo
because viewing firewall rules requires administrative privileges.
You will see output similar to this:
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
This output shows the rules for the three default chains: INPUT
, FORWARD
, and OUTPUT
.
INPUT
: Controls traffic destined for the local machine.
FORWARD
: Controls traffic passing through the machine (used for routing).
OUTPUT
: Controls traffic originating from the local machine.
The policy ACCEPT
means that by default, traffic is allowed in these chains if no specific rule matches it.
If there were specific rules configured, they would be listed under each chain, showing details like the target (e.g., ACCEPT, DROP), protocol (e.g., tcp, udp), source and destination IP addresses, and ports.
For now, the default configuration is simple, but you've successfully used iptables
to view the current rules.
Click Continue to proceed to the next step.