Viewing the existing routing table

Before we embark on adding or deleting routes, it’s prudent to check the existing default routes on a system. To do so, simply launch your terminal and issue the command:

$ ip route show
$ ip route list

 Similar statistics can be displayed using route command,
$ route -n

Or simply,
$ route 

Adding a static route using IP command

Suppose you want to take a backup of a Linux machine and push the backup file to another backup server in the subnet However, for one reason or the other, you cannot reach the backup server  via the default gateway. In this case, you will have to create a new route for backup server subnet via another IP, say via the interface enp0s3.

The command for this will be

$ sudo ip route add via dev enp0s3


  •      ->             is the network you want to connect to
  • /24              ->             is the subnet mask
  • ->    is the IP through which we will reach the server
  • enp0s3       ->            is the network interface

You can confirm whether new static route add been in route table using “ip route show” command.

$ sudo ip route show

To add the specific IP of the backup server, say run the command:

$ sudo ip route add via dev enp0s3

Once again, you can check the routing changes to see if the changes exist using the ip route show command:

$ ip route show

By anup

Leave a Reply

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