ip-route-get
performs a route lookup and displays exactly which route the kernel would use
TLDR
SYNOPSIS
ip route get [fibmatch] ADDRESS [from ADDRESS] [iif DEV] [oif DEV] [mark MARK] [tos TOS] [vrf NAME] [ipproto PROTOCOL] [sport NUMBER] [dport NUMBER] [connected]
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. It is equivalent to sending a packet along this path, but no packets are actually sent. Without iif, the kernel resolves a route for locally generated output; with iif, it pretends a packet arrived on that interface and looks for a forwarding path.
PARAMETERS
fibmatch
Return the full FIB lookup matched route instead of the resolved destination entryto ADDRESS
Destination address (the to keyword is optional)from SOURCE
Source address for route lookupiif DEVICE
Input interface (for forwarded packets)oif DEVICE
Force output interfacetos, dsfield TOS
Type of Service valuevrf NAME
VRF instance namemark MARK
Firewall mark (fwmark) valueipproto PROTOCOL
IP protocol as seen by the route lookupsport NUMBER, dport NUMBER
Source and destination port as seen by the route lookupconnected
If no from is given, redo the lookup with the source set to the preferred address from the first lookup
INSTALL
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. Using iif requires IP forwarding to be enabled, otherwise the lookup may fail.
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)
