16

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.

6
  • Not clear by your question, but are you trying to access shared folders from windows machine??? Jan 6, 2012 at 14:17
  • @rao_555: no, just ping a windows machine
    – vitaut
    Jan 6, 2012 at 14:19
  • if 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. Jan 6, 2012 at 14:25
  • @rao_555: that's what I am doing, but the name is not resolved
    – vitaut
    Jan 6, 2012 at 14:59
  • check 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 Jan 6, 2012 at 15:12

3 Answers 3

16

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.

2
  • 3
    +1 could not resolve windows host names without this library (even if nmblookup works)
    – Autodidact
    Apr 14, 2014 at 12:46
  • 1
    installing libnss-winbind was the key.
    – tomi
    Mar 18, 2016 at 7:23
16

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 
    
1
  • Using 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
    – Jimmy He
    Nov 2, 2019 at 21:03
7

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.

6
  • Placing wins before [NOTFOUND=return] breaks name resolution in chrome and firefox.
    – vitaut
    Jan 23, 2012 at 11:25
  • How 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?
    – cqcallaw
    Jan 23, 2012 at 16:17
  • When I place wins before [NOTFOUND=return] the browser is unable to open google.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.
    – vitaut
    Jan 23, 2012 at 16:48
  • 1
    The '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
    – cqcallaw
    Jan 23, 2012 at 16:56
  • 1
    Mr cqcallaw You should at least mention which config files we should change/edit
    – user89326
    Sep 13, 2012 at 10:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .