route and netstat
12,908 Total views across this article’s versions; includes the historical baseline where available.
This section describes the use of alternative tools to the iproute2 suite for viewing the status of a network. They may be old, but route and netstat can still be useful when troubleshooting IPv4 routing tables.
The examples below use one illustrative IPv4 topology throughout: eth0 has address 192.168.10.10/24, and its next-hop router is 192.168.10.6. They are explanatory output, not a capture from the reader’s host. These legacy tools show only part of modern Linux routing state; use ip route and ip rule for policy routing.
Hosts, Gateways, and Routes
A host is an addressable endpoint. A gateway is a next-hop router that forwards packets toward another destination. A route is a forwarding-table entry describing a destination prefix and how to handle matching traffic.
A route can cover a network or one address (/32 in IPv4). Either can be reached directly or through a gateway. “Host,” “gateway,” and “route” are therefore not three mutually exclusive connection types. A gateway need not perform NAT or firewall filtering, and a host route need not lead to a physically local device.
The route Command: An Oldie, but a Goodie
route belongs to the older net-tools suite. Its ordinary IPv4 listing is based on the kernel’s main routing table; it cannot provide the full view of policy rules, custom tables, or multipath attributes available through iproute2.
For the example topology, inspect the main table with:
ip -4 route show table main
Illustrative output:
default via 192.168.10.6 dev eth0 metric 100
192.168.10.0/24 dev eth0 proto kernel scope link src 192.168.10.10
The preferred local source address after src is an additional route attribute; it is not a NAT operation. The next-hop address remains 192.168.10.6 in every display below.
route -n
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.10.6 0.0.0.0 UG 100 0 0 eth0
192.168.10.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
Prefer ip route for new configurations because it exposes modern routing features. The older route add interface is not inherently corrupting, but it cannot express the complete policy-routing model. The examples here are read-only.
Flags
The common flags describe the entry, not a live test of the entire path:
| Flag | Meaning |
|---|---|
| G | Use a next-hop gateway. This does not say that the packet's final destination is that gateway. |
| H | A host route: the destination prefix identifies a single address. |
| U | The route is installed as up; this does not prove that a remote destination or gateway is responding. |
| ! | A rejecting route. |
| D / M | Historical dynamic/modified-route indicators. |
| A / C / R | Other legacy indicators described by route(8); their presence depends on address family, kernel, and entry type. |
GH can describe a route to one destination through a router. It does not establish that the destination itself is a router.
Destination, Gateway, Genmask, and Flags
Read the destination, mask, next hop, and interface together. The destination prefix describes which packet addresses match; the gateway and interface describe the next step. Flags help interpret these fields, but do not replace the prefix or routing policy.
Destination and Genmask
Destination is the route’s destination network or host, not necessarily the destination of the particular packet being investigated. Genmask is the netmask for that prefix.
For example, 192.168.10.0 with mask 255.255.255.0 represents 192.168.10.0/24. A /32 mask selects one address; a zero-length mask selects every IPv4 destination. See Netmask Filtering Deep Dive for the bit calculation.
Gateway Address vs. Gateway Flag
A G flag indicates use of a next-hop gateway. In numeric output, 0.0.0.0 in the Gateway column normally means no separate gateway is specified; the route sends traffic through its device directly.
On Ethernet that commonly means neighbor resolution on the attached link. A tunnel or point-to-point device can also have a device route, so the absence of a gateway does not prove a physical LAN connection. The routing table describes the configured path, not whether a destination is actually reachable.
The Up Flag
U is the legacy “up” route flag. It is not a health-check result. A static route can remain installed while a router or a service beyond it is unreachable. Link events, a routing daemon, or explicit monitoring can change route availability; the flag alone does not establish that those mechanisms exist.
route vs. route -n
Without -n, route attempts name resolution and can show names where they are available. For example, if 192.168.10.6 resolves to upstream.router, the same entries may appear as:
Destination Gateway Genmask Flags Metric Ref Use Iface
default upstream.router 0.0.0.0 UG 100 0 0 eth0
192.168.10.0 * 255.255.255.0 U 0 0 0 eth0
With -n, the addresses remain numeric, default is shown as 0.0.0.0, and an absent gateway is shown numerically rather than *. Name resolution is not guaranteed to return a hostname. It also does not change the route being described.
Default Routes
An IPv4 default route has prefix 0.0.0.0/0: both Destination and Genmask are zero in the legacy numeric display. It is the least-specific destination match in that table.
A table can contain multiple default routes, for example with different metrics, or a multipath default route with multiple nexthops. There is no one-gateway-per-interface rule. Policy rules decide which tables are consulted, and a successful lookup in an earlier table normally ends the search.
The example’s default route means: if lookup reaches main and no more-specific usable route matches, use 192.168.10.6 through eth0, subject to other route-selection attributes. A default route on a point-to-point device need not have a separate gateway address.
LANs
The example’s connected route is 192.168.10.0/24 dev eth0. For matching on-link unicast traffic, Linux uses eth0 without a separate next-hop router. The local address 192.168.10.10 lies in that prefix, and src expresses its preference for locally generated traffic using the route.
Broadcast and local-address handling also involve entries in the local table. A main-table row is not the whole local-delivery model. To inspect the actual addresses on the device:
ip -4 address show dev eth0
Iface (Interface)
Iface identifies the outgoing device for the displayed route. The device may be physical or virtual. Multiple routes may share it, and one host may have several interfaces.
Routing can send different destination prefixes through different devices. That is path selection, not an access restriction: use filtering when traffic must be prohibited from another path.
Metric, Ref, and Use
These legacy display fields do not all have the same significance. In particular, nonzero values are not automatically network-error alerts. Modern route selection still uses metrics; the old reference/use columns should not be treated as traffic-volume measurements.
Metric
For otherwise comparable routes with the same destination prefix in one table, a lower route metric is preferred. Metrics do not override a more-specific prefix, and they are separate from policy-rule priorities.
There is no general fallback based on a visible “route number.” Equal-cost multipath requires an appropriate route configuration; two unrelated rows with equal numbers are not a complete load-balancing design. A higher-metric default can be used when a preferred route is withdrawn or becomes unusable, but metrics alone do not probe Internet reachability or provide end-to-end failover.
The current kernel exports the route priority in the legacy Metric column. This field is not obsolete merely because route is an older utility.
Ref
Ref is a legacy reference-count field. Current Linux IPv4 /proc/net/route output supplies zero here. It is not a measure of how heavily a route is used.
Use
Use has historical lookup/cache-counter meanings in older documentation. Current Linux IPv4 /proc/net/route output supplies zero here as well. Do not infer a route’s traffic volume from it. The old IPv4 routing cache was removed in Linux 3.6; cache-hit/miss descriptions are historical, not instructions to flush a cache before route changes take effect.
Utilizing route Successfully
A useful read-only sequence is:
ip -4 rule show
ip -4 route show table all
ip -4 route get 203.0.113.20
Rules are processed by priority, with lower numbers first. A rule’s selector determines whether its action is attempted; this is not a “longest matching rule” contest. A table lookup then applies destination-prefix matching and other route attributes within that table. There is no global longest-prefix contest across every table in the RPDB.
ip route get performs a lookup; it does not send a test packet. Supply the relevant source, incoming interface, mark, or other selector when reproducing a policy-dependent lookup. Its result still does not prove end-to-end connectivity.
netstat
netstat is another net-tools utility. Its routing view is selected with -r, and -n suppresses address/name resolution:
netstat -rn
For modern route and policy inspection, use ip route and ip rule. For socket inspection, the usual iproute2 replacement is ss; that is a different task from displaying routes.
Analyzing Outputs: route vs netstat
The common destination, gateway, netmask, flags, and interface fields describe the same topology, but the supplementary columns differ with the selected output mode:
| Command | Supplementary fields |
|---|---|
| route -n | Metric, Ref, Use |
| route -en | MSS, Window, irtt |
| netstat -rn | MSS, Window, irtt (like route -en) |
| netstat -rne | Metric, Ref, Use (like route -n) |
For the one topology used in this article, the default next hop remains 192.168.10.6 through eth0. A change from numeric output to resolved names must not silently change that address or interface.
Parameters
The supplementary columns are route attributes or legacy counters. They are not operational alerts. Interpret their meaning and units before drawing conclusions from a nonzero value.
The following comparisons describe the net-tools route display. They are not pairs of equivalent iproute2 and netstat parameters.
Metric and the Legacy MSS Column
Metric describes route preference. A lower value is preferred among otherwise comparable routes; it is not a measured path delay or an inherent error condition.
The net-tools MSS heading has a legacy compatibility wrinkle. For current Linux IPv4 /proc/net/route, this column is supplied as advertised MSS plus the 40-byte base IPv4/TCP header size when an advertised MSS is configured; otherwise it is zero. It must not be read uncritically as a live, negotiated TCP payload size. The route mss option is also documented as setting the route MTU rather than TCP MSS.
For actual TCP terminology, MSS concerns segment data size, MTU concerns the IP packet size on a path/link, and segmentation differs from IP fragmentation. Use modern ip route attributes such as mtu and advmss when inspecting or configuring these values.
Ref and Window
Ref is the legacy field described above, not a TCP setting. Window is a route-related TCP window setting measured in bytes, not a count of packets that may be sent before an acknowledgment. A displayed zero represents no explicit route value in this interface; it is not an advertised zero receive window from a live TCP connection.
Use and irtt
Use is the legacy field described above. irtt is an initial round-trip-time setting/hint associated with a route, not a live latency measurement. A zero or nonzero value alone does not diagnose a network fault.
Sources: route(8), netstat(8), ip-route(8), ip-rule(8), the net-tools IPv4 formatter, and the Linux IPv4 route export. The kernel export explains the current main-table, metric, zero-counter, and legacy MSS details where older manual wording is misleading.