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

How can I change the hostname? #24

Closed
luochen1990 opened this issue Mar 29, 2021 · 4 comments
Closed

How can I change the hostname? #24

luochen1990 opened this issue Mar 29, 2021 · 4 comments
Labels
question Further information is requested

Comments

@luochen1990
Copy link

I find that setting networking.hostName only works after sudo nixos-rebuild switch, and when I reboot the wsl with wsl --shutdown, it turn back to the Windows hostname again.

So, am I expected to keep the hostname and not touching it ?

@Trundle
Copy link
Member

Trundle commented Apr 3, 2021

The hostname is set by WSL on boot. You can create a file /etc/wsl.conf with the following contents to set a custom hostname:

[network]
hostname = yournewname

It's not super well documented though, so I don't know if it has some other side-effects.

Maybe it makes sense to manage /etc/wsl.conf through NixOS-WSL after modularisation (#10 / #19) is done? 🤔

@nzbr nzbr added bug Something isn't working question Further information is requested and removed bug Something isn't working labels Mar 25, 2022
@nzbr
Copy link
Member

nzbr commented Mar 30, 2022

This is now possible through wsl.wslConf.network.hostname

@nzbr nzbr closed this as completed Mar 30, 2022
@Atry
Copy link
Contributor

Atry commented Apr 2, 2024

Shouldn't wsl.wslConf.network.hostname be derived from networking.hostName?

@nzbr
Copy link
Member

nzbr commented Apr 9, 2024

@Atry It is

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants