How do you check which interface and IP your machine will use to reach a destination?
BeginnerConceptIP Addressing, CIDR, Subnetting & Routing
Answer
Use ip route get. It reports the next hop, outgoing device and chosen source address.
ip route get 8.8.8.8
# 8.8.8.8 via 10.0.1.1 dev eth0 src 10.0.1.23 uid 1000
Combine with ip -br addr for a one-line-per-interface view.
More on IP Addressing, CIDR, Subnetting & Routing
What is an IPv4 address and how is it structured?BeginnerWhat are the private IPv4 ranges (RFC 1918)?BeginnerWhat is CIDR notation?BeginnerHow many usable hosts are in a /24, and why minus two?BeginnerSubnet 10.0.0.0/16 into /24 subnets. How many do you get and what are the first three?IntermediateGiven 172.16.37.200/21, what is the network address, broadcast and range?Intermediate