Linux 101 : Interpreting the output of "ip route" and adding routes to a host
The output of the "ip route show" might be confusing to us at first.
Below is an example of the output of that command:
The first line of output tells us that the default route for any packet that doesn't have a corresponding route in our routing table will go through "eno1" using the the default gateway "192.168.2.1".
The second line tells us that the packets sent to an IP address belonging to the "192.168.2.0/24" network - 192.168.2.1, 192.168.2.2, 192.168.2.2, ... -, will be sent to "eno1" which has the "192.168.2.20" IP address.
Adding new routes:
To be able to add routes between hosts, we could use the below command:
- 10.23.37.0/24 : network we want to reach
- 10.45.4.1 : address we use to get to the network we want to reach "10.23.37.0/24".
- eno1 : interface name used.
Adding a default gateway:
To add a default gateway, we could use the below command: