Open suntong opened 3 years ago
Ask would be for the WSL instances to have their own UTS namespace with a /etc/wsl.conf
entry. But this wouldn't work in the current WSL model. Whether the hostname is different or not, all WSL distribution instances share the same NET namespace, by-design. Having the same IP address with different hostnames, while in principle possible, would be a mess. Effectively dupe #4711 if WSL had a different net namespace per distro instance (but it does not).
Hmm... suppose different WSL hostnames is allowed, would that have any external impact?
I was thinking that the WSL hostname is just an internal thing, internal in the sense it matters only to the WSL Linux system itself. Never thought the hostname would have any external impact. For e.g., I think it is impossible to address to WSL using the hostname in any way, as there might be many different WSL running just using the same hostname and same IP.
This is all just me thinking, as I know next to nothing about WSL internals. Comments?
PS. For ages, Linux chroot environment must have the same hostname as the host, but it is no longer the case anymore nowadays.
I noticed changing my hostname doesn't affect bash prompt under WSL, and I'm wondering if that can be changed --
I'ved changed:
I also changed
/etc/hostname
to "wsl" and changed/etc/hosts
as well.But my hostname in bash prompt never changed.
As per bash prompt user manual
So I think, for normal case, it is read from either
/etc/hostname
or/etc/hosts
.Describe the solution you'd like
Any of the above changing of my hostname method can affect bash prompt.
For reason behind that, "I have 6 different wsl instances for different purposes. Most of the times I can't figure out which instance I'm currently in."
Describe alternatives you've considered
I know the official solution is to change the host system's name from
System --> Change Settings --> Change
, but I'd like to identify my WSL distribution in different sessions, e.g. UbuntuA, UbuntuB and UbuntuC.Additional context
I know "WSL doesn't allow you to set a hostname separately from the computer".
and I know from #125 that "Changing the hostname from Bash is currently not supported"
but if you do a search on "WSL Change hostname", you can see that it is a common request, meaning most people have the same desire as this.
Please consider. thx!