Open or close server ports
Open server ports for remote access
In many cases, it is necessary to open additional ports for your application(s) to function correctly.
If you are using iptables, use the following command to open port 21:
$ iptables -A INPUT -p tcp --dport 21 -j ACCEPT
If you are using ufw, use the following command to achieve the same result:
$ sudo ufw allow 21
Close server ports and deny remote access
In some cases, it is necessary to close ports for your application(s) to increase security.
If you are using iptables, use the following command to close port 21:
$ iptables -A INPUT -p tcp --dport 21 -j DROP
If you are using ufw, use the following command to achieve the same result:
$ sudo ufw deny 21