Linux 101 : Routing, adding routes, checking routes - ip route -

Displaying the routes:

To check the routes and the interfaces our packets take when talking to a specific machine, we could use the below command for a host with the IP - -:

The above results show that we would go to the host - - via the gateway address - - through the - eth0 - interface.

To communicate locally Linux uses the loopback address - lo - as we can see below:

Assigning an IP address to an interface:

To assign an IP address for example - - with a netmask of - 24 - to the interface - eth0 -, we use the below command

Adding a route to the routing table:

The below command adds a route that instructs our IP address
 to go through the interface - eth1- and the gateway - if there is a need to send any requests to any host in the following network - -:

We could check if  the routing table has been updated with the new entry using the below command:


Leave as a comment: