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 get ADDRESS [ from ADDRESS ] [ iif STRING ] [ oif STRING ] [ tos TOS ] [ vrf NAME ] [ connected ] [ fibmatch ]
PARAMETERS
ADDRESS
The destination IP address to look up.
from ADDRESS
The source IP address to use for the lookup.
iif STRING
The incoming interface name to use for the lookup. If specified, lookup only valid for packets entering through this interface.
oif STRING
The outgoing interface name to use for the lookup. If specified, the lookup considers routes only leaving the selected interface.
tos TOS
The Type of Service (TOS) value to use for the lookup.
vrf NAME
The VRF (Virtual Routing and Forwarding) instance to use for the lookup.
connected
Forces the command to look for a directly connected route, ignoring non-connected routes. Will only work with a valid iif.
fibmatch
Requests fib_rules lookup for destination, by default all rules are bypassed.
DESCRIPTION
The `ip route get` command is a powerful tool for querying the kernel's routing table. It allows you to determine the path that packets will take to reach a specific destination IP address. It provides details about the route, including the source address used, the gateway, the interface, and any relevant routing rules or policy routing settings. This is invaluable for troubleshooting network connectivity issues, understanding routing behavior, and verifying network configurations. The command can be used to simulate packet delivery by providing a destination IP address and other optional parameters (like source IP address or interface) and shows how the system would attempt to route the packet. It's an integral part of the `iproute2` suite, a collection of utilities for managing network interfaces, routing, and tunneling on Linux systems.
EXAMPLE USAGE
To find the route to 8.8.8.8:
ip route get 8.8.8.8
To find the route to 192.168.1.1 using source address 10.0.0.1:
ip route get 192.168.1.1 from 10.0.0.1