If you are connected to VPN or have multiple network interfaces on your machine, and want to see what route is the machine using, to which interface run:
ip route get IP_ADDRESS
BashThis will output in following format showing the interface and gateway:
# ip route get 127.0.0.1
local 127.0.0.1 dev lo src 127.0.0.1 uid 0
cache <local>
# ip route get 8.8.8.8
8.8.8.8 via 192.168.8.1 dev enp0s13f0u1u2u1 src 192.168.8.167 uid 0
cache
BashUseful resources:
- IP Route man page – https://www.man7.org/linux/man-pages/man8/ip-route.8.html
- IP man page – https://linux.die.net/man/8/ip