Block Attackers IP Address With Null Routes On a Linux
Someone might attack your Linux-Centos-RedHat based system. You can drop attacker IP addresses using IPtables. However, you can also use the route or ip command to null route unwanted traffic. A null route (also called as blackhole route) is a network route or kernel routing table entry that goes nowhere.
The act of using null routes is often called blackhole filtering.
Nullroute IP using route command
Suppose that bad IP is 126.96.36.199, type the following command at shell:
# route add 188.8.131.52 gw 127.0.0.1 lo
You can verify it with the following command:
# netstat -nr
To drop entire subnet 184.108.40.206/24, type:
# route add -net 220.127.116.11/24 gw 127.0.0.1 lo
How do I remove null routing? How do I remove blocked IP address?
Simple use the route delete command as follows:
# route delete 18.104.22.168
# route del -host 22.214.171.124 reject
Or use NA command to delete route:
# ip route delete 126.96.36.199/26 dev eth0
Or To Reject instead of BlackHole: – Though Blackhole they sit and wait for a response which is a further annoyance to the slammer.
route add 188.8.131.52 reject