How To Add New Route In Ubuntu, Linux?

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/add-new-route-ubuntu-linux/
PINTEREST
PINTEREST
INSTAGRAM

I have a box with Ubuntu Linux and I want to add new route to my box. Because I want to access external network from a different interface and network. How can I add new route to my Ubuntu, Debian, Fedora, Cent-OS Linux box? Because ip-tools is the same for all of this Linux distributions.

Display Existing Routing Table

First we should display existing routing table. Our target network should not intersect existing routing information.

Display Existing Routing Table
Display Existing Routing Table

We can see that there is a default route which is listed in the first line. It also named as default . The default gateway IP address is 192.168.142.2

Add New Route

In order to add new route we will  use ip route add command by providing related information. We will add new route to the 172.16.0.0/16 network.

  • ip route add  is our command to add new route
  • 172.16.0.0/24 is target network which is destination range
  • via 192.168.122.1 specifies the next hoop which should be directly connected to our system network.
  • dev ens3 specifies our interface which is same network with 192.168.122.1

Check New Route

This is a route action but we should check the status of the route

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/add-new-route-ubuntu-linux/
PINTEREST
PINTEREST
INSTAGRAM
LEARN MORE  Killing Linux Processes With killall Command