6

According to this link, NetBIOS is no longer supported starting from Windwos Vista. Sure enough, I can no longer see any NetBIOS name from the network properties.

However, when I am writing codes on my Windows 7, I still encounter NetBIOS names in many places. For example

  1. I can still use "MYDOMAIN\Harvey" to logon my machine, where I believe MYDOMAIN is a NetBIOS name.
  2. The environment variables COMPUTERNAME and USERDOMAIN are still NetBIOS names. I am expecting to see a DNS names here
  3. My SQL Server instance names coming up from my SQL Server Management Studio is still something like MYMACHINE\Instance1.

I am guessing Microsoft still maintains some pieces of it for backward compatibility. I want to understand how Windows 7 going to resolve the NetBIOS name to an IP address. I found this article explaining how the NetBIOS name resolution works but I am afraid this is no longer true in Windows 7. At least there is no WINS server for me.

My last question is how do I do the NetBIOS name resolution programmatically, preferrably in C#. I am okay to use PInvoke.

UDAPTE

Tridus was right. I can use System.Net.Dns.GetHostAddresses("hostname") to resolve NetBIOS name. I used reflector to see what's happening under the hood. It is calling gethostbyname() from ws2_32.dll

Here, it explains the gethostbyname() will do NetBIOS name resolution.

  1. Check the local host name for a matching name.
  2. Check the Hosts file for a matching name entry.
  3. If a DNS server is configured, query it.
  4. If no match is found, attempt NetBIOS name-resolution.

About the mystery of NetBIOS not supported in this link, I think it just means the API is not supported. People in ServerFault think that NetBIOS is still supported in Windows 7.

Community
  • 1
  • 1
Harvey Kwok
  • 11,713
  • 6
  • 37
  • 59
  • I suspect you may get more traction on this if it were on ServerFault. – bryanbcook Jan 20 '11 at 18:02
  • @bryanbcook Bearing in mind the last line, I suspect that might not be the case. :-) – John Parker Jan 20 '11 at 18:04
  • @Harvey Kwok - So your goal is to determine the IP address of a computer on the local network based on its computer name? – Justin Jan 20 '11 at 18:11
  • Named pipes use netbios names too. They are present both in Windows API and .NET library. – Al Kepp Jan 20 '11 at 18:14
  • @Justin Yes, I was trying to find a way to resolve the NetBIOS name to IP address on Windows 7 and then found that the NetBIOS is no longer supported on Windows 7 – Harvey Kwok Jan 20 '11 at 18:51
  • @btyanbcook Thanks, I think I should really ask similar question on ServerFault. – Harvey Kwok Jan 20 '11 at 18:55
  • Posted another question on ServerFault http://serverfault.com/questions/224821/is-netbios-really-gone-on-windows. I renamed this questions title to make it more programmer-related. I don't want this question to be closed :) – Harvey Kwok Jan 20 '11 at 19:04

1 Answers1

5

NetBIOS itself as the old protocol might not be supported, but SMB/CIFS still is and that's why \hostname for filesharing and such still works.

As for how to resolve a name, I was able to do this:

System.Net.Dns.GetHostAddresses("hostname")

I'm on a domain so it may be simply appending a DNS suffix and doing a DNS lookup, but it worked for me. Give it a try. :)

Tridus
  • 5,021
  • 1
  • 19
  • 19