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

Best way to handle an IP change after kexec #415

Open
arunoruto opened this issue Oct 30, 2024 · 4 comments
Open

Best way to handle an IP change after kexec #415

arunoruto opened this issue Oct 30, 2024 · 4 comments

Comments

@arunoruto
Copy link

After the NixCon I was eager to try out nixos-anywhere and took an old mini PC so I can mess around a bit. It already had NixOS, but to make a real experiment, I installed Debian on it, so I can remotely distrohop.

After executing nix run github:nix-community/nixos-anywhere -- --flake .#test [email protected], it was waiting for the host, but even after booting into nixos, it never reached it. A quick ip addr showed a different IP after the system was loaded, so of course it was unable to reach it again.

I could have maybe forced the same IP address somehow, but I ended up opening a new shell session and executing a new command nix run github:nix-community/nixos-anywhere -- --flake .#kenpachi [email protected] -i /tmp/tmp.abcde12345/nixos-anywhere.

a.b.c.d was the old IP, while a.b.c.e was the new one (can be found on your routers settings, the host name should be something like nixos-installer). I also had to provide the temporary SSH key for login /tmp/tmp.abcde12345/nixos-anywhere, which is displayed in the first lines during the execution of the script.

After fiddling around with this for an hour, it finally worked (I rarely use SSH keys, but it's a subject to change in the future!).
I am not sure if this has been mentioned somewhere in the documentation, so I wanted to ask if something like this should be also included? Maybe I am also mistaken and there is already a guide which slipped by me, while I was browsing the repo!

@arunoruto arunoruto changed the title Best way to handle IP change after kexec Best way to handle an IP change after kexec Oct 30, 2024
@josephfinlayson
Copy link

I also experienced this, and would like to know how to handle it!

@sedlund
Copy link
Contributor

sedlund commented Jan 1, 2025

you can increase the dhcp lease time on your dhcp server or set a static lease with the mac address of the machine.

or one could start with --phases kexec knowing that your network will change the ip on you. then once you figure out your new ip, you can run the other phases with the new ip.

@Mic92
Copy link
Member

Mic92 commented Jan 27, 2025

For local machines where you can select boot mediums, I would recommend booting the NixOS images instead: https://github.com/nix-community/nixos-images?tab=readme-ov-file#iso-installer-images

nixos-anywhere detects nixos installer. These images also have support for WiFi and nixos-anywhere can avoid kexec, which may not work with some hardware (i.e. some GPUs don't allow it).

@LarsOlt
Copy link

LarsOlt commented Jan 27, 2025

I fixed the issue by setting networking.useDHCP = false; in my nix configuration. After that I rebuilt my VPS with a fresh debian 12 install and ran nixos-anywhere again. Before I disabled DHCP my nixos got a different IP so I could no longer connect via ssh.

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

No branches or pull requests

5 participants