WSL: Can't resolve hostnames of other machines on local network
Using bash on Windows I can’t resolve the hostname of another machine on my local network.
Access to the internet at large from bash works (can do wget google.com or apt-get update, for instance). Bash can talk to the other host by IPv4 address, and pinging it by name works in the Windows command prompt; however, it can’t be resolved by name in bash.
A possible complication is that the local network is IPv6-enabled. It’s a recent Comcast wireless router between the two machines (both running Win10). I haven’t tried disabling IPv6 (not sure how to do it).
I also tried to follow these steps to install the winbind service, but this doesn’t seem to work on LXSS; afterward, when trying to resolve names I just got the error “Could not determine network interfaces, you must use a interfaces config line”.
Are there any steps I can take to enable local name resolution in bash?
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Reactions: 5
- Comments: 17
To get WINS resolution working you use winbindd from samba. Do:
sudo apt install libnss-winbind/etc/nssswitch.confeg:hosts: files dns wins/etc/samba/smb.confand set the interfaces setting to your ip/maskI am having the same issue. It seems to be because WSL does not know the local domain’s name. Try, for example, nslookup localmachine.localdomain and it will work. Have not yet figured out how to set the local domain name in WSL. Normal linux configuration methods do no seem to work.
@Reedbeta that’s because you need to do step 3 in my steps. Samba\Winbind can’t find network interfaces, so you need to specify the IP to bind on and the netmask using an interfaces line in /etc/samba/smb.conf. eg:
interfaces = 10.0.0.51/24 127.0.0.1/8And then it should work (I’m using 14942 with Xenial and it works)You can add a “search” entry in resolv.conf by setting the DNS suffix in the windows network adapter settings. It can be found in the adapter settings -> IPV4 -> Advanced -> Tab “DNS”.
@rodrymbo - Thanks for the tip, that helped. I had changed the network adapter a few days ago, and the DNS suffix was not set for the adapter. Everything had worked on the Windows side - only had a problem on the WSL side - so I figured it was a problem in WSL. It appears that Windows will use the computer’s primary DNS suffix, and WSL only uses the adapter’s DNS suffix. Maybe this should be changed.
Ok. I figured it out. I had made a typo when editing the config file. Add your local domain name to /etc/resolv.conf
For example add this line: domain example.net substitute example.net with your local domain name.