1 <chapter id=
"integrate-ms-networks">
5 <pubdate> (Jan
01 2001)
</pubdate>
8 <title>Integrating MS Windows networks with Samba
</title>
11 This section deals with NetBIOS over TCP/IP name to IP address resolution. If
12 your MS Windows clients are NOT configured to use NetBIOS over TCP/IP then this
13 section does not apply to your installation. If your installation involves use of
14 NetBIOS over TCP/IP then this section may help you to resolve networking problems.
19 NetBIOS over TCP/IP has nothing to do with NetBEUI. NetBEUI is NetBIOS
20 over Logical Link Control (LLC). On modern networks it is highly advised
21 to NOT run NetBEUI at all. Note also that there is NO such thing as
22 NetBEUI over TCP/IP - the existence of such a protocol is a complete
23 and utter mis-apprehension.
28 Since the introduction of MS Windows
2000 it is possible to run MS Windows networking
29 without the use of NetBIOS over TCP/IP. NetBIOS over TCP/IP uses UDP port
137 for NetBIOS
30 name resolution and uses TCP port
139 for NetBIOS session services. When NetBIOS over
31 TCP/IP is disabled on MS Windows
2000 and later clients then only TCP port
445 will be
32 used and UDP port
137 and TCP port
139 will not.
37 When using Windows
2000 or later clients, if NetBIOS over TCP/IP is NOT disabled, then
38 the client will use UDP port
137 (NetBIOS Name Service, also known as the Windows Internet
39 Name Service or WINS), TCP port
139 AND TCP port
445 (for actual file and print traffic).
44 When NetBIOS over TCP/IP is disabled the use of DNS is essential. Most installations that
45 disable NetBIOS over TCP/IP today use MS Active Directory Service (ADS). ADS requires
46 Dynamic DNS with Service Resource Records (SRV RR) and with Incremental Zone Transfers (IXFR).
47 Use of DHCP with ADS is recommended as a further means of maintaining central control
48 over client workstation network configuration.
53 <title>Name Resolution in a pure Unix/Linux world
</title>
56 The key configuration files covered in this section are:
60 <listitem><para><filename>/etc/hosts
</filename></para></listitem>
61 <listitem><para><filename>/etc/resolv.conf
</filename></para></listitem>
62 <listitem><para><filename>/etc/host.conf
</filename></para></listitem>
63 <listitem><para><filename>/etc/nsswitch.conf
</filename></para></listitem>
67 <title><filename>/etc/hosts
</filename></title>
70 Contains a static list of IP Addresses and names.
73 <para><programlisting>
74 127.0.0.1 localhost localhost.localdomain
75 192.168.1.1 bigbox.caldera.com bigbox alias4box
76 </programlisting></para>
79 The purpose of
<filename>/etc/hosts
</filename> is to provide a
80 name resolution mechanism so that uses do not need to remember
86 Network packets that are sent over the physical network transport
87 layer communicate not via IP addresses but rather using the Media
88 Access Control address, or MAC address. IP Addresses are currently
89 32 bits in length and are typically presented as four (
4) decimal
90 numbers that are separated by a dot (or period). eg:
168.192.1.1
94 MAC Addresses use
48 bits (or
6 bytes) and are typically represented
95 as two digit hexadecimal numbers separated by colons. eg:
100 Every network interfrace must have an MAC address. Associated with
101 a MAC address there may be one or more IP addresses. There is NO
102 relationship between an IP address and a MAC address, all such assignments
103 are arbitary or discretionary in nature. At the most basic level all
104 network communications takes place using MAC addressing. Since MAC
105 addresses must be globally unique, and generally remains fixed for
106 any particular interface, the assignment of an IP address makes sense
107 from a network management perspective. More than one IP address can
108 be assigned per MAC address. One address must be the primary IP address,
109 this is the address that will be returned in the ARP reply.
113 When a user or a process wants to communicate with another machine
114 the protocol implementation ensures that the
"machine name" or
"host
115 name" is resolved to an IP address in a manner that is controlled
116 by the TCP/IP configuration control files. The file
117 <filename>/etc/hosts
</filename> is one such file.
121 When the IP address of the destination interface has been
122 determined a protocol called ARP/RARP is used to identify
123 the MAC address of the target interface. ARP stands for Address
124 Resolution Protocol, and is a broadcast oriented method that
125 uses UDP (User Datagram Protocol) to send a request to all
126 interfaces on the local network segment using the all
1's MAC
127 address. Network interfaces are programmed to respond to two
128 MAC addresses only; their own unique address and the address
129 ff:ff:ff:ff:ff:ff. The reply packet from an ARP request will
130 contain the MAC address and the primary IP address for each
135 The
<filename>/etc/hosts
</filename> file is foundational to all
136 Unix/Linux TCP/IP installations and as a minumum will contain
137 the localhost and local network interface IP addresses and the
138 primary names by which they are known within the local machine.
139 This file helps to prime the pump so that a basic level of name
140 resolution can exist before any other method of name resolution
148 <title><filename>/etc/resolv.conf
</filename></title>
151 This file tells the name resolution libraries:
155 <listitem><para>The name of the domain to which the machine
159 <listitem><para>The name(s) of any domains that should be
160 automatically searched when trying to resolve unqualified
161 host names to their IP address
164 <listitem><para>The name or IP address of available Domain
165 Name Servers that may be asked to perform name to address
174 <title><filename>/etc/host.conf
</filename></title>
178 <filename>/etc/host.conf
</filename> is the primary means by
179 which the setting in /etc/resolv.conf may be affected. It is a
180 critical configuration file. This file controls the order by
181 which name resolution may procede. The typical structure is:
184 <para><programlisting>
187 </programlisting></para>
190 then both addresses should be returned. Please refer to the
191 man page for host.conf for further details.
200 <title><filename>/etc/nsswitch.conf
</filename></title>
203 This file controls the actual name resolution targets. The
204 file typically has resolver object specifications as follows:
208 <para><programlisting>
211 # Name Service Switch configuration file.
215 # Alternative entries for password authentication are:
216 # passwd: compat files nis ldap winbind
221 # Alternative entries for host name resolution are:
222 # hosts: files dns nis nis+ hesoid db compat ldap wins
223 networks: nis files dns
229 </programlisting></para>
232 Of course, each of these mechanisms requires that the appropriate
233 facilities and/or services are correctly configured.
237 It should be noted that unless a network request/message must be
238 sent, TCP/IP networks are silent. All TCP/IP communications assumes a
239 principal of speaking only when necessary.
243 Starting with version
2.2.0 samba has Linux support for extensions to
244 the name service switch infrastructure so that linux clients will
245 be able to obtain resolution of MS Windows NetBIOS names to IP
246 Addresses. To gain this functionality Samba needs to be compiled
247 with appropriate arguments to the make command (ie:
<command>make
248 nsswitch/libnss_wins.so
</command>). The resulting library should
249 then be installed in the
<filename>/lib
</filename> directory and
250 the
"wins" parameter needs to be added to the
"hosts:" line in
251 the
<filename>/etc/nsswitch.conf
</filename> file. At this point it
252 will be possible to ping any MS Windows machine by it's NetBIOS
253 machine name, so long as that machine is within the workgroup to
254 which both the samba machine and the MS Windows machine belong.
262 <title>Name resolution as used within MS Windows networking
</title>
265 MS Windows networking is predicated about the name each machine
266 is given. This name is known variously (and inconsistently) as
267 the
"computer name",
"machine name",
"networking name",
"netbios name",
268 "SMB name". All terms mean the same thing with the exception of
269 "netbios name" which can apply also to the name of the workgroup or the
270 domain name. The terms
"workgroup" and
"domain" are really just a
271 simply name with which the machine is associated. All NetBIOS names
272 are exactly
16 characters in length. The
16th character is reserved.
273 It is used to store a one byte value that indicates service level
274 information for the NetBIOS name that is registered. A NetBIOS machine
275 name is therefore registered for each service type that is provided by
280 The following are typical NetBIOS name/service type registrations:
283 <para><programlisting>
284 Unique NetBIOS Names:
285 MACHINENAME
<00> = Server Service is running on MACHINENAME
286 MACHINENAME
<03> = Generic Machine Name (NetBIOS name)
287 MACHINENAME
<20> = LanMan Server service is running on MACHINENAME
288 WORKGROUP
<1b
> = Domain Master Browser
291 WORKGROUP
<03> = Generic Name registered by all members of WORKGROUP
292 WORKGROUP
<1c
> = Domain Controllers / Netlogon Servers
293 WORKGROUP
<1d
> = Local Master Browsers
294 WORKGROUP
<1e
> = Internet Name Resolvers
295 </programlisting></para>
298 It should be noted that all NetBIOS machines register their own
299 names as per the above. This is in vast contrast to TCP/IP
300 installations where traditionally the system administrator will
301 determine in the /etc/hosts or in the DNS database what names
302 are associated with each IP address.
306 One further point of clarification should be noted, the
<filename>/etc/hosts
</filename>
307 file and the DNS records do not provide the NetBIOS name type information
308 that MS Windows clients depend on to locate the type of service that may
309 be needed. An example of this is what happens when an MS Windows client
310 wants to locate a domain logon server. It finds this service and the IP
311 address of a server that provides it by performing a lookup (via a
312 NetBIOS broadcast) for enumeration of all machines that have
313 registered the name type *
<1c
>. A logon request is then sent to each
314 IP address that is returned in the enumerated list of IP addresses. Which
315 ever machine first replies then ends up providing the logon services.
319 The name
"workgroup" or
"domain" really can be confusing since these
320 have the added significance of indicating what is the security
321 architecture of the MS Windows network. The term
"workgroup" indicates
322 that the primary nature of the network environment is that of a
323 peer-to-peer design. In a WORKGROUP all machines are responsible for
324 their own security, and generally such security is limited to use of
325 just a password (known as SHARE MODE security). In most situations
326 with peer-to-peer networking the users who control their own machines
327 will simply opt to have no security at all. It is possible to have
328 USER MODE security in a WORKGROUP environment, thus requiring use
329 of a user name and a matching password.
333 MS Windows networking is thus predetermined to use machine names
334 for all local and remote machine message passing. The protocol used is
335 called Server Message Block (SMB) and this is implemented using
336 the NetBIOS protocol (Network Basic Input Output System). NetBIOS can
337 be encapsulated using LLC (Logical Link Control) protocol - in which case
338 the resulting protocol is called NetBEUI (Network Basic Extended User
339 Interface). NetBIOS can also be run over IPX (Internetworking Packet
340 Exchange) protocol as used by Novell NetWare, and it can be run
341 over TCP/IP protocols - in which case the resulting protocol is called
342 NBT or NetBT, the NetBIOS over TCP/IP.
346 MS Windows machines use a complex array of name resolution mechanisms.
347 Since we are primarily concerned with TCP/IP this demonstration is
348 limited to this area.
352 <title>The NetBIOS Name Cache
</title>
355 All MS Windows machines employ an in memory buffer in which is
356 stored the NetBIOS names and IP addresses for all external
357 machines that that machine has communicated with over the
358 past
10-
15 minutes. It is more efficient to obtain an IP address
359 for a machine from the local cache than it is to go through all the
360 configured name resolution mechanisms.
364 If a machine whose name is in the local name cache has been shut
365 down before the name had been expired and flushed from the cache, then
366 an attempt to exchange a message with that machine will be subject
367 to time-out delays. i.e.: Its name is in the cache, so a name resolution
368 lookup will succeed, but the machine can not respond. This can be
369 frustrating for users - but it is a characteristic of the protocol.
373 The MS Windows utility that allows examination of the NetBIOS
374 name cache is called
"nbtstat". The Samba equivalent of this
375 is called
"nmblookup".
381 <title>The LMHOSTS file
</title>
384 This file is usually located in MS Windows NT
4.0 or
385 2000 in
<filename>C:\WINNT\SYSTEM32\DRIVERS\ETC
</filename> and contains
386 the IP Address and the machine name in matched pairs. The
387 <filename>LMHOSTS
</filename> file performs NetBIOS name
388 to IP address mapping.
392 It typically looks like:
395 <para><programlisting>
396 # Copyright (c)
1998 Microsoft Corp.
398 # This is a sample LMHOSTS file used by the Microsoft Wins Client (NetBIOS
399 # over TCP/IP) stack for Windows98
401 # This file contains the mappings of IP addresses to NT computernames
402 # (NetBIOS) names. Each entry should be kept on an individual line.
403 # The IP address should be placed in the first column followed by the
404 # corresponding computername. The address and the comptername
405 # should be separated by at least one space or tab. The
"#" character
406 # is generally used to denote the start of a comment (see the exceptions
409 # This file is compatible with Microsoft LAN Manager
2.x TCP/IP lmhosts
410 # files and offers the following extensions:
413 # #DOM:
<domain
>
414 # #INCLUDE
<filename
>
417 # \
0xnn (non-printing character support)
419 # Following any entry in the file with the characters
"#PRE" will cause
420 # the entry to be preloaded into the name cache. By default, entries are
421 # not preloaded, but are parsed only after dynamic name resolution fails.
423 # Following an entry with the
"#DOM:<domain>" tag will associate the
424 # entry with the domain specified by
<domain
>. This affects how the
425 # browser and logon services behave in TCP/IP environments. To preload
426 # the host name associated with #DOM entry, it is necessary to also add a
427 # #PRE to the line. The
<domain
> is always preloaded although it will not
428 # be shown when the name cache is viewed.
430 # Specifying
"#INCLUDE <filename>" will force the RFC NetBIOS (NBT)
431 # software to seek the specified
<filename
> and parse it as if it were
432 # local.
<filename
> is generally a UNC-based name, allowing a
433 # centralized lmhosts file to be maintained on a server.
434 # It is ALWAYS necessary to provide a mapping for the IP address of the
435 # server prior to the #INCLUDE. This mapping must use the #PRE directive.
436 # In addtion the share
"public" in the example below must be in the
437 # LanManServer list of
"NullSessionShares" in order for client machines to
438 # be able to read the lmhosts file successfully. This key is under
439 # \machine\system\currentcontrolset\services\lanmanserver\parameters\nullsessionshares
440 # in the registry. Simply add
"public" to the list found there.
442 # The #BEGIN_ and #END_ALTERNATE keywords allow multiple #INCLUDE
443 # statements to be grouped together. Any single successful include
444 # will cause the group to succeed.
446 # Finally, non-printing characters can be embedded in mappings by
447 # first surrounding the NetBIOS name in quotations, then using the
448 # \
0xnn notation to specify a hex value for a non-printing character.
450 # The following example illustrates all of these extensions:
452 #
102.54.94.97 rhino #PRE #DOM:networking #net group's DC
453 #
102.54.94.102 "appname \0x14" #special app server
454 #
102.54.94.123 popular #PRE #source server
455 #
102.54.94.117 localsrv #PRE #needed for the include
458 # #INCLUDE \\localsrv\public\lmhosts
459 # #INCLUDE \\rhino\public\lmhosts
462 # In the above example, the
"appname" server contains a special
463 # character in its name, the
"popular" and
"localsrv" server names are
464 # preloaded, and the
"rhino" server name is specified so it can be used
465 # to later #INCLUDE a centrally maintained lmhosts file if the
"localsrv"
466 # system is unavailable.
468 # Note that the whole file is parsed including comments on each lookup,
469 # so keeping the number of comments to a minimum will improve performance.
470 # Therefore it is not advisable to simply add lmhosts file entries onto the
472 </programlisting></para>
477 <title>HOSTS file
</title>
480 This file is usually located in MS Windows NT
4.0 or
2000 in
481 <filename>C:\WINNT\SYSTEM32\DRIVERS\ETC
</filename> and contains
482 the IP Address and the IP hostname in matched pairs. It can be
483 used by the name resolution infrastructure in MS Windows, depending
484 on how the TCP/IP environment is configured. This file is in
485 every way the equivalent of the Unix/Linux
<filename>/etc/hosts
</filename> file.
491 <title>DNS Lookup
</title>
494 This capability is configured in the TCP/IP setup area in the network
495 configuration facility. If enabled an elaborate name resolution sequence
496 is followed the precise nature of which is dependant on what the NetBIOS
497 Node Type parameter is configured to. A Node Type of
0 means use
498 NetBIOS broadcast (over UDP broadcast) is first used if the name
499 that is the subject of a name lookup is not found in the NetBIOS name
500 cache. If that fails then DNS, HOSTS and LMHOSTS are checked. If set to
501 Node Type
8, then a NetBIOS Unicast (over UDP Unicast) is sent to the
502 WINS Server to obtain a lookup before DNS, HOSTS, LMHOSTS, or broadcast
509 <title>WINS Lookup
</title>
512 A WINS (Windows Internet Name Server) service is the equivaent of the
513 rfc1001/
1002 specified NBNS (NetBIOS Name Server). A WINS server stores
514 the names and IP addresses that are registered by a Windows client
515 if the TCP/IP setup has been given at least one WINS Server IP Address.
519 To configure Samba to be a WINS server the following parameter needs
520 to be added to the &smb.conf; file:
523 <para><programlisting>
525 </programlisting></para>
528 To configure Samba to use a WINS server the following parameters are
529 needed in the &smb.conf; file:
532 <para><programlisting>
534 wins server = xxx.xxx.xxx.xxx
535 </programlisting></para>
538 where
<replaceable>xxx.xxx.xxx.xxx
</replaceable> is the IP address