↑ ↓ select, Enter open, Esc close

Find the route and source IP for a destination

Adjust the values, the command updates live
user@server
ip route get 1.1.1.1

Asks the kernel routing table how a packet to the given address would be sent. The output names the gateway (via), interface (dev) and the source address used (src). Especially useful on servers with multiple IPs, for example to check which address mail or API calls leave the server with.

Note: For IPv6, simply specify an IPv6 address as the destination.

Also searched as

  • which ip does my server use for outgoing traffic
  • ip route get example
  • find outgoing interface for destination

Related one-liners

All in Network

Read first, then run.

The commands on myline.de act directly on servers, files and databases. A wrong path or placeholder can delete data irreversibly or make a server unreachable.

  • All commands are provided without warranty and are not tested on every system.
  • Understand what a command does before running it, and check every placeholder.
  • Make a backup first and, if possible, try it on a test system.
  • You run commands at your own risk. Liability for damages is excluded to the extent permitted by law.