When you invokeÂ netstat with theÂ â€“r flag, it displays the kernel routing table in the way we’ve been doing withÂ route. OnÂ vstout, it produces:
# netstat -nr Kernel IP routing table Destination Gateway Genmask Flags MSS Window irtt Iface 127.0.0.1 * 255.255.255.255 UH 0 0 0 lo 172.16.1.0 * 255.255.255.0 U 0 0 0 eth0 172.16.2.0 172.16.1.1 255.255.255.0 UG 0 0 0 eth0
TheÂ â€“n option makesÂ netstat print addresses as dotted quad IP numbers rather than the symbolic host and network names. This option is especially useful when you want to avoid address lookups over the network (e.g., to a DNS or NIS server).
The second column ofÂ netstat ‘s output shows the gateway to which the routing entry points. If no gateway is used, an asterisk is printed instead. The third column shows the â€œgeneralityâ€ of the route, i.e., the network mask for this route. When given an IP address to find a suitable route for, the kernel steps through each of the routing table entries, taking the bitwise AND of the address and the genmask before comparing it to the target of the route.