ip-route-list
List the kernel's routing table
TLDR
Display the main routing table
Display the main routing table (same as first example)
Display the local routing table
Display all routing tables
List routes from a given device only
List routes within a given scope
Display the routing cache
Display only IPv6 or IPv4 routes
SYNOPSIS
ip route { list | show } [ SELECTOR_OPTIONS ] [ OUTPUT_OPTIONS ]
SELECTOR_OPTIONS may include filtering by to PREFIX, dev IFACE, table ID, src ADDR, via GATEWAY, or specifying ADDRESS_FAMILY (e.g., inet, inet6).
OUTPUT_OPTIONS may include brief, details, statistics, json, pretty, exact, cached, all.
PARAMETERS
list | show
The primary command to display routing table entries. Both are equivalent and often implied if no other subcommand is given after ip route.
to PREFIX
Filters routes to a specific destination network or host (e.g., 192.168.1.0/24, default for the default route).
dev NAME
Filters routes associated with a particular outgoing network interface (e.g., eth0, wlan0).
table ID | NAME
Specifies which routing table to display. Common tables include main (the default), local, and default, or a numeric ID for custom tables.
src ADDRESS
Filters routes that use a specific source IP address for outgoing packets.
inet | inet6
Specifies the IP address family to display routes for: IPv4 (inet) or IPv6 (inet6). If omitted, inet is typically assumed.
details
Shows more verbose information for each route, including advanced attributes like protocol, metric, and flags.
statistics
Displays packet and byte count statistics for each route, useful for monitoring network traffic.
json
Outputs the routing table data in a machine-readable JSON format.
pretty
Used in conjunction with json to produce human-readable, indented JSON output.
all
Lists entries from all routing tables configured on the system, not just the main table.
exact
Requires an exact match for the specified prefix, preventing longest prefix matching behavior.
DESCRIPTION
The ip route list command is a fundamental tool within the iproute2 utility suite, used to display the IP routing table entries maintained by the Linux kernel. This table dictates how IP packets are forwarded to their intended destinations, whether local or remote. It provides a comprehensive view of the system's routing configuration, including destination networks, next-hop gateways, outgoing network interfaces, and route metrics. This command is the modern standard for network routing inspection, replacing older tools like route and netstat, and offering richer detail and filtering capabilities. Users can specify various options to filter the output, such as displaying routes for specific address families (IPv4 or IPv6), listing entries from a particular routing table, or showing detailed attributes for each route. It's an indispensable command for network configuration, troubleshooting, and diagnostics on Linux systems.
CAVEATS
Viewing detailed routing information or specific routing tables often requires root privileges. Users migrating from older net-tools (e.g., route) should note the different syntax and richer functionality of iproute2 commands. The cached option refers to the route cache, which is less significant in modern Linux kernel routing mechanisms compared to the FIB (Forwarding Information Base) lookup.
UNDERSTANDING OUTPUT FIELDS
The output of ip route list provides several key fields:
destination (e.g., 0.0.0.0/0 or default): The network or host to which the route applies. 0.0.0.0/0 or default signifies the default route for all unroutable traffic.
via GATEWAY_IP: The IP address of the next-hop gateway for packets destined to the specified network.
dev INTERFACE_NAME: The local network interface through which packets leave the system to reach the destination or gateway.
proto KERNEL_PROTOCOL: Indicates how the route was installed (e.g., kernel for routes automatically configured, static for manually added routes, dhcp, bgp, etc.).
scope SCOPE_TYPE: Defines the visibility and reachability of the route (e.g., global for internet-routable, link for directly connected, host for local addresses).
metric METRIC_VALUE: A numerical value indicating the cost of the route; lower values are generally preferred.
POLICY ROUTING
Beyond the basic routing table (main), Linux kernels support multiple routing tables for policy routing. ip route list allows inspecting these tables using the table option. This feature enables complex routing decisions based on source address, application, and other criteria, going beyond simple destination-based routing.
HISTORY
The iproute2 utility suite, which includes ip route list, was developed by Alexey Kuznetsov starting in the late 1990s. It was designed as a modern replacement for the older net-tools utilities (like route and netstat), which relied on the less efficient ioctl interface. iproute2 leverages the Netlink socket interface, providing a more robust, extensible, and efficient method for interacting with the Linux kernel's networking stack. This shift enabled richer features such as policy routing and detailed traffic control, making ip route list the standard and preferred command for routing table inspection in modern Linux distributions.