CentOS Debian Mint openSUSE Red Hat Ubuntu

Route Command in Linux

Route Command in Linux


Routing is a difficult technique in the networking world. In order to make your computers communicate with other devices on the network, you have to define the route for them.

Thanks to the route command, the network administrators or Linux users can do this work in an easier way.

Route command can be used to show and modify the network routing table in a Linux system.

Below is the guide on how to use the route command in Linux.

Routing table

To show the current routing table, let’s run the following command

$ route -n


Another way to describe more detail about which network interface of routes is running the command:

$ ip route show


Add a new route

If your computer has more than one network interface and you want to add a new route, the computer will send traffic through that new gateway. You can use the route add command as below:


For example:

$ sudo route add -net gw eth2

To add a new route to a host, run the following command:

$ sudo route add -host <HOST-IP> gw <GATEWAY>

For example:

$ sudo route add -host gw


In the Flags column, there are some values that are difficult to understand. The following section is a quick explanation:

U: up

H: host

G: gateway

!: rejected route

Delete a route

If you no longer use a specific route and you want to delete it, you can simply run the following command:


For example:

$ sudo route del -net gw eth2

To reject a route but you want to keep it on the routing table, run the command with the reject option.

$ sudo route add -host reject


You have just read a tutorial about how to use the route command in a Linux system with examples.

Thanks for reading. If you have any concerns, feel free to leave your comment and let me know.

Similar Posts