If your machine has multiple interfaces (which I assume), there is no one interface that will be used for connecting to the internet.
Depending on the destination you are connecting to, your system will consult the ip table (the one shown when you do
route command) to find the next hope/router, when it does find one, it will use the interface associated with it.
That said, please refer to @torgeir's answer as it does exactly that:
- Given a domain (hardcoded as google.com, which is the only bad point in the answer)
- Resolves it's ip
- Consults the ip table for the route to use (and hence the interface).