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.
Prerequisites:
- 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.
Steps:
- Tell NetworkManager not to provide DNS resolution
- Create your own resolv.conf
Step 1 (described here)
Create /etc/NetworkManager/conf.d/90-dns-none.conf file with the following content:
[main]
dns=none
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 192.168.1.1 with your router or DHCP server's actual IP address if it's different):
nameserver 127.0.0.53
nameserver 192.168.1.1
Step 2.1
Restart the resolver
sudo systemctl restart systemd-resolved
Then you can test like this:
$ nslookup google.com
Server: 127.0.0.53
Address: 127.0.0.53#53
Non-authoritative answer:
Name: google.com
Address: 216.58.195.78
Name: google.com
Address: 2607:f8b0:4005:807::200e
$ nslookup mywindowsmachine
;; Got SERVFAIL reply from 127.0.0.53, trying next server
Server: 192.168.1.1
Address: 192.168.1.1#53
Name: mywindowsmachine
Address: 192.168.1.61
;; Got SERVFAIL reply from 127.0.0.53, trying next server
If the above still doesn't work, try installing winbind.
sudo apt install winbind libnss-winbind
No comments:
Post a Comment