1 <chapter id="integrate-ms-networks">
5 <pubdate> (Jan 01 2001) </pubdate>
8 <title>Integrating MS Windows networks with Samba</title>
10 <indexterm><primary>NetBIOS</primary></indexterm>
12 This section deals with NetBIOS over TCP/IP name to IP address resolution. If
13 your MS Windows clients are NOT configured to use NetBIOS over TCP/IP then this
14 section does not apply to your installation. If your installation involves use of
15 NetBIOS over TCP/IP then this section may help you to resolve networking problems.
20 NetBIOS over TCP/IP has nothing to do with NetBEUI. NetBEUI is NetBIOS
21 over Logical Link Control (LLC). On modern networks it is highly advised
22 to NOT run NetBEUI at all. Note also that there is NO such thing as
23 NetBEUI over TCP/IP - the existence of such a protocol is a complete
24 and utter mis-apprehension.
29 <title>Features and Benefits</title>
32 Many MS Windows network administrators have never been exposed to basic TCP/IP
33 networking as it is implemented in a UNIX/Linux operating system. Likewise, many UNIX and
34 Linux administrators have not been exposed to the intricacies of MS Windows TCP/IP based
35 networking (and may have no desire to be either).
39 This chapter gives a short introduction to the basics of how a name can be resolved to
40 it's IP address for each operating system environment.
46 <title>Background Information</title>
49 Since the introduction of MS Windows 2000 it is possible to run MS Windows networking
50 without the use of NetBIOS over TCP/IP. NetBIOS over TCP/IP uses UDP port 137 for NetBIOS
51 name resolution and uses TCP port 139 for NetBIOS session services. When NetBIOS over
52 TCP/IP is disabled on MS Windows 2000 and later clients then only TCP port 445 will be
53 used and UDP port 137 and TCP port 139 will not.
58 When using Windows 2000 or later clients, if NetBIOS over TCP/IP is NOT disabled, then
59 the client will use UDP port 137 (NetBIOS Name Service, also known as the Windows Internet
60 Name Service or WINS), TCP port 139 AND TCP port 445 (for actual file and print traffic).
65 When NetBIOS over TCP/IP is disabled the use of DNS is essential. Most installations that
66 disable NetBIOS over TCP/IP today use MS Active Directory Service (ADS). ADS requires
67 <indexterm><primary>DNS</primary><secondary>Dynamic</secondary></indexterm>
68 Dynamic DNS with Service Resource Records (SRV RR) and with Incremental Zone Transfers (IXFR).
69 <indexterm><primary>DHCP</primary></indexterm>
70 Use of DHCP with ADS is recommended as a further means of maintaining central control
71 over client workstation network configuration.
77 <title>Name Resolution in a pure UNIX/Linux world</title>
80 The key configuration files covered in this section are:
84 <listitem><para><filename>/etc/hosts</filename></para></listitem>
85 <listitem><para><filename>/etc/resolv.conf</filename></para></listitem>
86 <listitem><para><filename>/etc/host.conf</filename></para></listitem>
87 <listitem><para><filename>/etc/nsswitch.conf</filename></para></listitem>
91 <title><filename>/etc/hosts</filename></title>
94 Contains a static list of IP addresses and names.
97 <para><programlisting>
98 127.0.0.1 localhost localhost.localdomain
99 192.168.1.1 bigbox.caldera.com bigbox alias4box
100 </programlisting></para>
103 The purpose of <filename>/etc/hosts</filename> is to provide a
104 name resolution mechanism so that uses do not need to remember
110 Network packets that are sent over the physical network transport
111 layer communicate not via IP addresses but rather using the Media
112 Access Control address, or MAC address. IP addresses are currently
113 32 bits in length and are typically presented as four (4) decimal
114 numbers that are separated by a dot (or period). eg: 168.192.1.1.
117 <indexterm><primary>MAC Addresses</primary></indexterm>
119 MAC Addresses use 48 bits (or 6 bytes) and are typically represented
120 as two digit hexadecimal numbers separated by colons. eg:
125 Every network interface must have an MAC address. Associated with
126 a MAC address there may be one or more IP addresses. There is NO
127 relationship between an IP address and a MAC address, all such assignments
128 are arbitrary or discretionary in nature. At the most basic level all
129 network communications takes place using MAC addressing. Since MAC
130 addresses must be globally unique, and generally remains fixed for
131 any particular interface, the assignment of an IP address makes sense
132 from a network management perspective. More than one IP address can
133 be assigned per MAC address. One address must be the primary IP address,
134 this is the address that will be returned in the ARP reply.
138 When a user or a process wants to communicate with another machine
139 the protocol implementation ensures that the "machine name" or "host
140 name" is resolved to an IP address in a manner that is controlled
141 by the TCP/IP configuration control files. The file
142 <filename>/etc/hosts</filename> is one such file.
146 When the IP address of the destination interface has been
147 determined a protocol called ARP/RARP is used to identify
148 the MAC address of the target interface. ARP stands for Address
149 Resolution Protocol, and is a broadcast oriented method that
150 uses UDP (User Datagram Protocol) to send a request to all
151 interfaces on the local network segment using the all 1's MAC
152 address. Network interfaces are programmed to respond to two
153 MAC addresses only; their own unique address and the address
154 ff:ff:ff:ff:ff:ff. The reply packet from an ARP request will
155 contain the MAC address and the primary IP address for each
159 <indexterm><primary>/etc/hosts</primary></indexterm>
161 The <filename>/etc/hosts</filename> file is foundational to all
162 UNIX/Linux TCP/IP installations and as a minimum will contain
163 the localhost and local network interface IP addresses and the
164 primary names by which they are known within the local machine.
165 This file helps to prime the pump so that a basic level of name
166 resolution can exist before any other method of name resolution
174 <title><filename>/etc/resolv.conf</filename></title>
177 This file tells the name resolution libraries:
181 <listitem><para>The name of the domain to which the machine
185 <listitem><para>The name(s) of any domains that should be
186 automatically searched when trying to resolve unqualified
187 host names to their IP address
190 <listitem><para>The name or IP address of available Domain
191 Name Servers that may be asked to perform name to address
200 <title><filename>/etc/host.conf</filename></title>
203 <indexterm><primary>/etc/host.conf</primary></indexterm>
205 <filename>/etc/host.conf</filename> is the primary means by
206 which the setting in /etc/resolv.conf may be affected. It is a
207 critical configuration file. This file controls the order by
208 which name resolution may proceed. The typical structure is:
211 <para><programlisting>
214 </programlisting></para>
217 then both addresses should be returned. Please refer to the
218 man page for host.conf for further details.
227 <title><filename>/etc/nsswitch.conf</filename></title>
229 <indexterm><primary>/etc/nsswitch.conf</primary></indexterm>
232 This file controls the actual name resolution targets. The
233 file typically has resolver object specifications as follows:
237 <para><programlisting>
240 # Name Service Switch configuration file.
244 # Alternative entries for password authentication are:
245 # passwd: compat files nis ldap winbind
250 # Alternative entries for host name resolution are:
251 # hosts: files dns nis nis+ hesiod db compat ldap wins
252 networks: nis files dns
258 </programlisting></para>
261 Of course, each of these mechanisms requires that the appropriate
262 facilities and/or services are correctly configured.
266 It should be noted that unless a network request/message must be
267 sent, TCP/IP networks are silent. All TCP/IP communications assumes a
268 principal of speaking only when necessary.
271 <indexterm><primary>libnss_wins.so</primary></indexterm>
274 Starting with version 2.2.0 samba has Linux support for extensions to
275 the name service switch infrastructure so that linux clients will
276 be able to obtain resolution of MS Windows NetBIOS names to IP
277 Addresses. To gain this functionality Samba needs to be compiled
278 with appropriate arguments to the make command (i.e.: <userinput>make
279 nsswitch/libnss_wins.so</userinput>). The resulting library should
280 then be installed in the <filename>/lib</filename> directory and
281 the "wins" parameter needs to be added to the "hosts:" line in
282 the <filename>/etc/nsswitch.conf</filename> file. At this point it
283 will be possible to ping any MS Windows machine by its NetBIOS
284 machine name, so long as that machine is within the workgroup to
285 which both the samba machine and the MS Windows machine belong.
293 <title>Name resolution as used within MS Windows networking</title>
296 MS Windows networking is predicated about the name each machine
297 is given. This name is known variously (and inconsistently) as
298 the "computer name", "machine name", "networking name", "netbios name",
299 or "SMB name". All terms mean the same thing with the exception of
300 "netbios name" which can apply also to the name of the workgroup or the
301 domain name. The terms "workgroup" and "domain" are really just a
302 simple name with which the machine is associated. All NetBIOS names
303 are exactly 16 characters in length. The 16th character is reserved.
304 It is used to store a one byte value that indicates service level
305 information for the NetBIOS name that is registered. A NetBIOS machine
306 name is therefore registered for each service type that is provided by
311 The following are typical NetBIOS name/service type registrations:
315 <title>Unique NetBIOS names</title>
317 <colspec align="left"/>
318 <colspec align="justify"/>
320 <row><entry>MACHINENAME<00></entry><entry>Server Service is running on MACHINENAME</entry></row>
321 <row><entry>MACHINENAME<03></entry><entry>Generic Machine Name (NetBIOS name)</entry></row>
322 <row><entry>MACHINENAME<20></entry><entry>LanMan Server service is running on MACHINENAME</entry></row>
323 <row><entry>WORKGROUP<1b></entry><entry>Domain Master Browser</entry></row>
329 <title>Group Names</title>
331 <colspec align="left"/>
332 <colspec align="justify"/>
334 <row><entry>WORKGROUP<03></entry><entry>Generic Name registered by all members of WORKGROUP</entry></row>
335 <row><entry>WORKGROUP<1c></entry><entry>Domain Controllers / Netlogon Servers</entry></row>
336 <row><entry>WORKGROUP<1d></entry><entry>Local Master Browsers</entry></row>
337 <row><entry>WORKGROUP<1e></entry><entry>Internet Name Resolvers</entry></row>
343 <indexterm><primary>NetBIOS</primary></indexterm>
344 It should be noted that all NetBIOS machines register their own
345 names as per the above. This is in vast contrast to TCP/IP
346 installations where traditionally the system administrator will
347 determine in the /etc/hosts or in the DNS database what names
348 are associated with each IP address.
351 <indexterm><primary>NetBIOS</primary></indexterm>
353 One further point of clarification should be noted, the <filename>/etc/hosts</filename>
354 file and the DNS records do not provide the NetBIOS name type information
355 that MS Windows clients depend on to locate the type of service that may
356 be needed. An example of this is what happens when an MS Windows client
357 wants to locate a domain logon server. It finds this service and the IP
358 address of a server that provides it by performing a lookup (via a
359 NetBIOS broadcast) for enumeration of all machines that have
360 registered the name type *<1c>. A logon request is then sent to each
361 IP address that is returned in the enumerated list of IP addresses.
362 Whichever machine first replies then ends up providing the logon services.
366 The name "workgroup" or "domain" really can be confusing since these
367 have the added significance of indicating what is the security
368 architecture of the MS Windows network. The term "workgroup" indicates
369 that the primary nature of the network environment is that of a
370 peer-to-peer design. In a WORKGROUP all machines are responsible for
371 their own security, and generally such security is limited to use of
372 just a password (known as SHARE MODE security). In most situations
373 with peer-to-peer networking the users who control their own machines
374 will simply opt to have no security at all. It is possible to have
375 USER MODE security in a WORKGROUP environment, thus requiring use
376 of a user name and a matching password.
380 MS Windows networking is thus predetermined to use machine names
381 for all local and remote machine message passing. The protocol used is
382 called Server Message Block (SMB) and this is implemented using
383 the NetBIOS protocol (Network Basic Input Output System). NetBIOS can
384 be encapsulated using LLC (Logical Link Control) protocol - in which case
385 the resulting protocol is called NetBEUI (Network Basic Extended User
386 Interface). NetBIOS can also be run over IPX (Internetworking Packet
387 Exchange) protocol as used by Novell NetWare, and it can be run
388 over TCP/IP protocols - in which case the resulting protocol is called
389 NBT or NetBT, the NetBIOS over TCP/IP.
393 MS Windows machines use a complex array of name resolution mechanisms.
394 Since we are primarily concerned with TCP/IP this demonstration is
395 limited to this area.
399 <title>The NetBIOS Name Cache</title>
402 All MS Windows machines employ an in memory buffer in which is
403 stored the NetBIOS names and IP addresses for all external
404 machines that that machine has communicated with over the
405 past 10-15 minutes. It is more efficient to obtain an IP address
406 for a machine from the local cache than it is to go through all the
407 configured name resolution mechanisms.
411 If a machine whose name is in the local name cache has been shut
412 down before the name had been expired and flushed from the cache, then
413 an attempt to exchange a message with that machine will be subject
414 to time-out delays. i.e.: Its name is in the cache, so a name resolution
415 lookup will succeed, but the machine can not respond. This can be
416 frustrating for users - but it is a characteristic of the protocol.
419 <indexterm><primary>nbtstat</primary></indexterm>
420 <indexterm><primary>nmblookup</primary></indexterm>
422 The MS Windows utility that allows examination of the NetBIOS
423 name cache is called "nbtstat". The Samba equivalent of this
424 is called <command>nmblookup</command>.
430 <title>The LMHOSTS file</title>
432 <indexterm><primary>LMHOSTS</primary></indexterm>
434 This file is usually located in MS Windows NT 4.0 or
435 2000 in <filename>C:\WINNT\SYSTEM32\DRIVERS\ETC</filename> and contains
436 the IP Address and the machine name in matched pairs. The
437 <filename>LMHOSTS</filename> file performs NetBIOS name
438 to IP address mapping.
442 It typically looks like:
445 <para><programlisting>
446 # Copyright (c) 1998 Microsoft Corp.
448 # This is a sample LMHOSTS file used by the Microsoft Wins Client (NetBIOS
449 # over TCP/IP) stack for Windows98
451 # This file contains the mappings of IP addresses to NT computernames
452 # (NetBIOS) names. Each entry should be kept on an individual line.
453 # The IP address should be placed in the first column followed by the
454 # corresponding computername. The address and the computername
455 # should be separated by at least one space or tab. The "#" character
456 # is generally used to denote the start of a comment (see the exceptions
459 # This file is compatible with Microsoft LAN Manager 2.x TCP/IP lmhosts
460 # files and offers the following extensions:
463 # #DOM:<domain>
464 # #INCLUDE <filename>
467 # \0xnn (non-printing character support)
469 # Following any entry in the file with the characters "#PRE" will cause
470 # the entry to be preloaded into the name cache. By default, entries are
471 # not preloaded, but are parsed only after dynamic name resolution fails.
473 # Following an entry with the "#DOM:<domain>" tag will associate the
474 # entry with the domain specified by <domain>. This affects how the
475 # browser and logon services behave in TCP/IP environments. To preload
476 # the host name associated with #DOM entry, it is necessary to also add a
477 # #PRE to the line. The <domain> is always preloaded although it will not
478 # be shown when the name cache is viewed.
480 # Specifying "#INCLUDE <filename>" will force the RFC NetBIOS (NBT)
481 # software to seek the specified <filename> and parse it as if it were
482 # local. <filename> is generally a UNC-based name, allowing a
483 # centralized lmhosts file to be maintained on a server.
484 # It is ALWAYS necessary to provide a mapping for the IP address of the
485 # server prior to the #INCLUDE. This mapping must use the #PRE directive.
486 # In addition the share "public" in the example below must be in the
487 # LanManServer list of "NullSessionShares" in order for client machines to
488 # be able to read the lmhosts file successfully. This key is under
489 # \machine\system\currentcontrolset\services\lanmanserver\
490 # parameters\nullsessionshares
491 # in the registry. Simply add "public" to the list found there.
493 # The #BEGIN_ and #END_ALTERNATE keywords allow multiple #INCLUDE
494 # statements to be grouped together. Any single successful include
495 # will cause the group to succeed.
497 # Finally, non-printing characters can be embedded in mappings by
498 # first surrounding the NetBIOS name in quotations, then using the
499 # \0xnn notation to specify a hex value for a non-printing character.
501 # The following example illustrates all of these extensions:
503 # 102.54.94.97 rhino #PRE #DOM:networking #net group's DC
504 # 102.54.94.102 "appname \0x14" #special app server
505 # 102.54.94.123 popular #PRE #source server
506 # 102.54.94.117 localsrv #PRE #needed for the include
509 # #INCLUDE \\localsrv\public\lmhosts
510 # #INCLUDE \\rhino\public\lmhosts
513 # In the above example, the "appname" server contains a special
514 # character in its name, the "popular" and "localsrv" server names are
515 # preloaded, and the "rhino" server name is specified so it can be used
516 # to later #INCLUDE a centrally maintained lmhosts file if the "localsrv"
517 # system is unavailable.
519 # Note that the whole file is parsed including comments on each lookup,
520 # so keeping the number of comments to a minimum will improve performance.
521 # Therefore it is not advisable to simply add lmhosts file entries onto the
523 </programlisting></para>
528 <title>HOSTS file</title>
531 This file is usually located in MS Windows NT 4.0 or 2000 in
532 <filename>C:\WINNT\SYSTEM32\DRIVERS\ETC</filename> and contains
533 the IP Address and the IP hostname in matched pairs. It can be
534 used by the name resolution infrastructure in MS Windows, depending
535 on how the TCP/IP environment is configured. This file is in
536 every way the equivalent of the UNIX/Linux <filename>/etc/hosts</filename> file.
542 <title>DNS Lookup</title>
544 <indexterm><primary>DNS</primary></indexterm>
547 This capability is configured in the TCP/IP setup area in the network
548 configuration facility. If enabled, an elaborate name resolution sequence
549 is followed the precise nature of which is dependant on how the NetBIOS
550 Node Type parameter is configured. A Node Type of 0 means that
551 NetBIOS broadcast (over UDP broadcast) is used if the name
552 that is the subject of a name lookup is not found in the NetBIOS name
553 cache. If that fails then DNS, HOSTS and LMHOSTS are checked. If set to
554 Node Type 8, then a NetBIOS Unicast (over UDP Unicast) is sent to the
555 WINS Server to obtain a lookup before DNS, HOSTS, LMHOSTS, or broadcast
562 <title>WINS Lookup</title>
564 <indexterm><primary>WINS</primary></indexterm>
567 A WINS (Windows Internet Name Server) service is the equivalent of the
568 rfc1001/1002 specified NBNS (NetBIOS Name Server). A WINS server stores
569 the names and IP addresses that are registered by a Windows client
570 if the TCP/IP setup has been given at least one WINS Server IP Address.
574 To configure Samba to be a WINS server the following parameter needs
575 to be added to the &smb.conf; file:
579 <smbconfoption><name>wins support</name><value>Yes</value></smbconfoption>
580 </smbconfblock></para>
583 To configure Samba to use a WINS server the following parameters are
584 needed in the &smb.conf; file:
588 <smbconfoption><name>wins support</name><value>No</value></smbconfoption>
589 <smbconfoption><name>wins server</name><value>xxx.xxx.xxx.xxx</value></smbconfoption>
590 </smbconfblock></para>
593 where <replaceable>xxx.xxx.xxx.xxx</replaceable> is the IP address
597 <para>For information about setting up Samba as a WINS server, read
598 <link linkend="NetworkBrowsing">the chapter on network browsing</link>.</para>
604 <title>Common Errors</title>
607 TCP/IP network configuration problems find every network administrator sooner or later.
608 The cause can be anything from keyboard mishaps, forgetfulness, simple mistakes, and
609 carelessness. Of course, no one is every deliberately careless!
613 <title>Pinging works only in one way</title>
616 <quote>I can ping my samba server from Windows, but I can
617 not ping my Windows machine from the samba server.</quote>
621 The Windows machine was at IP Address 192.168.1.2 with netmask 255.255.255.0, the
622 Samba server (Linux) was at IP Address 192.168.1.130 with netmask 255.255.255.128.
623 The machines were on a local network with no external connections.
627 Due to inconsistent netmasks, the Windows machine was on network 192.168.1.0/24, while
628 the Samba server was on network 192.168.1.128/25 - logically a different network.
634 <title>Very Slow Network Connections</title>
637 A common causes of slow network response includes:
641 <listitem><para>Client is configured to use DNS and DNS server is down</para></listitem>
642 <listitem><para>Client is configured to use remote DNS server, but remote connection is down</para></listitem>
643 <listitem><para>Client is configured to use a WINS server, but there is no WINS server</para></listitem>
644 <listitem><para>Client is NOT configured to use a WINS server, but there is a WINS server</para></listitem>
645 <listitem><para>Firewall is filtering our DNS or WINS traffic</para></listitem>
651 <title>Samba server name change problem</title>
654 <quote>The name of the samba server was changed, samba was restarted, samba server can not be
655 pinged by new name from MS Windows NT4 Workstation, but it does still respond to ping using
656 the old name. Why?</quote>
660 From this description three (3) things are rather obvious:
664 <listitem><para>WINS is NOT in use, only broadcast based name resolution is used</para></listitem>
665 <listitem><para>The samba server was renamed and restarted within the last 10-15 minutes</para></listitem>
666 <listitem><para>The old samba server name is still in the NetBIOS name cache on the MS Windows NT4 Workstation</para></listitem>
670 To find what names are present in the NetBIOS name cache on the MS Windows NT4 machine,
671 open a cmd shell, then:
676 &dosprompt;<userinput>nbtstat -n</userinput>
678 NetBIOS Local Name Table
681 ------------------------------------------------
682 &example.workstation.windows; <03> UNIQUE Registered
683 ADMINSTRATOR <03> UNIQUE Registered
684 &example.workstation.windows; <00> UNIQUE Registered
685 SARDON <00> GROUP Registered
686 &example.workstation.windows; <20> UNIQUE Registered
687 &example.workstation.windows; <1F> UNIQUE Registered
690 &dosprompt;nbtstat -c
692 NetBIOS Remote Cache Name Table
694 Name Type Host Address Life [sec]
695 --------------------------------------------------------------
696 &example.server.samba; <20> UNIQUE 192.168.1.1 240
703 In the above example, &example.server.samba; is the Samba server and &example.workstation.windows; is the MS Windows NT4 Workstation.
704 The first listing shows the contents of the Local Name Table (i.e.: Identity information on
705 the MS Windows workstation), the second shows the NetBIOS name in the NetBIOS name cache.
706 The name cache contains the remote machines known to this workstation.