How do I Drop or block attackers IP with null routes?

Someone might attack on your system. You can drop attacker IP using IPtables. However, you can use route 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. Matching packets are dropped (ignored) rather than forwarded, acting as a kind of very limited firewall. The act of using null routes is often called blackhole filtering.

You can nullroute (like some time ISP do prevent your network device from sending any data to a remote system.) stopping various attacks coming from a single IP (read as spammers or hackers):

Nullroute IP using route command

Suppose that bad IP is, type following command at shell:

# route add gw lo

You can verify it with following command:
# netstat -nr

# route -n

You can also use reject target (thanks to Gabriele):
# route add -host IP-ADDRESS reject
# route add -host reject

To confirm the null routing status, use ip command as follows:
# ip route get


RTNETLINK answers: Network is unreachable

Drop entire subnet
# route add -net gw lo

You can also use ip command to null route network or ip, enter:
# ip route add blackhole
# route -n

How do I remove null routing? How do I remove blocked IP address?

Simple use router delete command,
# route delete

Leave a Reply

Your email address will not be published. Required fields are marked *