Wednesday, May 11, 2016

Figuring out which internet connection is being used

Now that fiber connections are more widely available (including in my house) sometimes I will plug my laptop in to a wired connection so that I can take advantage of the higher speeds. For general browsing and listening to music it doesn't make much difference whether I am on wifi or wired in, but when transferring large amounts of data, it can make a big difference. But when I plug in the wired connection, do I need to disconnect my wifi to ensure I am using the connection? How do I tell which connection is being used? The answer is found with the Linux tools route and traceroute.

First we look at the route that will be taken to get to our destination. To find out what route will be taken, type

traceroute someaddress.com

This will return a list of hops that your data packet must take to reach its destination. While the output from this tool is can be a fascinating look at the winding path of your data, we are really only interested in the first line, which in my case looks like this:

1  10.0.1.1 (10.0.1.1)  0.454 ms  0.437 ms  0.428 ms

This tells me that the first hop is from my laptop to 10.0.1.1. Now I can the route tool to determine which internet connection is going to this location. I type

route

and the output tells me

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         10.0.1.1        0.0.0.0         UG    100    0        0 eth0
default         192.168.0.88    0.0.0.0         UG    600    0        0 wlan0
10.0.1.0        *               255.255.255.0   U     100    0        0 eth0
link-local      *               255.255.0.0     U     1000   0        0 virbr0
192.168.0.0     *               255.255.255.0   U     600    0        0 wlan0
192.168.122.0   *               255.255.255.0   U     0      0        0 virbr0


Again, I am only interested in the first few rows. You can see that I have a default route going to the gateway 10.0.1.1, and the Use Iface column tells me that this uses the eth0 interface, which is my wired connection. (The wlan0 is my wifi, and the virbr0 is a virtual bridge, in case anyone is curious).

So connections to the someaddress.com website (which is a stand-in for anything real I would use there) run through the 10.0.1.1 gateway over the wired eth0 connection, and I don't need to worry about disconnecting my wifi to ensure that I get high speed for my download.

No comments:

Post a Comment