How to Resolve Windows Host Names on your LAN from a Linux Machine

Resolving Windows host names on a LAN from a Linux machine is tricky and changes often enough that most AskUbuntu or Stack Overflow "solutions" don't work as of Feb 2021.

This method works in KDE Neon 5.20 with Kernel 5.4.0-65-generic and should work with most Ubuntu 20.x versions.

The idea is to give your Ubuntu machine your router's / DHCP server's address as a secondary DNS server.

The difficulty is that the standard /etc/resolv.conf file gets clobbered when the NetworkManager service starts. The trick is how to manage resolv.conf manually.


  • A LAN
  • A Windows host on the LAN with default network configuration, in WORKGROUP
  • A Ubuntu 20.x machine

All of the following happens on the Ubuntu machine. The Windows host doesn't need any reconfiguration.


  1. Tell NetworkManager not to provide DNS resolution
  2. Create your own resolv.conf

Create /etc/NetworkManager/conf.d/90-dns-none.conf file with the following content:


Step 1.1
Restart NetworkManager
sudo systemctl reload NetworkManager

Step 2
If /etc/resolv.conf is a symlink to a systemd file (typically /run/systemd/resolve/resolv.conf or the stub file), remove that symlink.
Create a/etc/resolv.conf file like this (replace with your router or DHCP server's actual IP address if it's different):


Step 2.1 
Restart the resolver 

sudo systemctl restart systemd-resolved

Then you can test like this:

$ nslookup google.com

Non-authoritative answer:
Name:   google.com
Name:   google.com
Address: 2607:f8b0:4005:807::200e

$ nslookup mywindowsmachine
;; Got SERVFAIL reply from, trying next server

Name:   mywindowsmachine
;; Got SERVFAIL reply from, trying next server

If the above still doesn't work, try installing winbind. 

sudo apt install winbind libnss-winbind

No comments:

Post a Comment