LinuxCommandLibrary

ip-route-get

TLDR

Print route to destination

$ ip route get [1.1.1.1]
copy
Print route from a specific source
$ ip route get [destination] from [source]
copy
Print route for packets arriving on a specific interface
$ ip route get [destination] iif [eth0]
copy
Print route forcing output through specific interface
$ ip route get [destination] oif [eth0]
copy
Print route with Type of Service
$ ip route get [destination] tos [0x10]
copy
Print route using VRF instance
$ ip route get [destination] vrf [myvrf]
copy

SYNOPSIS

ip route get destination [options]

DESCRIPTION

ip route get performs a route lookup and displays exactly which route the kernel would use for a given destination. This shows the complete route entry including gateway, interface, source address, and any other attributes.
Unlike ip route list, which shows stored routes, ip route get queries the kernel's routing decision for a specific packet, accounting for policy routing rules and route selection algorithms.

PARAMETERS

from SOURCE

Source address for route lookup
iif DEVICE
Input interface (for forwarded packets)
oif DEVICE
Force output interface
tos TOS
Type of Service value
vrf NAME
VRF instance name
mark MARK
Firewall mark value

CAVEATS

The output reflects the current routing state, which may change dynamically. VRF lookups require the VRF to be configured. Mark-based lookups require matching policy rules.

HISTORY

ip route get is part of iproute2 and provides insight into the kernel's actual routing decisions, which can differ from the stored route table due to policy rules and route metrics.

SEE ALSO

ip(8), ip-route(8), ip-route-list(8), ip-rule(8)

Copied to clipboard