When you have two or more interfaces you want to know what is the default interface used to connect outside world. Here are the commands to help you found the default outbound interface and ip address.

To list all your interfaces

ip a

ip route command is part of iproute2 suite of tools for IP management, ip route provides management tools for displaying routes or the routing cache, adding routes, deleting routes, modifying existing routes, and fetching a route and clearing an entire routing table or the routing cache.

Its simulating a request for the specified destination, ip route get causes the routing selection algorithm to be run.

ip route get

This will print via dev wlan0  src

In this is gateway ip wlan0 is interface name interface address

To get outbound ip address

ip route get | awk 'NR == 1 {print $NF}'

To get outbound interface name

ip route get | awk 'NR == 1 {print $5}'
Previous article Adblock using pi-hole
Next article How to install NodeJS