Windows hostnames are not resolved
Solution 1
To summarize the above, here's what I did to get it to work:
sudo apt-get install winbind
sudo apt-get install libnss-winbind
-
sudo gedit /etc/nsswitch.conf
and append "wins" after "files"hosts: files wins mdns4_minimal [NOTFOUND=return] dns
Solution 2
I had the same issue. Changing the location of wins in nslookup.conf
did not work, or possibly only got me part of the way there. Install the package libnss-winbind
to be able to find windows computers by hostname. I tested it with and without the package installed, and it is indeed necessary for resolving any windows hostname.
Solution 3
The order of operands in the hosts definition in /etc/nsswitch.conf
is important. In your case, host name resolution is terminated by the [NOTFOUND=return] statement before WINS name resolution ever happens. Move 'wins' so it's just after 'files', and you should be good to go:
hosts: files wins mdns4_minimal [NOTFOUND=return] dns mdns4
nmblookup (part of the samba-common-bin package) is another useful troubleshooting tool for this situations--it can be used to manually verify that the hostname you're using is valid.
Related videos on Youtube
vitaut
GitHub: https://github.com/vitaut Twitter: https://twitter.com/vzverovich Author of {fmt} and C++20 std::format
Updated on September 18, 2022Comments
-
vitaut over 1 year
I know that similar questions has already been asked. However, as suggested in the answers to that question I have the
winbind
package installed and havewins
in/etc/nsswitch.conf
:hosts: files mdns4_minimal [NOTFOUND=return] dns wins mdns4
Nevertheless, attempts to ping windows hostnames give
ping: unknown host <hostname>
Restarting
winbind
service doesn't help.I have Ubuntu 11.10 and winbind 3.5.11.
-
Admin over 12 years@rao_555: no, just ping a windows machine
-
Admin over 12 yearsif you'r windows machine are in same network, you can directly ping the windows machine, you dont need winbind for that. The main use of winbind is for unified logon.
-
Admin over 12 years@rao_555: that's what I am doing, but the name is not resolved
-
Admin over 12 yearscheck if your linux machine is in your network. check if you are able to ping the linux machine's ip-address from windows system. Also, check if you are able to ping windows machine ip-address
-
Admin over 9 yearsI did not have
mdns4
in my defaultnsswitch.conf
(ubuntu 14.04), you don't need that; it also feels a little bit faster without.
-
-
vitaut over 12 yearsPlacing
wins
before[NOTFOUND=return]
breaks name resolution in chrome and firefox. -
cqcallaw over 12 yearsHow exactly is name resolution breaking? Do all name lookups fail to resolve, or just NetBIOS names? Also, does ping work with the modified hosts line?
-
vitaut over 12 yearsWhen I place
wins
before[NOTFOUND=return]
the browser is unable to opengoogle.com
and other sites, so it's not only NetBIOS. When I change it back, sites open normally. The ping does work with the modified hosts line. -
cqcallaw over 12 yearsThe 'wins' statement needs to go after 'files', not after 'mdns4_minimal'. If you put 'wins' after 'mdns4_minimal' and before '[NOTFOUND=return]', then you're telling the name resolution routines to return if the NetBIOS name isn't found, which skips dns. Try moving 'wins' so it's immediately after 'files'. If you still have issues, try moving 'dns' so it's before 'mdns_minimal' as well, like so:
hosts: files dns wins mdns4_minimal [NOTFOUND=return] mdns4
-
Admin over 11 yearsMr cqcallaw You should at least mention which config files we should change/edit
-
cqcallaw over 11 yearsI was assuming the config file was obvious, since it was the only file mentioned in the original question. But, to avoid any confusion, I've updated my answer.
-
Autodidact about 10 years+1 could not resolve windows host names without this library (even if nmblookup works)
-
tomi about 8 yearsinstalling libnss-winbind was the key.
-
Jimmy He over 4 yearsUsing 18.04.3 in 2019, and this is still the way to go! Be sure to restart the winbind service afterwards:
sudo systemctl restart winbind