PI Zero W. Another puzzler

Sep 16, 2023 Last reply: 2 years ago 21 Replies

First of all, huge thanks to all who helped me get to the bottom of the memory bug...code seems rock solid now.



Here is another 'strangeness' .



The Pi Zero W is configured to present its usb interface as an ethernet device, in order that for initial configuration, it can be plugged into a host computer which will acquire an Ethernet connection and be issued by DHCP with an address that can directly communicate with the Pi Zeros web server by issuing a command in the host computers web browser to a fixed IP address. When this works, it works perfectly.



If the host computer (HP Elite Desk, Linux MINT 20) is rebooted WITH the Pi Zero connected, it works.



If the host computer is rebooted *without* the Pi Zero connected and the Pi Zero is subsequently connected, it works.



But if the Pi Zero is disconnected and then reconnected, it fails to pick up DHCP.



The network manager app tries indefinitely to get a connection, and fails.



If the computer is told to reboot with the Pi Zero connected, it hangs. If the computer is powered off and on, it works.


This is the syslog for a *successful* connection after reboot



Sep 16 09:57:42 juliet NetworkManager[739]: <info> [1694854662.5981] dhcp4 (usb0): option dhcp_lease_time => '43200' Sep 16 09:57:42 juliet NetworkManager[739]: <info> [1694854662.5982] dhcp4 (usb0): option domain_name_servers => '172.16.21.32' Sep 16 09:57:42 juliet NetworkManager[739]: <info> [1694854662.5982] dhcp4 (usb0): option expiry => '1694897859' Sep 16 09:57:42 juliet NetworkManager[739]: <info> [1694854662.5983] dhcp4 (usb0): option host_name => 'juliet' Sep 16 09:57:42 juliet NetworkManager[739]: <info> [1694854662.5983] dhcp4 (usb0): option ip_address => '172.16.21.3' Sep 16 09:57:42 juliet NetworkManager[739]: <info> [1694854662.5983] dhcp4 (usb0): option next_server => '172.16.21.32' Sep 16 09:57:42 juliet avahi-daemon[735]: Joining mDNS multicast group on interface usb0.IPv4 with address 172.16.21.3. Sep 16 09:57:42 juliet NetworkManager[739]: <info> [1694854662.5983] dhcp4 (usb0): option requested_broadcast_address => '1' Sep 16 09:57:42 juliet avahi-daemon[735]: New relevant interface usb0.IPv4 for mDNS. Sep 16 09:57:42 juliet NetworkManager[739]: <info> [1694854662.5984] dhcp4 (usb0): option requested_domain_name => '1' Sep 16 09:57:42 juliet avahi-daemon[735]: Registering new address record for 172.16.21.3 on usb0.IPv4. Sep 16 09:57:42 juliet NetworkManager[739]: <info> [1694854662.5984] dhcp4 (usb0): option requested_domain_name_servers => '1' Sep 16 09:57:42 juliet NetworkManager[739]: <info> [1694854662.5984] dhcp4 (usb0): option requested_domain_search => '1' Sep 16 09:57:42 juliet NetworkManager[739]: <info> [1694854662.5985] dhcp4 (usb0): option requested_host_name => '1' Sep 16 09:57:42 juliet NetworkManager[739]: <info> [1694854662.5985] dhcp4 (usb0): option requested_interface_mtu => '1' Sep 16 09:57:42 juliet NetworkManager[739]: <info> [1694854662.5985] dhcp4 (usb0): option requested_ms_classless_static_routes => '1' Sep 16 09:57:42 juliet NetworkManager[739]: <info> [1694854662.5985] dhcp4 (usb0): option requested_nis_domain => '1'



But this is what happens when the device is unplugged and re plugged in..



