Forrest logo
back to the iptables tool


Block a port from incoming traffic.
$ sudo iptables -A INPUT -p tcp --dport ${port_number} -j ACCEPT
try on your machine

This command adds a new rule to the INPUT chain of the iptables firewall, which allows incoming traffic on a specific TCP port (${port_number}).

  • 'sudo' is used to execute the command with root privileges.
  • 'iptables' is the name of the software that manages the firewall rules.
  • '-A INPUT' appends the new rule to the end of the INPUT chain.
  • '-p tcp' specifies that the protocol used is TCP.
  • '--dport ${port_number}' specifies the destination port that is allowed.
  • '-j ACCEPT' indicates that the traffic matching this rule should be ACCEPTED and allowed to go through.

Overall, this command opens up a specific TCP port to incoming traffic, allowing data to be sent and received on that port.

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