Forrest logo
back to the nft tool

nft:tldr:79a99

nft: Add a new rule to accept several TCP ports.
$ sudo nft add rule ${inet} ${filter} ${input} ${tcp} ${dport \{ telnet, ssh, http, https \} accept}
try on your machine

This command is using the nft command-line tool with the add rule option to add a new rule to the network filtering table.

  • sudo: This command is executed with superuser (root) privileges.
  • nft: It is the command-line tool used to manage the Netfilter firewall rules in the Linux kernel.
  • add rule: This option is used to add a new rule to the specified table.
  • ${inet}: This specifies the network family or address family. It usually represents the IPv4 or IPv6 family.
  • ${filter}: This specifies the table name. In this case, it is the filter table used for packet filtering.
  • ${input}: This specifies the chain within the table where the rule should be inserted. In this case, it is the input chain used for processing incoming packets.
  • ${tcp}: This specifies the protocol that the rule should apply to. In this case, it is the TCP protocol.
  • ${dport { telnet, ssh, http, https } accept}: This specifies the rule itself. It matches packets with a destination port number matching any of the specified ports (telnet, ssh, http, https) and accepts them.

In summary, this command adds a new rule to the filter table's input chain that accepts TCP packets with the destination port number matching telnet, ssh, http, or https.

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 nft tool