Interpreting the 'metric' column in routing table
I'm a little confused about the output I'm seeing in my routing table, particularly the 'metric' column:
$ route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.0.1 0.0.0.0 UG 0 0 0 wlan0
172.16.35.0 0.0.0.0 255.255.255.0 U 0 0 0 vmnet1
192.168.0.0 0.0.0.0 255.255.255.0 U 9 0 0 wlan0
192.168.82.0 0.0.0.0 255.255.255.0 U 0 0 0 vmnet8
According to the man page, metric indicates the 'distance' to the target. I was a little confused about what exactly "target" was. I assumed it was my router (it goes to gateway 0.0.0.0, which then goes to my router at 192.168.0.1). Thus, I expected the metric to be a single hop to my router. However, it's 9! Why is this so number high?
According to the man page, metric indicates the 'distance' to the target.
I expected the metric to be a single hop to my router. However, it's 9! Why is this so number high?
The metric
field has a number of different meanings:
The Metric field indicates the cost of a route. If multiple routes exist to a given destination network ID, the metric is used to decide which route is to be taken. The route with the lowest metric is the preferred route. Some routing algorithms only store a single route to any Network ID in the routing table even when multiple routes exist. In this case, the metric is used by the router to decide which route to store in the routing table.
Metrics can indicate different ways of expressing a route preference:
Hop Count.
A common metric. Indicates the number of routers (hops) in the path to the network ID.
Delay.
A measure of time that is required for the packet to reach the network ID. Delay is used to indicate the speed of the path—local area networks (LAN) links have a low delay, wide area network (WAN) links have a high delay—or a congested condition of a path.
Throughput.
The effective amount of data that can be sent along the path per second. Throughput is not necessarily a reflection of the bit rate of the link, as a very busy Ethernet link may have a lower throughput than an unutilized 64-Kbps WAN link.
Reliability.
A measure of the path constancy. Some types of links are more prone to link failures than others. For example, with WAN links, leased lines are more reliable than dial-up lines.
Source Routing Tables