Sep 16 09:41:53 juliet NetworkManager[737]: <info> [1694853713.4136] manager: (usb0): new Ethernet device (/org/freedesktop/NetworkManager/Devices/4) Sep 16 09:41:53 juliet NetworkManager[737]: <info> [1694853713.5013] device (usb0): interface index 4 renamed iface from 'usb0' to 'enxf62dad34f39e' Sep 16 09:41:53 juliet NetworkManager[737]: <info> [1694853713.5233] device (enxf62dad34f39e): state change: unmanaged -> unavailable (reason 'managed', sys-iface-state: 'external') Sep 16 09:41:53 juliet NetworkManager[737]: <info> [1694853713.5242] device (enxf62dad34f39e): carrier: link connected Sep 16 09:41:53 juliet NetworkManager[737]: <info> [1694853713.5263] settings: (enxf62dad34f39e): created default wired connection 'Wired connection 2' Sep 16 09:41:53 juliet NetworkManager[737]: <info> [1694853713.5267] device (enxf62dad34f39e): state change: unavailable -> disconnected (reason 'none', sys-iface-state: 'managed') Sep 16 09:41:53 juliet NetworkManager[737]: <info> [1694853713.5316] policy: auto-activating connection 'Wired connection 2' (c8d6876c-99de-3b51-b55d-c6fe727632ed) Sep 16 09:41:53 juliet NetworkManager[737]: <info> [1694853713.5319] device (enxf62dad34f39e): Activation: starting connection 'Wired connection 2' (c8d6876c-99de-3b51-b55d-c6fe727632ed) Sep 16 09:41:53 juliet NetworkManager[737]: <info> [1694853713.5320] device (enxf62dad34f39e): state change: disconnected -> prepare (reason 'none', sys-iface-state: 'managed') Sep 16 09:41:53 juliet NetworkManager[737]: <info> [1694853713.5324] device (enxf62dad34f39e): state change: prepare -> config (reason 'none', sys-iface-state: 'managed') Sep 16 09:41:53 juliet NetworkManager[737]: <info> [1694853713.5327] device (enxf62dad34f39e): state change: config -> ip-config (reason 'none', sys-iface-state: 'managed') Sep 16 09:41:53 juliet NetworkManager[737]: <info> [1694853713.5329] dhcp4 (enxf62dad34f39e): activation: beginning transaction (timeout in



45 seconds) Sep 16 09:41:59 juliet NetworkManager[737]: <info> [1694853719.5490] device (enxf62dad34f39e): state change: ip-config -> unavailable (reason 'carrier-changed', sys-iface-state: 'managed ') Sep 16 09:41:59 juliet NetworkManager[737]: <info> [1694853719.5649] dhcp4 (enxf62dad34f39e): canceled DHCP transaction Sep 16 09:41:59 juliet NetworkManager[737]: <info> [1694853719.5650] dhcp4 (enxf62dad34f39e): state changed unknown -> done

Does anyone have a clue? I don't.



What do the logs on the Pi end say? Maybe it barfs and stops replying.

Theo

I am not sure... I will try and get that info. IIRC it keeps dishing out the data and its not accepted for some reason.

A bit more googling reveals that this is not an unknown problem - the pseudo Ethernet interface is distinctly sketchy, by all accounts...

It seems that your Raspi OS is set up to provide 'predictable interface names', which changes usb0 to enx<MAC without colons>, so your Ethernet is f6:2d:ad:34:f3:9e.

The Network Manager gets confused of the naming change.

There is an option to disable the interface name change in raspi-config.

--

-TV

<parts snipped> Just including the parts relevant to my suggestion ...

There isn't enough shown from the good connection to show whether it's occurring after the interface is renamed or before it. I'm just wondering if it's not being recognized due to that, in combination with settings in the dhcp server.

Try adding the kernel boot parameter net.ifnames=0 to stop the interface being renamed.

If that fails, run wireshark on the host so you can compare what is being sent and received to/from the dhcp server.

Regards, Dave Hodgins

Tauno, that sounds promising. I will look into it.

Umm. I looked into this it it appeared to be disabled.

I am even more confused

Well I explicitly selected to disable it in the config tool and now it seems to work

Where (what file) is that config option stored?

In article <ue5711$8pt$ snipped-for-privacy@dont-email.me, The Natural Philosopher snipped-for-privacy@invalid.invalid wrote: ...

That's good. I was going to comment to that effect (that the network names thing was your issue, but others beat me to it.

The standard advice given at this point is to look at the code in /usr/bin/raspi-config. It is a shell script, and reasonably readable.

Searching around a bit, I found this function:

