How I can block specific IP's using iptables?

How I can block specific IP's? And as I know, if I somehow block them, it will be not blocked again after reboot. How I can make a script which will block specific IP's?

1

1 Answer

You can add this rule. In --src you also can define various IPs seperated by , (and without spaces!)

iptables -A INPUT --src <the specific IP> -j DROP

Be careful not to lock yourself out though!

For keeping them after reboot read how-can-i-make-a-specific-set-of-iptables-rules-permanent


A quite complete and easy to maintain iptables setup I've found is

DigitalOcean: How to implement a basic firewall template with iptables on Ubuntu 14.04

2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like