ip-route-get
Get route to destination address
TLDR
Print route to a destination
Print route to a destination from a specific source address
Print route to a destination for packets arriving on a specific interface
Print route to a destination, forcing output through a specific interface
Print route to a destination with a specified Type of Service (ToS)
Print route to a destination using a specific VRF (Virtual Routing and Forwarding) instance
SYNOPSIS
ip [route|rt] get [ OPTIONS ] TO-ADDRESS
PARAMETERS
from PREFIX
Match source address prefix
to PREFIX
Match destination prefix (alternative to positional arg)
tos TOS
Type-of-Service value
iif STRING
Incoming device name
oif STRING
Outgoing device name
mark MARK
Firewall mark value
table TABLE-ID
Routing table ID or name
protocol PROTO
Route protocol (e.g., static, bgp)
scope SCOPE
Route scope (global, link, host)
type TYPE
Route type (unicast, local, blackhole)
src PREFIX
Source address prefix
metric NUMBER
Route metric
fromdev
Match source device only
dev STRING
Device name constraint
vrf NAME
VRF name
uidrange ID-ID
UID range for owner matching
fibmatch
Strict FIB lookup
mdst MDST
Modified DST lookup
approx
Approximate lookup
limit LIMIT
Limit recursion depth
maxdepth DEPTH
Maximum recursion depth
DESCRIPTION
The ip route get command performs a route lookup in the kernel routing table for a specified destination address, simulating how a packet would be routed without actually sending it. It outputs detailed information about the selected route, including the output interface, source IP address, gateway (next hop), priority, and any policy routing details used.
This is invaluable for network troubleshooting, verifying routing decisions, testing policy-based routing (PBR), and understanding FIB (Forwarding Information Base) selections. It respects routing tables, realms, multipath routes, and rules from ip rule. For example, running ip route get 8.8.8.8 might show:
8.8.8.8 via 192.168.1.1 dev eth0 src 192.168.1.100 uid 1000
cache
Options allow specifying source (from), input/output interfaces (iif, oif), TOS, marks, VRFs, and more, enabling precise simulation of packet contexts. It supports IPv4 and IPv6 seamlessly.
CAVEATS
Does not alter routing tables; output reflects current kernel state. IPv6 requires address in [::1] format if scoped. Multipath routes show one nexthop randomly. No packet transmission occurs.
OUTPUT FORMAT
Shows route as DEST via GATEWAY dev IFACE src SRC [flags], followed by cache or error if no route.
EXAMPLES
ip route get 8.8.8.8 from 192.168.1.100 iif lo
ip -6 route get 2001:db8::1 vrf red
HISTORY
Part of iproute2 suite, developed by Alexey Kuznetsov starting 1996-1999 as replacement for deprecated route command. ip route get added early for policy routing support in Linux 2.2+. Enhanced in 2.6+ kernels for VRFs, marks, and FIB matching.


