Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

running two nodes = duplicate hostname/dns name on DHCP server #167

Closed
ikonia opened this issue Mar 28, 2023 · 6 comments · Fixed by #218
Closed

running two nodes = duplicate hostname/dns name on DHCP server #167

ikonia opened this issue Mar 28, 2023 · 6 comments · Fixed by #218

Comments

@ikonia
Copy link

ikonia commented Mar 28, 2023

I've got 2 enviro local on the same wlan, the dhcp see's them both ask for addresses and updates dns successfully, however both of them have the same default hostname that doesn't seem to be able to be changed
eg:
DHCPDISCOVER from 28:c1:05:02:9d (PYBD) via enp2s0
DHCPDISCOVER from 28:c1:05:22:82 (PYBD) via enp2s0

is there anyway to get them to identify themselves differently.

I'm also not sure if this is causing any problems in terms of wifi stability either due to conflicting FQDN as dhcp will also update DDNS with FQDN from dhcp requests.

@ikonia
Copy link
Author

ikonia commented Apr 23, 2024

this is confirmed causing a problem, as DDNS is unable to handle duplicate hostnames and as such will refuse to offer an IP address if the forward map cannot be set.

@Gadgetoid
Copy link
Member

Gadgetoid commented Apr 23, 2024

Which part of the above is the hostname?

Looks like a fix is possible downstream- micropython/micropython#10635

I guess we could change the hostname to include part of the Pico's UUID. Something like (note: ⚠️ test this in a REPL first I don't know what format UUID will be in!):

UUID = machine.unique_id()
machine.hostname(f"enviro{UUID[-4:]}")

You might be able to make this change early in your board's main.py and see if it accomplishes what we'd want it to.

edit: I guess this gives us a clue:

enviro/enviro/helpers.py

Lines 27 to 28 in b5bff82

def uid():
return "{:02x}{:02x}{:02x}{:02x}{:02x}{:02x}{:02x}{:02x}".format(*machine.unique_id())

@ikonia
Copy link
Author

ikonia commented Apr 23, 2024

the hostname being advertised by the network interface is "PYBD" so in essence 2 devices are called PYBD

I was looking to mirror the 'nickname' set in the setup interface into the hostname parameter, but on the current platform I couldn't see a possible way to do it.

Gadgetoid added a commit that referenced this issue Apr 23, 2024
(Attempt to) make the hostname unique per board, by using the last
four chars of the unique ID (flash chip ID) as a suffix.

Fixes #167
@Gadgetoid
Copy link
Member

the hostname being advertised by the network interface is "PYBD"

Weird, I thought ours was always configured to be PicoW but it could be broken or non-functional in an older build.

I was looking to mirror the 'nickname' set in the setup interface into the hostname parameter

I'd wondered, this should be doable but needs some changes and a good place to put the hostname wrangling. I added some basic disambiguation here - 33ab1a2

Test builds for that change- and all the other networking fixes, and a much newer build of MicroPython - are available here: https://github.com/pimoroni/enviro/actions/runs/8803662645

@sjefferson99
Copy link
Contributor

@Gadgetoid As my board is misbehaving on my custom branch code, I've flashed it with this UF2 to properly test the new firmware and wifi updates. I can confirm that now I've taken my MAC reservation off the DHCP server I immediately get a hostname of EnviroW-7822.

Assuming you have picked the end of the UUID that is likely to change most (I have no idea how it's allocated to the flash chip), then this looks to be successful. Providing no one else finds they have the same suffix, this should be enough for the use case.

@Gadgetoid
Copy link
Member

Assuming you have picked the end of the UUID that is likely to change most

I don't know for sure, but I think it's convention to have the bit that changes most on the right.

I think this is safer, and easier to implement without extensive testing, than taking user input as the hostname. Though the latter is still possible.

Gadgetoid added a commit that referenced this issue Apr 24, 2024
(Attempt to) make the hostname unique per board, by using the last
four chars of the unique ID (flash chip ID) as a suffix.

Fixes #167
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants