Saturday, 14 September 2019

How to check routing table on CentOS 7



The routing table is displays the different sub nets and their routes details. Also the table provides information about default route and other routes and their matrices. This article describes various commands that displays routing table in CentOS 7.
1. ip command: Run the following command to display the routing table using ip –r or ip route or ip route list command:

[root@linuxcloudy ~]# ip r
default via 192.168.43.1 dev ens33 proto static metric 100
192.168.43.0/24 dev ens33 proto kernel scope link src 192.168.43.14 metric 100
[root@linuxcloudy ~]#

[root@linuxcloudy ~]# ip route
default via 192.168.43.1 dev ens33 proto static metric 100
192.168.43.0/24 dev ens33 proto kernel scope link src 192.168.43.14 metric 100
[root@linuxcloudy ~]#

[root@linuxcloudy ~]# ip route list
default via 192.168.43.1 dev ens33 proto static metric 100
192.168.43.0/24 dev ens33 proto kernel scope link src 192.168.43.14 metric 100
[root@linuxcloudy ~]#

2. netstat command: Run the following command to display the routing table using netstat -nr command:

[root@linuxcloudy ~]# netstat -nr
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
0.0.0.0         192.168.43.1    0.0.0.0         UG        0 0          0 ens33
192.168.43.0    0.0.0.0         255.255.255.0   U         0 0          0 ens33 [root@linuxcloudy ~]#

3. route command: Run the following command to display routing table using route -n command:

[root@linuxcloudy ~]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.43.1    0.0.0.0         UG    100    0        0 ens33
192.168.43.0    0.0.0.0         255.255.255.0   U     100    0        0 ens33
[root@linuxcloudy ~]#

Done!!! The above commands displays routing table.

No comments:

Post a Comment