Garu94
Posts: 8
Joined: Wed Dec 04, 2019 7:14 pm

Raspberry Pi Zero W: how to connect to ethernt with more priority than wifi?

Sat Dec 07, 2019 2:48 pm

Hi,
I setup my Pi Zero W to connect automatically to wifi at boot, providing a wpa_supplicant.conf with my Wifi creadentials and editing config.txt and cmdline.txt in boot folder. So far everything works fine.
Now, I bought a microUSB-Ethernet adaptor and, when I run ifconfig, I can see eth0 device. How could I make the Pi connect to ethernet over wifi by default?


Garu94
Posts: 8
Joined: Wed Dec 04, 2019 7:14 pm

Re: Raspberry Pi Zero W: how to connect to ethernt with more priority than wifi?

Tue Dec 10, 2019 10:20 am

Hi, I tried but it didn't work.
My ifconfig is showing this:

Code: Select all

eth0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether 00:00:10:02:61:c1  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 328  bytes 57720 (56.3 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 328  bytes 57720 (56.3 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

usb0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether aa:f0:01:fb:2e:96  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.6  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::eced:8cdb:aa69:51be  prefixlen 64  scopeid 0x20<link>
        ether b8:27:eb:44:59:53  txqueuelen 1000  (Ethernet)
        RX packets 32244  bytes 26504102 (25.2 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 21953  bytes 11693635 (11.1 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
Should I refer to usb0 or eth0 when editing dhcpcd.conf, given that I am connecting through a usb hub?

pcmanbob
Posts: 7974
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Raspberry Pi Zero W: how to connect to ethernt with more priority than wifi?

Tue Dec 10, 2019 4:00 pm

It does not look like you have an network connection on eth0 or usb0 ,

do you have a cable plugged in to your usb Ethernet adaptor and router ?
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

Garu94
Posts: 8
Joined: Wed Dec 04, 2019 7:14 pm

Re: Raspberry Pi Zero W: how to connect to ethernt with more priority than wifi?

Wed Dec 11, 2019 2:45 pm

Yes, I did plug my cable in both the router and the adaptor. Is there anyway I need to configure on Raspberry Pi to "activate" this connection? As soon as I can, I will also try with the same port and cable I am using on my desktop to isolate the problem.

pcmanbob
Posts: 7974
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Raspberry Pi Zero W: how to connect to ethernt with more priority than wifi?

Wed Dec 11, 2019 3:24 pm

So the first question is does you pi recognised the USB networking device correctly ?

So you can test this for yourself,
Does it enumerate?
If a device doesn't work, then the first step is to see if it is detected at all. There are two commands that can be entered into a terminal for this: lsusb and dmesg. The first will print out all devices attached to USB, whether they are actually recognised or not, and the second will print out the kernel message buffer (which can be quite big after booting: try doing sudo dmesg -C then plug in your device and retype dmesg to see new messages).
quote taken from here : https://www.raspberrypi.org/forums/view ... hp?t=53832
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

Garu94
Posts: 8
Joined: Wed Dec 04, 2019 7:14 pm

Re: Raspberry Pi Zero W: how to connect to ethernt with more priority than wifi?

Thu Dec 12, 2019 1:14 pm

https://imgur.com/a/l8P9YJv
This is the output of dmesg, so it seems it is recognised properly as Ethernet gadget. From here, how should I use it? Am I missing something from config.txt or cmdline.txt in /boot partition maybe?

pcmanbob
Posts: 7974
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Raspberry Pi Zero W: how to connect to ethernt with more priority than wifi?

Thu Dec 12, 2019 4:00 pm

So with your USB Ethernet device connected to the pi and the cable connected between the USB device and the router/switch , do you get any lights to show there is a connection on the router/switch end or the USB end ?

assuming pi is powered and booted.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

Garu94
Posts: 8
Joined: Wed Dec 04, 2019 7:14 pm

Re: Raspberry Pi Zero W: how to connect to ethernt with more priority than wifi?

Thu Dec 12, 2019 7:19 pm

Oh guys, I think I am *******k now, I just realized the cable wasn't fully plugged into the router.... Sorry for wasting your time so far.
Now I have two different local IP, so I think this means the Pi is getting connection from both router and wifi. Given the lower metrics when running "route -n", I think I should already be on ethernet connection by default. Thank you and sorry again for my dumbness

pcmanbob
Posts: 7974
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Raspberry Pi Zero W: how to connect to ethernt with more priority than wifi?

Thu Dec 12, 2019 9:07 pm

Garu94 wrote:
Thu Dec 12, 2019 7:19 pm
Oh guys, I think I am stupid as fuck now, I just realized the cable wasn't fully plugged into the router.... Sorry for wasting your time so far.
Now I have two different local IP, so I think this means the Pi is getting connection from both router and wifi. Given the lower metrics when running "route -n", I think I should already be on ethernet connection by default. Thank you and sorry again for my dumbness
:lol: :lol: :lol:

Well we all make silly mistakes at some point, don't worry about it, glad you now have you wired connection working.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

Return to “Beginners”