HOW TO : Route traffic to loopback interface in Linux

Back in 2009 (last decade!! 🙂 ), I wrote a blog post on how you can trick windows to route traffic destined to a particular IP address to a black-hole. In it, I mentioned the command to route traffic to /dev/null in Linux was


I ran into a need to try it today and looks like the trick doesn’t work :). So here is the right command if you want to route traffic to the loopback (or blackhole) destined to a particular IP address

sudo route add -host IP_ADDRESS_OF_HOST/NETWORK_MASK lo 

For example if I want to black-hole traffic destined to, I would do the following

 sudo route add -host lo 

Leave a Reply

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