The routing table can be displayed using 2 commands ip route show and route -n. ip route show command tells us the details such as default ip address to be used, the network interface, protocol being used, source ip address and metric.
In Linux, the routing table can be displayed using commands such as route -n or ip route show. These commands provide essential information about how the system routes network traffic. Here's a brief explanation based on the provided example:
route -n:
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.1.1 0.0.0.0 UG 600 0 0 wlp2s0
192.168.1.0 0.0.0.0 255.255.255.0 U 600 0 0 wlp2s0
This command displays the kernel IP routing table.
The first line (0.0.0.0) represents the default route, pointing to the gateway (192.168.1.1) via the wlp2s0 interface.
The second line (192.168.1.0/24) signifies the local subnet directly accessible via wlp2s0.
ip route show:
default via 192.168.1.1 dev wlp2s0 proto dhcp src 192.168.1.35 metric 600
192.168.1.0/24 dev wlp2s0 proto kernel scope link src 192.168.1.35 metric 600
This command provides a more detailed output.
The first line denotes the default route via 192.168.1.1 on the wlp2s0 interface, obtained dynamically through DHCP.
The second line specifies the local subnet 192.168.1.0/24 via wlp2s0 with a kernel scope.
Both commands offer insights into the routing table, showcasing default routes, gateways, interfaces, and associated metrics for effective network connectivity.