Forrest logo
back to the iptables tool

iptables:tldr:f71f6

iptables: Set chain policy rule.
$ sudo iptables -P ${chain} ${rule}
try on your machine

This command is used to set the default policy for a specific chain in the iptables firewall rules on a Linux system.

Here's a breakdown of the command:

  • sudo: This is used to execute the command with administrative/root privileges.
  • iptables: This is the command-line utility for configuring the Linux firewall and packet filtering system, known as iptables.
  • -P: This option is used to set the default policy for a chain. The default policy specifies what happens to the network traffic that doesn't match any of the rules in the chain.
  • ${chain}: This is a placeholder for the name of the chain you want to modify. Chains are used to organize rules, and they can be predefined chains like INPUT, OUTPUT, or FORWARD, or custom user-defined chains.
  • ${rule}: This is a placeholder for the default policy you want to set for the specified chain. The policy can be one of ACCEPT, DROP, or REJECT. ACCEPT allows the traffic to pass through, DROP silently discards the traffic, and REJECT discards the traffic but also sends an error response to the sender.

To use this command, you will need to replace ${chain} with the actual name of the chain and ${rule} with the desired default policy. For example, to set the default policy of the INPUT chain to DROP, you would execute sudo iptables -P INPUT DROP.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the iptables tool