get_net_names() { if grep -q "net.ifnames=0" $CMDLINE || [ "$(readlink -f /etc/systemd/network/99-def ault.link)" = "/dev/null" ] ; then echo 1 else echo 0 fi }

I think that should give you the general idea. there is also a set_net_names() function in there too.

Two other comments:

1) This Orwellian termed "predictable names" thing is a real PIA. To be fair, it is probably the sort of thing that is a good thing if you a) really need it and b) can deal with the fallout. But for most people, it is just a PIA. It was added to RaspiOS a few releases back, but then when people complained about it, they made it off-by-default. So, you must be running one of the versions where it is on-by-default. 2) You might want to join the Raspberry Pi help forum and ask your questions there. I say this entirely in peaces and love - this is not a "You're off topic in my newsgroup!" flame. It is a good forum and they are very attentive to people's questions such as yours. forums.raspberrypi.com should get you there.

I'm not trying to discourage you from posting RPi questions to Usenet, but I think you'll do better there.

On a full RPi 3B added ' net.ifnames=0 biosdevname=0 ' to end of command line in /boot/cmdline.txt to get "old" interface names

This may not help of course. I don't know about Pi0.

In article <ue5dt6$1qr2$ snipped-for-privacy@dont-email.me, Chris Elvidge snipped-for-privacy@mshome.net wrote: ...

Why did you respond to a post of mine (*), rather than OP, to answer OP's question? And to basically answer it by giving half the answer I gave?

(*) And quoting the whole thing, when you were, in fact, responding to none of it...

Yeah, it is the same. It is only a function of the OS version, not of the hardware involved. RPi is very good about having the same OS for all flavors of the board.

I think c.s.raspberry-pi is a perfectly good corner of usenet in which to post Raspberry Pi questions :)

It's most useful (read pretty much essential) if there are multiple interfaces and you want to make sure they get the right static routes and firewall rules.

You're probably right. Which is about 0.000001% of users.

Which is why they were right to make it off-by-default. Those who need it, will be able to enable it.

For most people, it was: What the h*** is this???

Yeah > found thatr link but couldnt believe it

AFAIK I downloaded the latest a couple of months ago.

I found many instances of the problem there. I found no solution

As it happens I have done pretty well here so far..;-)

I think his point was that forums.raspberrypi.com might be a better places to get *answers*.

The simple way to keep the original name on USB Ethernet is to create a symlink /etc/systemd/network/73-usb-net-by-mac.link pointing to /dev/null.

Of course, the link has to be created with sudo or running as root.

It is one of the side-effects of systemd.

If I need many Ethernet interfaces on a Pi, I'll use a VLAN aware switch and put the separate ports in separate VLANS, trunked to the Pi connection. The VLANs can be accessed from the OS directly as separate virtual interfaces.

Yes. Something - presumably Raspi-config - did that. It was confusing. The NO option was highlighted in that program so I assumed that was its current state, but hitting return seems to have made it NO when it wasn't before. And a find mtime -1 revealed that that was the only likely looking file that had changed.

Only that idiot Poettering could have conceived of the idea of linking a file to /dev/null was in fact a way to configure a computer.

Well this PI has 'two, but very small' as the song says - usb0 and wlan0.

It seems perfectly simple to distinguish between them, to me.

I cant remember how they were configured - I cargo culted some script - but the issue seemed to be that dnsmasq wasnt in the end expecting to deal with the interface as it became renamed, but with usb0.

i.e. in /etc/dnsmasq.conf we have

interface=usb0 bind-dynamic domain-needed bogus-priv dhcp-range=172.16.21.1,172.16.21.5,255.255.0.0,12h

So that would explain why, if the interface was renamed at some point, the client machine couldn't get DHCP.

Oh. I just looked and that interface has now disconnected itself. Maybe the problem is still extant.

Nope. It still seems to work.

I am back to two interfaces.

I do get it that its handy to have unique Ids for disks and interfaces so that whether a disk is /dev/sda or /dev/sdb it gets mounted in the correct place....and likewise if one had a dozen usb0 1 2 3 etc Ethernet adapters ..one would want to give them some sort of unique id, but, as you say, if that is where you are going you probably have the nous to enable smart ID via MAC address anyway, without it being the default

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required