n Linux, the ip route command is used to display and manipulate the kernel’s IP routing table. This table contains information about how packets should be forwarded to their destinations. Here’s a breakdown of the information provided by the ip route command:
- Destination: This field represents the destination network or host to which the route applies. It can be specified as an IP address or network address.
- Gateway: This field specifies the IP address of the next-hop router to which packets should be forwarded to reach the destination network or host. If the destination is directly reachable (e.g., on the same subnet), this field may be blank.
- Genmask/Mask: This field indicates the network mask associated with the destination address. It’s used to determine which portion of the IP address represents the network portion and which portion represents the host portion.
- Flags: Flags provide additional information about the route. Common flags include:
U(Up): Indicates that the route is up and available.G(Gateway): Indicates that a gateway is required to reach the destination.H(Host): Indicates that the destination is a host (single IP address).D(Dynamic): Indicates that the route was dynamically added by a routing protocol.C(Cache): Indicates that the route was dynamically added and is stored in the routing cache.M(Modified): Indicates that the route has been modified since it was last used.
- Metric: This field represents the routing metric associated with the route. The metric is used by the routing algorithm to determine the best path to a destination when multiple routes are available. Lower metric values typically indicate better paths.
- Ref: This field shows the number of references to the route. It indicates how many routes are using this particular route entry.
- Use: This field displays the number of lookups performed on this route. It indicates how many times this route has been used.
- Iface/Interface: This field specifies the network interface through which packets should be sent to reach the destination. It indicates the outgoing interface for the route.
- Scope: This field defines the scope of the route, which determines where the route is valid. Common values include:
global: The route is valid globally.link: The route is only valid on the local network segment.host: The route is valid only for the specified host.
The ip route command provides a comprehensive view of the system’s routing table, allowing administrators to understand how packets are being routed and to configure routing behavior as needed.
