To block a port using the iptables command on a Linux system, you can use the following syntax:
iptables -A INPUT -p tcp --dport [port number] -j DROP
For example, to block incoming connections on port 80 (the default HTTP port), you would use the following command:
iptables -A INPUT -p tcp --dport 80 -j DROP
To block incoming connections on multiple ports, you can specify multiple --dport arguments:
iptables -A INPUT -p tcp --dport 80 --dport 443 -j DROP
Note that the iptables command is not persistent, so if you reboot your system or restart the iptables service, your rules will be lost. To make the rules persistent, you can use the iptables-save and iptables-restore commands to save the current rules to a file and restore them on boot.
It's also worth noting that the iptables command is deprecated in many modern Linux distributions in favor of the nftables command. If you are using a recent version of Linux, you may want to consider using nftables instead.