Blocking all incoming requests except specific IP using iptables

B

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

About the author

Mahmoud M. Abdel-Fattah

Add comment

 

WP-SpamFree by Pole Position Marketing

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Recent Posts

Recent Comments