openzfs/openzfs-docs

NixOS: add option for more than 3 udhcpc retries when ssh unlocking boot

mariaa144 opened this issue · 5 comments

I tried to setup sshUnlock using the guide but I couldn't figure out how to connect using ssh. Specifically, I couldn't ping the host and ssh would return sh: connect to host 192.168.99.47 port 22: No route to host. I am using DHCP and I believe the IP is correct.

Is it possible to get some logging for initrd? How should I go about troubleshooting the issue? How can I verify DHCP is setup correctly for initrd. I do have NetworkManager enabled.

I tried again with NetworkManager disable and I got the errors:

udhcpc: broadcasting discover
udhcpc: broadcasting discover
udhcpc: broadcasting discover
udhcpc: no lease, failing

When I boot completely in NixOS with NetworkManager or without NetworkManager enable I get a IP with no problem.

To get udhcpc to have enough time to get an IP I had to increase the number of tries to 10. Usually on the forth try it succeeds. All works fine after that.

See: https://nixos.org/manual/nixos/stable/options.html#opt-boot.initrd.network.udhcpc.extraArgs

I added:

boot.initrd.network.udhcpc.extraArgs = [ "--retries=10" ];

Perhaps an options to allow for more retires should be added or the default should be increased a little. Right now the default is 3 retries.

ne9z commented

To get udhcpc to have enough time to get an IP I had to increase the number of tries to 10. Usually on the forth try it succeeds.

@mariaa144 it strongly indicates that you have local problems with network or dhcp server, I agree with @ne9z here.

Maybe it is a problem with my dhcp but my dhcp is running on an off the shelf pfsense device and it has never been a source of problem for me. Perhaps my NIC is still initializing when the for the first three attempts. That's what this guy suggests is happening for him. https://unix.stackexchange.com/a/617821/55139

I noticed I can create an issue on the flake repo so I'm going to close the issue here.