How to use the route command in Linux?

Gaurav Gupta
3 min readMay 31, 2021


route command in Linux is used to modify or work with IP/kernel routing table. Its primary use is to set up static routes to specific hosts or networks. This command mainly used for showing the routing table content.

Installation of route command:

Most OS comes with route command preinstalled. In case of not having this command, it comes with software package named net-tools.

# in case of ubuntu/debian distribution
$ apt-get install net-tools
# in case of redhat distribution
$ yum install net-tools

Working with route:

  • To show IP/kernel routing table:
$ route
  • To add a new route to routing table:
$ route add -net netmask dev eth0

This sets all of the class D (multicast) IP routes to go via “eth0”. To check more examples and options used with this command, check manual of route command

$ man route
  • To delete a route:
$ route del default

This deletes the current default route, which is labeled “default” or in the destination field of the current routing table. To delete other routes, used the label assigned or use Destination IP.

Let’s play some more with route command…

Task Description:

Create a network Topology Setup in such a way so that System A can ping to two Systems System B and System C but both these systems should not be pinging each other without using any security rule e.g firewall etc.


  • Let’s check first that these 3 systems can ping to each other or not…

In System A:

In System B:

In System C:

  • Now let’s modify the routing table of system B so that it can't ping to system C
$ route add -host reject

This adds a new host in the routing table and reject install a blocking route, which will force a route lookup to fail.

You can see that system B can ping to system A but not system C.

  • Now modify the routing table of system C so that it can’t ping to system B
$ route add -host reject

Now we can see that it can’t ping to system B but can ping to system A.


Do clap if you find it worth…🙌

Feel free to connect on linkedin…😊

Having any issues related to the article, please DM me…



Gaurav Gupta

Tech Enthusiasts, Passion to learn and share