how to discover all netbios scopes on a LAN?
dave-gnus at bfnet.com
Wed Oct 22 20:31:01 GMT 2003
Chris Hertel sent me the following reply to my question, and asked me
to forward it to the list.
On Wed, Oct 22, 2003 at 11:40:03AM -0700, David Wuertele wrote:
> I would like my application to be able to enumerate all the netbios
> scopes that are in use on the LAN.
> I thought that I might be able to do it by using NBSTAT request
> packets (nmblookup -S <IP ADDR>), but apparently NBSTAT replies only
> return names in the netbios scope given in the NBSTAT request. If I
> don't know what netbios scopes are available, I won't be able to use
> NBSTAT to discover them :-(
The NBT layer creates virtual NetBIOS LANs on top of TCP/UDP/IP:
| NetBIOS |
|TCP | UDP|
| IP |
...like so. All of the nodes that participate in the "virtual NetBIOS
LAN" are said to be in the same "scope". If all of the nodes are B nodes,
then the scope is limited to the IP broadcast domain. If all of the nodes
are P nodes, then the scope is limited to the entries in the NBNS
database. M and H mode scopes are the union of B and P mode scopes.
...but that has nothing to do with the ScopeID.
Think of the ScopeID as a vLAN tag. The default ScopeID is "" (empty
string), so most NBT nodes are simply part of the "" scope. If you add a
non-empty ScopeID (eg. "foo") then what you are doing is creating a new
virtual NBT LAN. It is in the same IP space as the "" scope, but it is a
*separate virtual NetBIOS LAN*.
I usually have to ice my cranium after pondering that for a while.
> How can my app discover all the netbios scopes in use on the LAN?
Well... there's always a fudge.
One way is to sniff traffic, but that's a pain and it only collects
information from the local LAN.
Another way is to ask the WINS server itself. I have no idea how to do
this on a Windows WINS server, but you should be able to access Samba's
WINS database. At present, Samba periodically dumps its internal WINS
database to the file "wins.dat". It's a text file. The ScopeIDs should
be in there.
"Implementing CIFS - the Common Internet FileSystem" ISBN: 013047116X
Samba Team -- http://www.samba.org/ -)----- Christopher R. Hertel
jCIFS Team -- http://jcifs.samba.org/ -)----- ubiqx development, uninq.
ubiqx Team -- http://www.ubiqx.org/ -)----- crh at ubiqx.mn.org
OnLineBook -- http://ubiqx.org/cifs/ -)----- crh at ubiqx.org
More information about the samba-technical