Windows hostnames are not resolved

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 have wins 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.


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.


To summarize the above, here's what I did to get it to work:

  1. sudo apt-get install winbind
  2. sudo apt-get install libnss-winbind
  3. sudo gedit /etc/nsswitch.conf and append "wins" after "files"

    hosts:          files wins mdns4_minimal [NOTFOUND=return] dns 
    

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.