This commit was manufactured by cvs2svn to create branch 'SAMBA_3_0'.(This used to...
[ira/wip.git] / docs / docbook / projdoc / Integrating-with-Windows.sgml
1 <chapter id="integrate-ms-networks">
2  
3 <chapterinfo>
4         &author.jht;
5         <pubdate> (Jan 01 2001) </pubdate>
6 </chapterinfo>
7  
8 <title>Integrating MS Windows networks with Samba</title>
9  
10 <para>
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.
15 </para>
16
17 <note>
18 <para>
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.
24 </para>
25 </note>
26
27 <para>
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.
33 </para>
34
35 <note>
36 <para>
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).
40 </para>
41 </note>
42
43 <para>
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.
49 </para>
50
51
52 <sect1>
53 <title>Name Resolution in a pure Unix/Linux world</title>
54
55 <para>
56 The key configuration files covered in this section are:
57 </para>
58
59 <itemizedlist>
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>
64 </itemizedlist>
65
66 <sect2>
67 <title><filename>/etc/hosts</filename></title>
68
69 <para>
70 Contains a static list of IP Addresses and names.
71 eg:
72 </para>
73 <para><programlisting>
74         127.0.0.1       localhost localhost.localdomain
75         192.168.1.1     bigbox.caldera.com      bigbox  alias4box
76 </programlisting></para>
77
78 <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 
81 IP addresses.
82 </para>
83
84
85 <para>
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
91 </para>
92
93 <para>
94 MAC Addresses use 48 bits (or 6 bytes) and are typically represented 
95 as two digit hexadecimal numbers separated by colons. eg: 
96 40:8e:0a:12:34:56
97 </para>
98
99 <para>
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.
110 </para>
111
112 <para>
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.
118 </para>
119
120 <para>
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 
131 interface.
132 </para>
133
134 <para>
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 
141 becomes available.
142 </para>
143
144 </sect2>
145
146
147 <sect2>
148 <title><filename>/etc/resolv.conf</filename></title>
149
150 <para>
151 This file tells the name resolution libraries:
152 </para>
153
154 <itemizedlist>
155         <listitem><para>The name of the domain to which the machine 
156         belongs
157         </para></listitem>
158         
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
162         </para></listitem>
163         
164         <listitem><para>The name or IP address of available Domain 
165         Name Servers that may be asked to perform name to address 
166         translation lookups
167         </para></listitem>
168 </itemizedlist>
169
170 </sect2>
171
172
173 <sect2>
174 <title><filename>/etc/host.conf</filename></title>
175
176
177 <para>
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:
182 </para>
183
184 <para><programlisting>
185         order hosts,bind
186         multi on
187 </programlisting></para>
188
189 <para>
190 then both addresses should be returned. Please refer to the 
191 man page for host.conf for further details.
192 </para>
193
194
195 </sect2>
196
197
198
199 <sect2>
200 <title><filename>/etc/nsswitch.conf</filename></title>
201
202 <para>
203 This file controls the actual name resolution targets. The 
204 file typically has resolver object specifications as follows:
205 </para>
206
207
208 <para><programlisting>
209         # /etc/nsswitch.conf
210         #
211         # Name Service Switch configuration file.
212         #
213
214         passwd:         compat
215         # Alternative entries for password authentication are:
216         # passwd:       compat files nis ldap winbind
217         shadow:         compat
218         group:          compat
219
220         hosts:          files nis dns
221         # Alternative entries for host name resolution are:
222         # hosts:        files dns nis nis+ hesoid db compat ldap wins
223         networks:       nis files dns
224
225         ethers:         nis files
226         protocols:      nis files
227         rpc:            nis files
228         services:       nis files
229 </programlisting></para>
230
231 <para>
232 Of course, each of these mechanisms requires that the appropriate 
233 facilities and/or services are correctly configured.
234 </para>
235
236 <para>
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.
240 </para>
241
242 <para>
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.
255 </para>
256
257 </sect2>
258 </sect1>
259
260
261 <sect1>
262 <title>Name resolution as used within MS Windows networking</title>
263
264 <para>
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 
276 the client/server.
277 </para>
278
279 <para>
280 The following are typical NetBIOS name/service type registrations:
281 </para>
282
283 <para><programlisting>
284         Unique NetBIOS Names:
285                 MACHINENAME&lt;00&gt;   = Server Service is running on MACHINENAME
286                 MACHINENAME&lt;03&gt; = Generic Machine Name (NetBIOS name)
287                 MACHINENAME&lt;20&gt; = LanMan Server service is running on MACHINENAME
288                 WORKGROUP&lt;1b&gt; = Domain Master Browser
289
290         Group Names:
291                 WORKGROUP&lt;03&gt; = Generic Name registered by all members of WORKGROUP
292                 WORKGROUP&lt;1c&gt; = Domain Controllers / Netlogon Servers
293                 WORKGROUP&lt;1d&gt; = Local Master Browsers
294                 WORKGROUP&lt;1e&gt; = Internet Name Resolvers
295 </programlisting></para>
296
297 <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.
303 </para>
304
305 <para>
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 *&lt;1c&gt;. 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.
316 </para>
317
318 <para>
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.
330 </para>
331
332 <para>
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.
343 </para>
344
345 <para>
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.
349 </para>
350
351 <sect2>
352 <title>The NetBIOS Name Cache</title>
353
354 <para>
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.
361 </para>
362
363 <para>
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.
370 </para>
371
372 <para>
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".
376 </para>
377
378 </sect2>
379
380 <sect2>
381 <title>The LMHOSTS file</title>
382
383 <para>
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.
389 </para>
390
391 <para>
392 It typically looks like:
393 </para>
394
395 <para><programlisting>
396         # Copyright (c) 1998 Microsoft Corp.
397         #
398         # This is a sample LMHOSTS file used by the Microsoft Wins Client (NetBIOS
399         # over TCP/IP) stack for Windows98
400         #
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
407         # below).
408         #
409         # This file is compatible with Microsoft LAN Manager 2.x TCP/IP lmhosts
410         # files and offers the following extensions:
411         #
412         #      #PRE
413         #      #DOM:&lt;domain&gt;
414         #      #INCLUDE &lt;filename&gt;
415         #      #BEGIN_ALTERNATE
416         #      #END_ALTERNATE
417         #      \0xnn (non-printing character support)
418         #
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.
422         #
423         # Following an entry with the "#DOM:&lt;domain&gt;" tag will associate the
424         # entry with the domain specified by &lt;domain&gt;. 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 &lt;domain&gt; is always preloaded although it will not
428         # be shown when the name cache is viewed.
429         #
430         # Specifying "#INCLUDE &lt;filename&gt;" will force the RFC NetBIOS (NBT)
431         # software to seek the specified &lt;filename&gt; and parse it as if it were
432         # local. &lt;filename&gt; 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.
441         #
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.
445         #
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.
449         #
450         # The following example illustrates all of these extensions:
451         #
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
456         #
457         # #BEGIN_ALTERNATE
458         # #INCLUDE \\localsrv\public\lmhosts
459         # #INCLUDE \\rhino\public\lmhosts
460         # #END_ALTERNATE
461         #
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.
467         #
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
471         # end of this file.
472 </programlisting></para>
473
474 </sect2>
475
476 <sect2>
477 <title>HOSTS file</title>
478
479 <para>
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.
486 </para>
487 </sect2>
488
489
490 <sect2>
491 <title>DNS Lookup</title>
492
493 <para>
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 
503 lookup is used.
504 </para>
505
506 </sect2>
507
508 <sect2>
509 <title>WINS Lookup</title>
510
511 <para>
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.
516 </para>
517
518 <para>
519 To configure Samba to be a WINS server the following parameter needs 
520 to be added to the &smb.conf; file:
521 </para>
522
523 <para><programlisting>
524         wins support = Yes
525 </programlisting></para>
526
527 <para>
528 To configure Samba to use a WINS server the following parameters are 
529 needed in the &smb.conf; file:
530 </para>
531
532 <para><programlisting>
533         wins support = No
534         wins server = xxx.xxx.xxx.xxx
535 </programlisting></para>
536
537 <para>
538 where <replaceable>xxx.xxx.xxx.xxx</replaceable> is the IP address 
539 of the WINS server.
540 </para>
541
542 </sect2>
543 </sect1>
544
545 </chapter>