When sending network packets, your computer selects a network interface based on the address it's sending the packet to, and the routing table.
Normally you will run the DHCP protocol to auto-configure your "main" interface and from this your computer will learn that it has a connection to the entire Internet through some router, and it will learn the address of that router. You can also specify the address of this router manually. The setting is usually called "default gateway" - I don't know whether Ubuntu also calls it that.
This information goes into the routing table which can be viewed with the ip route
command. Your typical home computer will have a couple of specific routes for specific address ranges reflecting the networks it's directly connected to, telling it to send packets destined to those addresses directly to those networks, and then an entry for 0.0.0.0/0
which reflects the entire Internet, telling it to send packets destined for any address to your home router. More specific routes take priority, so 0.0.0.0/0
(the least specific route possible) does not include those directly connected networks that have specific entries.
If more than one interface uses DHCP or has a default gateway configured, you'll have more than one 0.0.0.0/0
entry in your routing table, and one is chosen arbitrarily (based on some kind of interface properties, and it's never the one you want) so you might want to unconfigure the ones you don't want to use.