3

I'm new at the Raspi 3 and unix in general, and now trying to build a headless streaming application, and trying to automate some basic setup steps on boot.

If I want to guarantee the fastest connection speed is used for streaming, I'm just wondering if there's any benefit to turning off wlan0 if I see they're connected to eth0 already.

I guess my question is what happens when both wired and wireless connections to Internet exist? Do the connections get prioritized for speed, or do they get pooled together - or is there a possibility that the wireless would be used instead of wired ethernet?

I realize the answer might apply to all Unix flavors - and possible even Windows - but I'm specifically interested in Raspbian

dbmitch
  • 381
  • 6
  • 20

1 Answers1

6

Normally if both Ethernet and Wifi are capable of supplying an internet connection to the Raspberry Pi the one with the lowest metric (independent of the internet speed) will be the one used by the Pi to get the internet (In my personal experience eth0 always gets the lowest metric). If you want to check the metrics type route -n you would see something like :

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         100.100.100.1   0.0.0.0         UG    202    0        0 eth0
0.0.0.0         192.168.137.1   0.0.0.0         UG    303    0        0 wlan0
100.100.100.0   0.0.0.0         255.255.255.0   U     202    0        0 eth0
192.168.137.0   0.0.0.0         255.255.255.0   U     303    0        0 wlan0

In this chart you can see that eth0 has the lowest metric so the internet coming from that connection will be the one used. If you wanted to change the metric so that wlan0 becomes the one with the lowest metric then type

sudo route delete  default gateway 192.168.137.1 

and then

sudo route add  default gateway 192.168.137.1

you will see that the chart is now

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.137.1   0.0.0.0         UG    0      0        0 wlan0
0.0.0.0         100.100.100.1   0.0.0.0         UG    202    0        0 eth0
100.100.100.0   0.0.0.0         255.255.255.0   U     202    0        0 eth0
192.168.137.0   0.0.0.0         255.255.255.0   U     303    0        0 wlan0

and the internet coming from wlan0 will be the one used

VMMF
  • 470
  • 2
  • 6
  • 14
  • Perfect - thanks. I'll have a look. Is there a command I can run to determine how much data is being passed via each interface? Or does tha fact that the external IP 100.100.100.0 is using eth0, confirm that it's not using wireless? – dbmitch Jul 02 '16 at 01:08
  • 1
    About merging two internet connections i'm not sure but check: http://superuser.com/questions/330157/how-can-i-use-two-internet-connections-at-the-same-time, http://unix.stackexchange.com/questions/29317/merging-two-internet-connections-from-two-network-interfaces-in-order-to-obtain and http://forums.debian.net/viewtopic.php?f=30&t=99149 – VMMF Jul 02 '16 at 01:27
  • 1
    To determine how much data is being passed via each interface I think the command is netstat but I'm not sure if it works on Pi, please check http://unix.stackexchange.com/questions/56453/how-can-i-monitor-all-outgoing-requests-connections-from-my-machine , http://superuser.com/questions/615958/how-to-track-internet-usage-upload-download-on-linux , http://www.binarytides.com/linux-commands-monitor-network/ and http://serverfault.com/questions/195894/monitor-number-of-bytes-transferred-to-from-ip-address-on-port – VMMF Jul 02 '16 at 01:31