Blocking all incoming requests except specific IP using iptables

If you are using linux and wants to block all incoming requests to a specific port except a specific IP (your static IP or localhost in my example) , You should first block all incoming requests to this PORT using the following command :

~  iptables -A INPUT -p tcp --dport PORT_NUMBER -j DROP

Then, Allow this specific IP using the following command :

~  iptables -A INPUT -p tcp -s THE_IP_YOU_WANT_TO_ALLOW --dport PORT_NUMBER -j ACCEPT

Leave a comment

 

WP-SpamFree by Pole Position Marketing