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

HOSTNAME.local: Name or service not known #10077

Open
1 of 2 tasks
blami opened this issue May 7, 2023 · 5 comments
Open
1 of 2 tasks

HOSTNAME.local: Name or service not known #10077

blami opened this issue May 7, 2023 · 5 comments

Comments

@blami
Copy link

blami commented May 7, 2023

Windows Version

Microsoft Windows [Version 10.0.22621.1555]

WSL Version

1.2.5.0

Are you using WSL 1 or WSL 2?

  • WSL 2
  • WSL 1

Kernel Version

5.15.90.1

Distro Version

Debian Testing (bookworm), imported

Other Software

N/A

Repro Steps

Imported Debian Testing from Docker container rootfs.

/etc/wsl.conf:

[network]
generateHosts = true
generateResolvConf = true

/etc/resolv.conf:

# This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf:
# [network]
# generateResolvConf = false
nameserver 172.31.16.1

/etc/hosts:

# This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf:
# [network]
# generateHosts = false
127.0.0.1       localhost
127.0.1.1       HOSTNAME.        HOSTNAME

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

/etc/nsswitch.conf:

passwd:         files systemd
group:          files systemd
shadow:         files systemd
gshadow:        files systemd

hosts:          files dns
networks:       files

protocols:      db files
services:       db files
ethers:         db files
rpc:            db files

netgroup:       nis

Finally, when trying to ping Windows side of host (ICMP traffic enabled) it does not work:

# ping HOSTNAME.local
ping: HOSTNAME.local: Name or service not known

but nslookup gives:

# nslookup HOSTNAME.local
Server:         172.31.16.1
Address:        172.31.16.1#53

Non-authoritative answer:
Name:   HOSTNAME
Address: 172.31.16.1
Name:   HOSTNAME
Address: xxx.xxx.xxx.xxx
Name:   HOSTNAME
Address: fe80::6e5a:a5c4:3df:8cf4
Name:   HOSTNAME
Address: fe80::d955:3be3:873c:54f

I guess this is because mDNS query is forced (leaking) through to DNS server running for WSL adapter?

Also,

# ping HOSTNAME.mshome.net

works fine and resolves to correct IP (using that as workaround for now).

Without any further changes same command (ping HOSTNAME.local) works as desired on Ubuntu installed from MS Store:

(Ubuntu) # ping HOSTNAME.local
PING HOSTNAME (172.31.16.1) 56(84) bytes of data.
64 bytes from HOSTNAME.mshome.net (172.31.16.1): icmp_seq=1 ttl=128 time=0.368 ms

Is there any specific library/software that needs to be installed or configuration need to be changed in imported distribution to make this work? My workflow relies on being able to hit Windows host from WSL2 guest.

Expected Behavior

HOSTNAME.local resolves to Windows side of host.

Actual Behavior

HOSTNAME.local cannot be resolved.

Diagnostic Logs

No response

@yachen4ever
Copy link

same problem here

@stej
Copy link

stej commented Jul 18, 2023

wsl2, Ubuntu-22.04

ping "$(hostname).local"
ping: CZ.local: Name or service not known
:(

@jeffrson
Copy link

jeffrson commented Sep 26, 2023

Anything new? This used to work but doesn't now (WSL 2.0.0/WSL 2.0.1).

Edit: oh, well, it seems to be simple - just install "libnss-mdns" with its dependencies.

@ayqazi
Copy link

ayqazi commented Feb 6, 2024

I have installed libnss-mdns on Ubuntu 22.04 and ping "$(hostname).local" still doesn't work:

$ dpkg -l|grep libnss-mdns
ii  libnss-mdns:amd64                                 0.15.1-1ubuntu1                         amd64        NSS module for Multicast DNS name resolution
$ ping "$(hostname).local"
ping: MYCOMPUTERNAME.local: Name or service not known

@sigasigasiga
Copy link

sigasigasiga commented Sep 25, 2024

sudo apt install avahi-daemon libnss-mdns
sudo systemctl enable --now avahi-daemon

and then make sure that libnss-mdns is enabled in /etc/nsswitch.conf file:

$ cat /etc/nsswitch.conf
# uninvolved config portion skipped here...
#
# now, make sure that `mdns4_minimal [NOTFOUND=return]` exists and goes after `files`
hosts:          files mdns4_minimal [NOTFOUND=return] dns

after that mdns support should be set up and ready


if you want to test it out using ping, please note that there's a small catch: for some reason, the host machine cannot be pinged from WSL:

$ ping ${hostname}.local
PING egor-bychin-pc.local (172.28.0.1) 56(84) bytes of data.
^C
--- egor-bychin-pc.local ping statistics ---
21 packets transmitted, 0 received, 100% packet loss, time 20800ms

as you can see, the address was resolved just fine (and the ip address is 172.28.0.1) but all the packets were lost. this issue has nothing to do with mdns, the same would happen if i'd try to ping this ip address manually:

$ ping 172.28.0.1
PING 172.28.0.1 (172.28.0.1) 56(84) bytes of data.
^C
--- 172.28.0.1 ping statistics ---
23 packets transmitted, 0 received, 100% packet loss, time 22891ms

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

6 participants