Enable (or check) if a USB-RJ45 adapters is working or not?

Maybe a stupid question.

On my RPi zero w I have both the wlan and micro-USB to rj45 adapter active, but since my router reports it as wlan device, I think the eth adapter is not working (maybe I’ve to enable it in DietPI the driver is not on by default?). So if I turn off the Wi-Fi on the RPi, and the adapter isn’t working, how can I reconnect to the RPi? :rofl:

I already tried in the network options of DietPI-config and is listed only the Wi-Fi (Ethernet not present), but maybe it shows as USB device?

I don’t know how these USB OTG devices work in DietPI and if they’re already enabled or is not compatible.

What does the system see?
lsusb; lsmod; ip link; ip addr

root@Homebridge:~# lsusb; lsmod; ip link; ip addr
Bus 001 Device 002: ID 0b95:772b ASIX Electronics Corp. AX88772B
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Module                  Size  Used by
ax88796b               16384  1
asix                   36864  0
brcmfmac              307200  0
brcmutil               20480  1 brcmfmac
sha256_generic         16384  0
libsha256              16384  1 sha256_generic
cfg80211              778240  1 brcmfmac
rfkill                 32768  4 cfg80211
raspberrypi_hwmon      16384  0
uio_pdrv_genirq        16384  0
uio                    20480  1 uio_pdrv_genirq
fixed                  16384  0
fuse                  126976  1
ip_tables              28672  0
x_tables               36864  1 ip_tables
ipv6                  491520  20
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DORMANT group default qlen 1000
    link/ether b8:27:eb:8a:52:21 brd ff:ff:ff:ff:ff:ff
3: eth0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
    link/ether 00:0e:c6:8e:d5:ea brd ff:ff:ff:ff:ff:ff
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
2: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether b8:27:eb:8a:52:21 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.5/24 brd 192.168.1.255 scope global wlan0
       valid_lft forever preferred_lft forever
3: eth0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether 00:0e:c6:8e:d5:ea brd ff:ff:ff:ff:ff:ff

eth0: state DOWN

At least now it’s available from the network tool (dietpi-config), I tried to put it ON, assigned an IP, rebooted but now I can’t ssh in to the rpi. If I disconnet the network adapter, reboot, it’s discoverable and I can use ssh via wlan.

Maybe I have to turn the wifi OFF, but if -after the reboot- it doesn’t come up, how I can reconnect to it? :thinking: if I put out the sd card, is there an option to switch back to wifi and disable the eth inside the /boot config.txt or somewhere in the sd card? :thinking: or a way to set the priority to ethernet and if it fails switch to wlan?

thanks

You can assign a metric to the interface, lower metric has higher priority.
https://unix.stackexchange.com/questions/413031/changing-the-metric-of-an-interface-permanently

Thanks, I don’t understand well, now it’s

root@Homebridge:~# cat /etc/network/interfaces
# Location: /etc/network/interfaces
# Please modify network settings via: dietpi-config
# Or create your own drop-ins in: /etc/network/interfaces.d/

# Drop-in configs
source interfaces.d/*

# Ethernet
allow-hotplug eth0
iface eth0 inet static
address 192.168.1.6
netmask 255.255.255.0
gateway 192.168.1.2
#dns-nameservers 192.168.1.4

# WiFi
allow-hotplug wlan0
iface wlan0 inet static
address 192.168.1.5
netmask 255.255.255.0
gateway 192.168.1.2
#dns-nameservers 192.168.1.4
wireless-power off
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

and it should become:

# Ethernet
allow-hotplug eth0
iface eth0 inet static
address 192.168.1.6
netmask 255.255.255.0
gateway 192.168.1.2
#dns-nameservers 192.168.1.4
post-up /sbin/ip route add default via 192.168.1.1 dev eth0 metric 30
post-down /sbin/ip route del default via 192.168.1.1 dev eth0 metric 30

# WiFi
allow-hotplug wlan0
iface wlan0 inet static
address 192.168.1.5
netmask 255.255.255.0
gateway 192.168.1.2
#dns-nameservers 192.168.1.4
post-up /sbin/ip route add default via 192.168.1.1 dev wlan0 metric 10
post-down /sbin/ip route del default via 192.168.1.1 dev wlan0 metric 10
wireless-power off
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

even if not ideal but it should be possible to have both Ethernet as well as WiFi available same time (with different IP address). At least it is working on my RPi3B+ with the 2 onboard adaptor.

root@DietPi3:~# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether b8:27:eb:d6:61:4a brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.12/24 brd 192.168.0.255 scope global dynamic eth0
       valid_lft 86281sec preferred_lft 86281sec
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether b8:27:eb:83:34:1f brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.70/24 brd 192.168.0.255 scope global dynamic wlan0
       valid_lft 86296sec preferred_lft 86296sec
root@DietPi3:~#

Then why if I reboot using wlan (192.168.5) and eth (192.168.6)… I can’t reach the rpi? To be honest, on my lan I found the rpi with the wlan IP (.5), but I can’t ssh in to it, I don’t know how to reach it. Only way it’s detach the usb-eth adapter and reboot.

We’d need to see the configuration in /etc/network/interfaces to have an idea what are you applying there.

usually there is no need to do anything in /etc/network/interfaces as this file is managed by dietpi-config. Custom configurations should go to the configuration file directory /etc/network/interfaces.d

I posted my config 3 messages above your :smiley: (with also the config to change the set the order priority, but I’m not sure it’s correct): Enable (or check) if a USB-RJ45 adapters is working or not? - #5 by giuliomagnifico

IDK if this is the correct gateway in the post-up and post-down statements? Earlier it’s 192.168.1.2.
What is the purpose of using the post-up and post-down commands? It just means to add a gateway with a metric after the interface is up. But what is the advantage of doing it this way?
And when I look into the manpage it should be:

# Ethernet
allow-hotplug eth0
iface eth0 inet static
address 192.168.1.6
netmask 255.255.255.0
gateway 192.168.1.2
#dns-nameservers 192.168.1.4
metric 30

# WiFi
allow-hotplug wlan0
iface wlan0 inet static
address 192.168.1.5
netmask 255.255.255.0
gateway 192.168.1.2
#dns-nameservers 192.168.1.4
metric 10
wireless-power off
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

which means the wifi interface is prefered, when available?

As the other my posts, -I don’t know why- again this was not my fault but a fault (or not compatible) usb-rj45 adapter :rofl:

I bought (well, ordered from amazon) another adpter and this one works perfectly at the first reboot! And as Joulinar said: the rpi could be used with both wlan and eth enabled (with two ip), now I can safely disable the wifi (what a luck that I didn’t do it before with the incompatible adpter !! I’d still be here freaking out how to connect to my rpi zero :rofl: )

root@Homebridge:~# cat /etc/network/interfaces
# Location: /etc/network/interfaces
# Please modify network settings via: dietpi-config
# Or create your own drop-ins in: /etc/network/interfaces.d/

# Drop-in configs
source interfaces.d/*

# Ethernet
allow-hotplug eth0
iface eth0 inet static
address 192.168.1.5
netmask 255.255.255.0
gateway 192.168.1.2
#dns-nameservers 192.168.1.4

# WiFi
allow-hotplug wlan0
iface wlan0 inet static
address 192.168.1.7
netmask 255.255.255.0
gateway 192.168.1.2
#dns-nameservers 192.168.1.4
wireless-power off
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf




jappish thanks for the reply, I’ve just found the solution as you probably already noticed :rofl: I don’t know if your solution would have worked with the faulty adapter :thinking:

This was more a question of mine than a notice to solve your problem :slight_smile:
But I’m glad your network is working now with the new adapter!