1 <?xml version="1.0" encoding="iso-8859-1"?>
2 <!DOCTYPE chapter PUBLIC "-//Samba-Team//DTD DocBook V4.2-Based Variant V1.0//EN" "http://www.samba.org/samba/DTD/samba-doc">
3 <chapter id="integrate-ms-networks">
7 <pubdate> (Jan 01 2001) </pubdate>
10 <title>Integrating MS Windows Networks with Samba</title>
13 <indexterm><primary>NetBIOS</primary></indexterm>
14 This section deals with NetBIOS over TCP/IP name to IP address resolution. If
15 your MS Windows clients are not configured to use NetBIOS over TCP/IP, then this
16 section does not apply to your installation. If your installation
18 NetBIOS over TCP/IP then this section may help you to resolve networking problems.
23 NetBIOS over TCP/IP has nothing to do with NetBEUI. NetBEUI is NetBIOS
24 over Logical Link Control (LLC). On modern networks it is highly advised
25 to not run NetBEUI at all. Note also there is no such thing as
26 NetBEUI over TCP/IP &smbmdash; the existence of such a protocol is a complete
27 and utter misapprehension.
32 <title>Features and Benefits</title>
35 Many MS Windows network administrators have never been exposed to basic TCP/IP
36 networking as it is implemented in a UNIX/Linux operating system. Likewise, many UNIX and
37 Linux administrators have not been exposed to the intricacies of MS Windows TCP/IP-based
38 networking (and may have no desire to be either).
42 This chapter gives a short introduction to the basics of how a name can be resolved to
43 its IP address for each operating system environment.
49 <title>Background Information</title>
52 Since the introduction of MS Windows 2000, it is possible to run MS Windows networking
53 without the use of NetBIOS over TCP/IP. NetBIOS over TCP/IP uses UDP port 137 for NetBIOS
54 name resolution and uses TCP port 139 for NetBIOS session services. When NetBIOS over
55 TCP/IP is disabled on MS Windows 2000 and later clients, then only the TCP port 445 will be
56 used and the UDP port 137 and TCP port 139 will not.
61 When using Windows 2000 or later clients, if NetBIOS over TCP/IP is not disabled, then
62 the client will use UDP port 137 (NetBIOS Name Service, also known as the Windows Internet
63 Name Service or WINS), TCP port 139 and TCP port 445 (for actual file and print traffic).
68 When NetBIOS over TCP/IP is disabled, the use of DNS is essential. Most installations that
69 disable NetBIOS over TCP/IP today use MS Active Directory Service (ADS). ADS requires
70 <indexterm><primary>DNS</primary><secondary>Dynamic</secondary></indexterm>
71 Dynamic DNS with Service Resource Records (SRV RR) and with Incremental Zone Transfers (IXFR).
72 <indexterm><primary>DHCP</primary></indexterm>
73 Use of DHCP with ADS is recommended as a further means of maintaining central control
74 over the client workstation network configuration.
80 <title>Name Resolution in a Pure UNIX/Linux World</title>
83 The key configuration files covered in this section are:
87 <listitem><para><filename>/etc/hosts</filename></para></listitem>
88 <listitem><para><filename>/etc/resolv.conf</filename></para></listitem>
89 <listitem><para><filename>/etc/host.conf</filename></para></listitem>
90 <listitem><para><filename>/etc/nsswitch.conf</filename></para></listitem>
94 <title><filename>/etc/hosts</filename></title>
97 This file contains a static list of IP addresses and names.
99 <para><programlisting>
100 127.0.0.1 localhost localhost.localdomain
101 192.168.1.1 bigbox.quenya.org bigbox alias4box
102 </programlisting></para>
105 The purpose of <filename>/etc/hosts</filename> is to provide a
106 name resolution mechanism so users do not need to remember
111 Network packets that are sent over the physical network transport
112 layer communicate not via IP addresses but rather using the Media
113 Access Control address, or MAC address. IP addresses are currently
114 32 bits in length and are typically presented as four (4) decimal
115 numbers that are separated by a dot (or period). For example, 168.192.1.1.
119 <indexterm><primary>MAC Addresses</primary></indexterm>
120 MAC Addresses use 48 bits (or 6 bytes) and are typically represented
121 as two-digit hexadecimal numbers separated by colons: 40:8e:0a:12:34:56.
125 Every network interface must have a MAC address. Associated with
126 a MAC address 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 take place using MAC addressing. Since MAC
130 addresses must be globally unique and generally remain 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
135 this is the address that will be returned in the ARP reply.
139 When a user or a process wants to communicate with another machine,
140 the protocol implementation ensures that the <quote>machine name</quote> or <quote>host
141 name</quote> is resolved to an IP address in a manner that is controlled
142 by the TCP/IP configuration control files. The file
143 <filename>/etc/hosts</filename> is one such file.
147 When the IP address of the destination interface has been
148 determined, a protocol called ARP/RARP is used to identify
149 the MAC address of the target interface. ARP stands for Address
150 Resolution Protocol and is a broadcast-oriented method that
151 uses User Datagram Protocol (UDP) to send a request to all
152 interfaces on the local network segment using the all 1s MAC
153 address. Network interfaces are programmed to respond to two
154 MAC addresses only; their own unique address and the address
155 ff:ff:ff:ff:ff:ff. The reply packet from an ARP request will
156 contain the MAC address and the primary IP address for each
161 <indexterm><primary>/etc/hosts</primary></indexterm>
162 The <filename>/etc/hosts</filename> file is foundational to all
163 UNIX/Linux TCP/IP installations and as a minimum will contain
164 the localhost and local network interface IP addresses and the
165 primary names by which they are known within the local machine.
166 This file helps to prime the pump so a basic level of name
167 resolution can exist before any other method of name resolution
175 <title><filename>/etc/resolv.conf</filename></title>
178 This file tells the name resolution libraries:
182 <listitem><para>The name of the domain to which the machine
186 <listitem><para>The name(s) of any domains that should be
187 automatically searched when trying to resolve unqualified
188 host names to their IP address.
191 <listitem><para>The name or IP address of available Domain
192 Name Servers that may be asked to perform name-to-address
201 <title><filename>/etc/host.conf</filename></title>
205 <indexterm><primary>/etc/host.conf</primary></indexterm>
206 <filename>/etc/host.conf</filename> is the primary means by
207 which the setting in <filename>/etc/resolv.conf</filename> may be effected. It is a
208 critical configuration file. This file controls the order by
209 which name resolution may proceed. The typical structure is:
212 <para><programlisting>
215 </programlisting></para>
218 then both addresses should be returned. Please refer to the
219 man page for <filename>host.conf</filename> for further details.
228 <title><filename>/etc/nsswitch.conf</filename></title>
232 <indexterm><primary>/etc/nsswitch.conf</primary></indexterm>
233 This file controls the actual name resolution targets. The
234 file typically has resolver object specifications as follows:
238 <para><programlisting>
241 # Name Service Switch configuration file.
245 # Alternative entries for password authentication are:
246 # passwd: compat files nis ldap winbind
251 # Alternative entries for host name resolution are:
252 # hosts: files dns nis nis+ hesiod db compat ldap wins
253 networks: nis files dns
259 </programlisting></para>
262 Of course, each of these mechanisms requires that the appropriate
263 facilities and/or services are correctly configured.
267 It should be noted that unless a network request/message must be
268 sent, TCP/IP networks are silent. All TCP/IP communications assume a
269 principal of speaking only when necessary.
274 <indexterm><primary>libnss_wins.so</primary></indexterm>
275 Starting with version 2.2.0, Samba has Linux support for extensions to
276 the name service switch infrastructure so Linux clients will
277 be able to obtain resolution of MS Windows NetBIOS names to IP
278 Addresses. To gain this functionality, Samba needs to be compiled
279 with appropriate arguments to the make command (i.e., <userinput>make
280 nsswitch/libnss_wins.so</userinput>). The resulting library should
281 then be installed in the <filename>/lib</filename> directory and
282 the <parameter>wins</parameter> parameter needs to be added to the <quote>hosts:</quote> line in
283 the <filename>/etc/nsswitch.conf</filename> file. At this point, it
284 will be possible to ping any MS Windows machine by its NetBIOS
285 machine name, as long as that machine is within the workgroup to
286 which both the Samba machine and the MS Windows machine belong.
294 <title>Name Resolution as Used within MS Windows Networking</title>
297 MS Windows networking is predicated about the name each machine
298 is given. This name is known variously (and inconsistently) as
299 the <quote>computer name,</quote> <quote>machine name,</quote> <quote>networking name,</quote> <quote>netbios name,</quote>
300 or <quote>SMB name.</quote> All terms mean the same thing with the exception of
301 <quote>netbios name</quote> that can also apply to the name of the workgroup or the
302 domain name. The terms <quote>workgroup</quote> and <quote>domain</quote> are really just a
303 simple name with which the machine is associated. All NetBIOS names
304 are exactly 16 characters in length. The 16<superscript>th</superscript> character is reserved.
305 It is used to store a one-byte value that indicates service level
306 information for the NetBIOS name that is registered. A NetBIOS machine
307 name is, therefore, registered for each service type that is provided by
312 <link linkend="uniqnetbiosnames">Unique NetBIOS Names</link> and <link linkend="netbiosnamesgrp">Group Names</link> tables
313 list typical NetBIOS name/service type registrations.
316 <table frame="all" id="uniqnetbiosnames">
317 <title>Unique NetBIOS Names</title>
319 <colspec align="left"/>
320 <colspec align="justify"/>
322 <row><entry>MACHINENAME<00></entry><entry>Server Service is running on MACHINENAME</entry></row>
323 <row><entry>MACHINENAME<03></entry><entry>Generic Machine Name (NetBIOS name)</entry></row>
324 <row><entry>MACHINENAME<20></entry><entry>LanMan Server service is running on MACHINENAME</entry></row>
325 <row><entry>WORKGROUP<1b></entry><entry>Domain Master Browser</entry></row>
330 <table frame="all" id="netbiosnamesgrp">
331 <title>Group Names</title>
333 <colspec align="left"/>
334 <colspec align="justify"/>
336 <row><entry>WORKGROUP<03></entry><entry>Generic Name registered by all members of WORKGROUP</entry></row>
337 <row><entry>WORKGROUP<1c></entry><entry>Domain Controllers / Netlogon Servers</entry></row>
338 <row><entry>WORKGROUP<1d></entry><entry>Local Master Browsers</entry></row>
339 <row><entry>WORKGROUP<1e></entry><entry>Browser Election Service</entry></row>
345 <indexterm><primary>NetBIOS</primary></indexterm>
346 It should be noted that all NetBIOS machines register their own
347 names as per the above. This is in vast contrast to TCP/IP
348 installations where traditionally the system administrator will
349 determine in the <filename>/etc/hosts</filename> or in the DNS database what names
350 are associated with each IP address.
354 <indexterm><primary>NetBIOS</primary></indexterm>
355 One further point of clarification should be noted. The <filename>/etc/hosts</filename>
356 file and the DNS records do not provide the NetBIOS name type information
357 that MS Windows clients depend on to locate the type of service that may
358 be needed. An example of this is what happens when an MS Windows client
359 wants to locate a domain logon server. It finds this service and the IP
360 address of a server that provides it by performing a lookup (via a
361 NetBIOS broadcast) for enumeration of all machines that have
362 registered the name type *<1c>. A logon request is then sent to each
363 IP address that is returned in the enumerated list of IP addresses.
364 Whichever machine first replies, it then ends up providing the logon services.
368 The name <quote>workgroup</quote> or <quote>domain</quote> really can be confusing since these
369 have the added significance of indicating what is the security
370 architecture of the MS Windows network. The term <quote>workgroup</quote> indicates
371 that the primary nature of the network environment is that of a
372 peer-to-peer design. In a WORKGROUP, all machines are responsible for
373 their own security, and generally such security is limited to the use of
374 just a password (known as Share Level security). In most situations
375 with peer-to-peer networking, the users who control their own machines
376 will simply opt to have no security at all. It is possible to have
377 User Level Security in a WORKGROUP environment, thus requiring the use
378 of a user name and a matching password.
382 MS Windows networking is thus predetermined to use machine names
383 for all local and remote machine message passing. The protocol used is
384 called Server Message Block (SMB) and this is implemented using
385 the NetBIOS protocol (Network Basic Input Output System). NetBIOS can
386 be encapsulated using LLC (Logical Link Control) protocol &smbmdash; in which case
387 the resulting protocol is called NetBEUI (Network Basic Extended User
388 Interface). NetBIOS can also be run over IPX (Inter-networking Packet
389 Exchange) protocol as used by Novell NetWare, and it can be run
390 over TCP/IP protocols &smbmdash; in which case the resulting protocol is called
391 NBT or NetBT, the NetBIOS over TCP/IP.
395 MS Windows machines use a complex array of name resolution mechanisms.
396 Since we are primarily concerned with TCP/IP, this demonstration is
397 limited to this area.
401 <title>The NetBIOS Name Cache</title>
404 All MS Windows machines employ an in-memory buffer in which is
405 stored the NetBIOS names and IP addresses for all external
406 machines that machine has communicated with over the
407 past 10-15 minutes. It is more efficient to obtain an IP address
408 for a machine from the local cache than it is to go through all the
409 configured name resolution mechanisms.
413 If a machine whose name is in the local name cache has been shut
414 down before the name had been expired and flushed from the cache, then
415 an attempt to exchange a message with that machine will be subject
416 to time-out delays. Its name is in the cache, so a name resolution
417 lookup will succeed, but the machine cannot respond. This can be
418 frustrating for users but is a characteristic of the protocol.
422 <indexterm><primary>nbtstat</primary></indexterm>
423 <indexterm><primary>nmblookup</primary></indexterm>
424 The MS Windows utility that allows examination of the NetBIOS
425 name cache is called <quote>nbtstat</quote>. The Samba equivalent of this
426 is called <command>nmblookup</command>.
432 <title>The LMHOSTS File</title>
435 <indexterm><primary>LMHOSTS</primary></indexterm>
436 This file is usually located in MS Windows NT 4.0 or Windows 200x/XP in the directory
437 <filename>%SystemRoot%\SYSTEM32\DRIVERS\ETC</filename> and contains the IP Address
438 and the machine name in matched pairs. The <filename>LMHOSTS</filename> file
439 performs NetBIOS name to IP address mapping.
443 It typically looks like this:
446 <para><programlisting>
447 # Copyright (c) 1998 Microsoft Corp.
449 # This is a sample LMHOSTS file used by the Microsoft Wins Client (NetBIOS
450 # over TCP/IP) stack for Windows98
452 # This file contains the mappings of IP addresses to NT computer names
453 # (NetBIOS) names. Each entry should be kept on an individual line.
454 # The IP address should be placed in the first column followed by the
455 # corresponding computer name. The address and the computer name
456 # should be separated by at least one space or tab. The "#" character
457 # is generally used to denote the start of a comment (see the exceptions
460 # This file is compatible with Microsoft LAN Manager 2.x TCP/IP lmhosts
461 # files and offers the following extensions:
464 # #DOM:<domain>
465 # #INCLUDE <filename>
468 # \0xnn (non-printing character support)
470 # Following any entry in the file with the characters "#PRE" will cause
471 # the entry to be pre-loaded into the name cache. By default, entries are
472 # not pre-loaded, but are parsed only after dynamic name resolution fails.
474 # Following an entry with the "#DOM:<domain>" tag will associate the
475 # entry with the domain specified by <domain>. This effects how the
476 # browser and logon services behave in TCP/IP environments. To preload
477 # the host name associated with #DOM entry, it is necessary to also add a
478 # #PRE to the line. The <domain> is always pre-loaded although it will not
479 # be shown when the name cache is viewed.
481 # Specifying "#INCLUDE <filename>" will force the RFC NetBIOS (NBT)
482 # software to seek the specified <filename> and parse it as if it were
483 # local. <filename> is generally a UNC-based name, allowing a
484 # centralized lmhosts file to be maintained on a server.
485 # It is ALWAYS necessary to provide a mapping for the IP address of the
486 # server prior to the #INCLUDE. This mapping must use the #PRE directive.
487 # In addition the share "public" in the example below must be in the
488 # LanMan Server list of "NullSessionShares" in order for client machines to
489 # be able to read the lmhosts file successfully. This key is under
490 # \machine\system\currentcontrolset\services\lanmanserver\
491 # parameters\nullsessionshares
492 # in the registry. Simply add "public" to the list found there.
494 # The #BEGIN_ and #END_ALTERNATE keywords allow multiple #INCLUDE
495 # statements to be grouped together. Any single successful include
496 # will cause the group to succeed.
498 # Finally, non-printing characters can be embedded in mappings by
499 # first surrounding the NetBIOS name in quotations, then using the
500 # \0xnn notation to specify a hex value for a non-printing character.
502 # The following example illustrates all of these extensions:
504 # 102.54.94.97 rhino #PRE #DOM:networking #net group's DC
505 # 102.54.94.102 "appname \0x14" #special app server
506 # 102.54.94.123 popular #PRE #source server
507 # 102.54.94.117 localsrv #PRE #needed for the include
510 # #INCLUDE \\localsrv\public\lmhosts
511 # #INCLUDE \\rhino\public\lmhosts
514 # In the above example, the "appname" server contains a special
515 # character in its name, the "popular" and "localsrv" server names are
516 # pre-loaded, and the "rhino" server name is specified so it can be used
517 # to later #INCLUDE a centrally maintained lmhosts file if the "localsrv"
518 # system is unavailable.
520 # Note that the whole file is parsed including comments on each lookup,
521 # so keeping the number of comments to a minimum will improve performance.
522 # Therefore it is not advisable to simply add lmhosts file entries onto the
524 </programlisting></para>
529 <title>HOSTS File</title>
532 This file is usually located in MS Windows NT 4.0 or Windows 200x/XP in
533 the directory <filename>%SystemRoot%\SYSTEM32\DRIVERS\ETC</filename> and contains
534 the IP Address and the IP hostname in matched pairs. It can be
535 used by the name resolution infrastructure in MS Windows, depending
536 on how the TCP/IP environment is configured. This file is in
537 every way the equivalent of the UNIX/Linux <filename>/etc/hosts</filename> file.
543 <title>DNS Lookup</title>
547 <indexterm><primary>DNS</primary></indexterm>
548 This capability is configured in the TCP/IP setup area in the network
549 configuration facility. If enabled, an elaborate name resolution sequence
550 is followed, the precise nature of which is dependant on how the NetBIOS
551 Node Type parameter is configured. A Node Type of 0 means that
552 NetBIOS broadcast (over UDP broadcast) is used if the name
553 that is the subject of a name lookup is not found in the NetBIOS name
554 cache. If that fails then DNS, HOSTS and LMHOSTS are checked. If set to
555 Node Type 8, then a NetBIOS Unicast (over UDP Unicast) is sent to the
556 WINS Server to obtain a lookup before DNS, HOSTS, LMHOSTS, or broadcast
563 <title>WINS Lookup</title>
567 <indexterm><primary>WINS</primary></indexterm>
568 A WINS (Windows Internet Name Server) service is the equivalent of the
569 rfc1001/1002 specified NBNS (NetBIOS Name Server). A WINS server stores
570 the names and IP addresses that are registered by a Windows client
571 if the TCP/IP setup has been given at least one WINS Server IP Address.
575 To configure Samba to be a WINS server, the following parameter needs
576 to be added to the &smb.conf; file:
580 <smbconfoption name="wins support">Yes</smbconfoption>
581 </smbconfblock></para>
584 To configure Samba to use a WINS server, the following parameters are
585 needed in the &smb.conf; file:
589 <smbconfoption name="wins support">No</smbconfoption>
590 <smbconfoption name="wins server">xxx.xxx.xxx.xxx</smbconfoption>
591 </smbconfblock></para>
594 where <replaceable>xxx.xxx.xxx.xxx</replaceable> is the IP address
598 <para>For information about setting up Samba as a WINS server, read
599 <link linkend="NetworkBrowsing">Network Browsing</link>.</para>
605 <title>Common Errors</title>
608 TCP/IP network configuration problems find every network administrator sooner or later.
609 The cause can be anything from keyboard mishaps, forgetfulness, simple mistakes, and
610 carelessness. Of course, no one is ever deliberately careless!
614 <title>Pinging Works Only in One Way</title>
617 <quote>I can ping my Samba server from Windows, but I cannot ping my Windows
618 machine from the Samba server.</quote>
622 <emphasis>Answer:</emphasis> The Windows machine was at IP Address 192.168.1.2 with netmask 255.255.255.0, the
623 Samba server (Linux) was at IP Address 192.168.1.130 with netmask 255.255.255.128.
624 The machines were on a local network with no external connections.
628 Due to inconsistent netmasks, the Windows machine was on network 192.168.1.0/24, while
629 the Samba server was on network 192.168.1.128/25 &smbmdash; logically a different network.
635 <title>Very Slow Network Connections</title>
638 A common cause of slow network response includes:
642 <listitem><para>Client is configured to use DNS and the DNS server is down.</para></listitem>
643 <listitem><para>Client is configured to use remote DNS server, but the
644 remote connection is down.</para></listitem>
645 <listitem><para>Client is configured to use a WINS server, but there is no WINS server.</para></listitem>
646 <listitem><para>Client is not configured to use a WINS server, but there is a WINS server.</para></listitem>
647 <listitem><para>Firewall is filtering our DNS or WINS traffic.</para></listitem>
653 <title>Samba Server Name Change Problem</title>
656 <quote>The name of the Samba server was changed, Samba was restarted, Samba server cannot be
657 ping-ed by new name from MS Windows NT4 Workstation, but it does still respond to ping using
658 the old name. Why?</quote>
662 From this description, three things are obvious:
666 <listitem><para>WINS is not in use, only broadcast-based name resolution is used.</para></listitem>
667 <listitem><para>The Samba server was renamed and restarted within the last 10-15 minutes.</para></listitem>
668 <listitem><para>The old Samba server name is still in the NetBIOS name cache on the MS Windows NT4 Workstation.</para></listitem>
672 To find what names are present in the NetBIOS name cache on the MS Windows NT4 machine,
673 open a <command>cmd</command> shell and then:
678 &dosprompt;<userinput>nbtstat -n</userinput>
680 NetBIOS Local Name Table
683 ------------------------------------------------
684 &example.workstation.windows; <03> UNIQUE Registered
685 ADMINISTRATOR <03> UNIQUE Registered
686 &example.workstation.windows; <00> UNIQUE Registered
687 SARDON <00> GROUP Registered
688 &example.workstation.windows; <20> UNIQUE Registered
689 &example.workstation.windows; <1F> UNIQUE Registered
692 &dosprompt;nbtstat -c
694 NetBIOS Remote Cache Name Table
696 Name Type Host Address Life [sec]
697 --------------------------------------------------------------
698 &example.server.samba; <20> UNIQUE 192.168.1.1 240
705 In the above example, &example.server.samba; is the Samba server and &example.workstation.windows; is the MS Windows NT4 Workstation.
706 The first listing shows the contents of the Local Name Table (i.e., Identity information on
707 the MS Windows workstation) and the second shows the NetBIOS name in the NetBIOS name cache.
708 The name cache contains the remote machines known to this workstation.