How do I block requests from an IP address/range with iptables?

0 Comments

To block incoming requests from a single IP address, you can use:
iptables -I INPUT -s {IP-HERE} -j DROP
so if you’d want to block incoming requests from IP address 2.4.6.8, you’d use:
iptables -I INPUT -s 2.4.6.8 -j DROP

Should you want to block an entire range, for example 10.20.30.0-10.20.30.255, you can use:
iptables -I INPUT -s 10.20.30.0/24 -j DROP

In all cases: Use iptables -L to verify the address/range you added is indeed on top of the list now.

--
51 views
Was this answer helpful ? Yes (1) / No (0)

Leave a Reply

reduction