So you’ve just purchased your brand new server and a few days later, your service provider sends you an email saying that a particular port is being abused and you need to block it.
In Linux, it’s really easy and even simpler using QuickBox Pro as well. In this guide, we’ll show the 2 commands you need to use to block any port that you choose.
Blocking the Ports
- SSH into your Server
- Then run the following command
sudo su -
3. Now that your permissions have been elevated correctly, you can now enter the following command
iptables -I INPUT -p tcp --dport <port number> -j REJECT && ip6tables -I INPUT -p tcp --dport <port number> -j REJECT
Where you see <port number> enter in the number of the port you wish to block.
The command port we hear from users that needs to be blocked is port 111. You can simply copy and paste the command below for this port
iptables -I INPUT -p tcp --dport 111 -j REJECT && ip6tables -I INPUT -p tcp --dport 111 -j REJECT