Windows hostnames are not resolved

19,548

Solution 1

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 
    

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.

Share:
19,548

Related videos on Youtube

vitaut
Author by

vitaut

GitHub: https://github.com/vitaut Twitter: https://twitter.com/vzverovich Author of {fmt} and C++20 std::format

Updated on September 18, 2022

Comments

  • vitaut
    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 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.

    • Admin
      Admin over 12 years
      @rao_555: no, just ping a windows machine
    • Admin
      Admin over 12 years
      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.
    • Admin
      Admin over 12 years
      @rao_555: that's what I am doing, but the name is not resolved
    • Admin
      Admin over 12 years
      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
    • Admin
      Admin over 9 years
      I did not have mdns4 in my default nsswitch.conf (ubuntu 14.04), you don't need that; it also feels a little bit faster without.
  • vitaut
    vitaut over 12 years
    Placing wins before [NOTFOUND=return] breaks name resolution in chrome and firefox.
  • cqcallaw
    cqcallaw over 12 years
    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?
  • vitaut
    vitaut over 12 years
    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.
  • cqcallaw
    cqcallaw over 12 years
    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
  • Admin
    Admin over 11 years
    Mr cqcallaw You should at least mention which config files we should change/edit
  • cqcallaw
    cqcallaw over 11 years
    I 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
    Autodidact about 10 years
    +1 could not resolve windows host names without this library (even if nmblookup works)
  • tomi
    tomi about 8 years
    installing libnss-winbind was the key.
  • Jimmy He
    Jimmy He over 4 years
    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