How to enable netbios for NBNS name resolution?

How can I enable netbios (NBNS) name resolution on Linux?

I have a windows 2000 pc and a Linux pc (knoppix) running Samba.

I determined (via sniffer) that the Win2k pc finds my Linux pc by machine name, by sending a NBNS broadcast query (after getting no results from a DNS query).

However the Linux pc only does a DNS query, not a NBNS query, so it can't find the windows pc.
airplaysAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

harbor235Commented:
You can set up Samba as a WINS server by setting two global options in the configuration file, as shown below:

[global]
      wins support = yes
      name resolve order = wins lmhosts hosts bcast


harbor235 ;}
airplaysAuthor Commented:
I set those options in /etc/samba/smb.conf,  and did a /etc/init.d/samba stop, then /etc/init.d/samba start...

But there was no change... my sniffer (ethereal) showed that when pinging my win2k box, only a DNS query was sent, not an NBNS query.

jar3817Commented:
Try making a change to your /etc/nsswitch.conf file:

hosts: wins files dns

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
CompTIA Network+

Prepare for the CompTIA Network+ exam by learning how to troubleshoot, configure, and manage both wired and wireless networks.

sda100Commented:
Hi airplays,

Try:

nmblookup <netbios_name>

Steve :)
airplaysAuthor Commented:
harbor234: My understanding is that there is already a WINS server running on the win2k box - how would a WINS server running on Linux help me find the win2k from Linux?

jar3817:  I made the change to the file, but still no NBNS query when pinging.  Do I have to restart a service for that to take effect?

sda100:  that function successfully returned the IP of my win2k box (which is useful, thanks!)  however how do I enable NBNS queries when pinging?
sda100Commented:
Ah, yes...

With help from another source... you need to edit /etc/nsswitch.conf

Add the wins parameter to the "hosts:" line, for example:

       hosts:      files dns wins

Then you should just be able to ping by netbios host name.

Steve :)
sda100Commented:
Sorry jar3817, I've just read your answer - I was a little late there.
airplaysAuthor Commented:
Like I mentioned, I edited /etc/nsswitch.conf to contain "hosts:      files dns wins"

Still no NBNS query when pinging (only DNS).  Do I have to restart a service for that to take effect?  I'm on Debian (knoppix)
sda100Commented:
Is it able to query but just can't find the name, or are you getting an error when you try?

For the Windows machine, does it have a firewall  (if so, turn off for testing)

On the Windows machine, does the output of this command match the name you're trying to ping?

     nbtstat -n | find "<00>  U"

(there's 2 spaces before the U)

Steve :)
airplaysAuthor Commented:
Yes on windows that command is the machine name I ping.  

But really it shouldn't make a difference if the name is correct or not.  Because I determined with the sniffer that when I ping from Debian knoppix, it only attempts a DNS query, whereas pinging from windows attempts a DNS then a NBNS query.

So I just want to enable the Debian knoppix box to also perform an NBNS query, which won't matter whether the target name exists or not.
sda100Commented:
Ok, that makes more sense.  On my test system (Fedora Core #3), all I had to do was edit nsswitch.  If, on Debian, you have to also restart networking, then Google says:

     /etc/init.d/networking restart

Failing that, can you post the [global] section of your smb.conf?
jar3817Commented:
Or just try rebooting the server.

This might not be the answer you're looking for, but why don't you just set up a dns server? You can do it on the linux machine. Netbios is an old dead protocol. Starting with windows 2000 they switched the default name resolution from netbios to dns. As long as you have the right dns suffix set in all the computers you'll be able to do \\computername\share and have it work.
airplaysAuthor Commented:
"/etc/init.d/networking restart" did not change the behavior, still no NBNS query.
My [global] smb.conf section follows:

[global]
   panic action = /usr/share/samba/panic-action %d
   printing = cups
   printcap name = cups
   load printers = yes
   guest account = nobody
   invalid users = root
   security = user
   workgroup = WORKGROUP
   server string = %h server (Samba %v)
   syslog only = no
   syslog = 0;
   socket options = IPTOS_LOWDELAY TCP_NODELAY SO_SNDBUF=4096 SO_RCVBUF=4096
   encrypt passwords = true
   passdb backend = smbpasswd guest
   wins support = no
   include = /etc/samba/dhcp.conf
   name resolve order = lmhosts host wins bcast
   dns proxy = no
   preserve case = yes
   short preserve case = yes
   unix password sync = false
   passwd program = /usr/bin/passwd %u
   max log size = 1000
   obey pam restrictions = yes
   unix charset = iso-8859-15
   display charset = iso-8859-15
   dos charset = 850
airplaysAuthor Commented:
jar3817:  As for your suggestion for me to setup a network server, here is my response:  In my network, I will be connecting various laptop computers to various router ports at various times... so the IP address of each computer will change.  Will a DNS server be useful in this case?  Because I thought a DNS server is only an ideal solution for static IPs.  It seems to me like NBNS is an ideal solution for locating windows & linux boxes when the IPs are dynamic... I may be totally misinformed, so correct me if I'm wrong.

Also I think you deserve the points for this question since your suggestion on /etc/nsswitch.conf seems to be the solution... although I haven't gotten it to work, but it may be an OS issue having to do with Linux/Knoppix.  
jar3817Commented:
Sorry you haven't gotten it to work, I tried it on my servers and it works fine.

You're right and wrong about the DNS only being useful for static hosts. In it's simplest form, yes that is true. But if you want to get more complicated you could set up dynamic dns that would change as your hosts get addresses from the dhcp server. That sounds like overkill for you though...

Looking at your [global] section of smb.conf above, you don't have a netbios name specified. Add a line like this to the [global] section of that file:

netbios name = svrname

Then restart smbd and nmbd.  Maybe that'll fix it.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux Networking

From novice to tech pro — start learning today.