0

I'm using a usb to ethernet with my Raspberry Zero W but it doesn't get any IP (usb0 interface):

rogermiranda1000@raspberrypi:~ $ ifconfig
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 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

usb0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether 36:33:e3:ba:6f:72  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.3.123  netmask 255.255.255.0  broadcast 192.168.3.255
        inet6 fe80::ba27:ebff:fe45:e9e5  prefixlen 64  scopeid 0x20<link>
        ether b8:27:eb:45:e9:e5  txqueuelen 1000  (Ethernet)
        RX packets 380  bytes 47826 (46.7 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 155  bytes 22392 (21.8 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

On /etc/network/interfaces I have this:

source-directory /etc/network/interfaces.d


auto usb0
iface usb0 inet dhcp

auto wlan0
allow-hotplug wlan0
iface wlan0 inet dhcp
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

iface default inet dhcp

If I use ifup here's the output:

rogermiranda1000@raspberrypi:~ $ sudo ifup usb0
Internet Systems Consortium DHCP Client 4.4.1
Copyright 2004-2018 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/

Listening on LPF/usb0/36:33:e3:ba:6f:72
Sending on   LPF/usb0/36:33:e3:ba:6f:72
Sending on   Socket/fallback
DHCPDISCOVER on usb0 to 255.255.255.255 port 67 interval 4
DHCPDISCOVER on usb0 to 255.255.255.255 port 67 interval 11
DHCPDISCOVER on usb0 to 255.255.255.255 port 67 interval 12
DHCPDISCOVER on usb0 to 255.255.255.255 port 67 interval 10
DHCPDISCOVER on usb0 to 255.255.255.255 port 67 interval 15
DHCPDISCOVER on usb0 to 255.255.255.255 port 67 interval 9
No DHCPOFFERS received.
No working leases in persistent database - sleeping.

If it's useful, here's dmesg output:

rogermiranda1000@raspberrypi:~ $ dmesg | grep usb0
[    8.421372] usb0: HOST MAC 32:f0:31:6c:f5:94
[    8.424389] usb0: MAC 36:33:e3:ba:6f:72

I have also tried to configure a static IP. In that case the IP is OK, but I couldn't ping the device.

Edit:

ethtool result (but according to the product description it's a "driver-free adapter"):

rogermiranda1000@raspberrypi:~ $ sudo ethtool -i usb0
driver: g_ether
version: 29-May-2008
firmware-version: 20980000.usb
expansion-rom-version:
bus-info: gadget
supports-statistics: no
supports-test: no
supports-eeprom-access: no
supports-register-dump: no
supports-priv-flags: no

ip result:

rogermiranda1000@raspberrypi:~ $ ip a && ip r
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group defaul                                                                                                                                                                                                                                                                     t 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
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: usb0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen                                                                                                                                                                                                                                                                      1000
    link/ether fe:eb:bb:8e:64:77 brd ff:ff:ff:ff:ff:ff
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP g                                                                                                                                                                                                                                                                     roup default qlen 1000
    link/ether b8:27:eb:45:e9:e5 brd ff:ff:ff:ff:ff:ff
    inet 192.168.3.123/24 brd 192.168.3.255 scope global dynamic wlan0
       valid_lft 43160sec preferred_lft 43160sec
    inet6 fe80::ba27:ebff:fe45:e9e5/64 scope link
       valid_lft forever preferred_lft forever
default via 192.168.3.1 dev wlan0
192.168.3.0/24 dev wlan0 proto kernel scope link src 192.168.3.123
  • Is your usb to ethernet connected to a domestic router or switch ? What the output means is that no DHCP offers are received, so this could possibly be a firewall issue, but it's more likely that the device at the other hand is not running a DHCP server. – Kate Jan 03 '22 at 19:34
  • it's on a switch, but it should have connection to the dhcp server – Roger Miranda Perez Jan 03 '22 at 19:36
  • If you type `ifconfig` I guess the TX counter has increased but the RX counter is still at zero, right ? – Kate Jan 03 '22 at 19:41
  • Both TX and RX stay at 0. Connecting it directly to the router doesn't work either. – Roger Miranda Perez Jan 03 '22 at 19:45
  • Not sure but I'm thinking about a driver issue then. If you have the ethtool installed you could try: `sudo ethtool -i usb0`. Another suggestion: run `sudo tail -f /var/log/messages`, and then plug the device and see if errors are reported. You can update your question with results. – Kate Jan 03 '22 at 20:08
  • According to the product description it's a "driver-free adapter" – Roger Miranda Perez Jan 03 '22 at 20:21
  • I have attached ethtool's result – Roger Miranda Perez Jan 03 '22 at 21:14

1 Answers1

1

I am continually amazed by the things people put into /etc/network/interfaces.

It hasn't been used by Raspberry Pi OS for 7 years, and what you have would not have been correct even then!

Your /etc/network/interfaces will disable the default dhcpcd networking. Either delete your changes or just delete /etc/network/interfaces (which by default does NOTHING).

See How to set up networking/WiFi

This may not fix your problem, but it won't make it any worse. If it still doesn't work post the output of ip a && ip r

Your question mentions g_ether, but this should not be necessary for a USB Ethernet dongle. It is possible you have made other changes, but not elaborated.

Milliways
  • 54,718
  • 26
  • 92
  • 182
  • Done. I have deleted everything from `/etc/network/interfaces` except the wlan0 interface (if I remove it completely it doesn't login into my Wifi) – Roger Miranda Perez Jan 03 '22 at 23:51
  • @RogerMirandaPerez **Raspberry Pi OS** DOES NOT use /etc/network/interfaces so nothing is needed. Your question contains little information about which OS or what you have done. You need to explain, but if you include `dhcp` in interfaces you will break normal networking. – Milliways Jan 03 '22 at 23:57
  • even removing everything usb0 doesn't get any IP – Roger Miranda Perez Jan 04 '22 at 00:02