s3: Make open_file_ntcreate a bit easier to read
[kai/samba.git] / docs-xml / using_samba / ch03.xml
1 <chapter label="3" id="SAMBA-CH-3">
2 <title>Configuring Windows Clients</title>
3
4
5
6
7 <para>
8 <indexterm id="ch03-idx-947918-0" class="startofrange"><primary>Windows clients</primary><secondary>configuring</secondary></indexterm>
9 <indexterm id="ch03-idx-947918-1" class="startofrange"><primary>configuring Windows clients</primary></indexterm>You'll be glad to know that configuring Windows to use your new Samba server is quite simple. SMB is Microsoft's native language for resource sharing on a local area network, so much of the installation and setup on the Windows client side has been taken care of already. The primary issues that we will cover in this chapter involve communication and coordination between Windows and Unix, two completely different operating systems.</para>
10
11
12 <para>Samba uses TCP/IP to talk to its clients on the network. If you aren't already using TCP/IP on your Windows computers, this chapter will show you how to install it. Then you'll need to configure your Windows machines to operate on a TCP/IP network. Once these two requirements have been taken care of, we can show how to access a shared disk on the Samba server.</para>
13
14
15 <para>This chapter is divided into three sections. The first section covers setting up Windows 95/98 computers while the second covers Windows NT 4.0 machines. The final section provides some prerequisite information on how SMB connections are made from Windows clients and servers, which is useful as we move into the later chapters of the book.</para>
16
17
18
19
20
21
22
23
24
25
26
27 <sect1 role="" label="3.1" id="ch03-55770">
28 <title>Setting Up Windows 95/98 Computers</title>
29
30
31 <para>
32 <indexterm id="ch03-idx-947927-0" class="startofrange"><primary>Windows clients</primary><secondary>configuring</secondary><tertiary>Windows95/98 computers</tertiary></indexterm>
33 <indexterm id="ch03-idx-947927-1" class="startofrange"><primary>configuring Windows clients</primary><secondary>Windows 95/98 computers</secondary></indexterm>Unfortunately, Windows 95/98 wasn't designed for a PC to have more than one user; that concept is more inherent to a Unix operating system or Windows NT. However, <indexterm id="ch03-idx-947953-0"><primary>Windows 95/98</primary><secondary>multiple users, support for</secondary></indexterm>Windows 95/98 does have <emphasis>limited</emphasis> support for multiple users: if you tell it, the operating system will keep a separate <indexterm id="ch03-idx-947955-0"><primary>user profiles (Windows 95/98)</primary></indexterm>profile (desktop layout) and password file for each user. This is a far cry from true multiuser security. In other words, Windows 95/98 won't try to keep one user from destroying the work of another on the local hard drive like Unix, but profiles are a place to start.</para>
34
35
36 <sect2 role="" label="3.1.1" id="ch03-SECT-1.1">
37 <title>Accounts and Passwords</title>
38
39
40 <para>
41 <indexterm id="ch03-idx-947956-0" class="startofrange"><primary>accounts</primary></indexterm>
42 <indexterm id="ch03-idx-947956-1" class="startofrange"><primary>passwords</primary><secondary>Windows 95/98</secondary></indexterm>
43 <indexterm id="ch03-idx-947956-2" class="startofrange"><primary>usernames</primary><secondary>Windows 95/98</secondary></indexterm>The first thing we need to do is to tell Windows to keep user profiles separate, and to collect usernames and passwords to authenticate anyone trying to access a Samba share. We do so via the <indexterm id="ch03-idx-947957-0"><primary>Password settings (Windows 95/98)</primary></indexterm>Password settings in the Control Panel. If you are not familiar with the Windows Control Panel, you can access it by choosing the Settings menu item from the pop-up menu of the Start button in the lower-left corner of the screen. Alternatively, you'll find it as a folder under the icon in the upper-left corner that represents your computer and is typically labeled <indexterm id="ch03-idx-947958-0"><primary>My Computer (Windows 95/98)</primary></indexterm>My Computer.</para>
44
45
46 <para>After selecting the Passwords icon in the Control Panel, click on the User Profiles tab on the far right. You should see the dialog box shown in <link linkend="ch03-84319">Figure 3.1</link>. Then click the lower of the two radio buttons that starts "Users can customize their preferences...." This causes Windows to store a separate profile for each user, and saves the username and password you provide, which it will use later when it connects to an SMB/CIFS server. Finally, check <emphasis>both</emphasis> the options under the User Profile Settings border, as shown in the figure.</para>
47
48
49 <figure label="3.1" id="ch03-84319">
50 <title>The Passwords Properties panel</title>
51
52 <graphic width="502" depth="289" fileref="figs/sam.0301.gif"></graphic>
53 </figure>
54
55 <para>The next step is to select the Change Passwords tab on the left side of the dialog box. In order for Samba to allow you access to its shares, the username and password you give to Windows must match the account and password on the Samba server. If you don't have this tab in your dialog box, don't worry; it's probably because you haven't given yourself a Windows username and password yet. Simply click the OK button at the bottom and respond Yes when Windows asks to reboot. Then, skip down to <link linkend="ch03-57581">Section 3.1.1.2</link>.</para>
56
57
58 <sect3 role="" label="3.1.1.1" id="ch03-SECT-1.1.1">
59 <title>Changing the Windows password</title>
60
61
62 <para>
63 <indexterm id="ch03-idx-947966-0"><primary>passwords</primary><secondary>Windows 95/98</secondary><tertiary>changing</tertiary></indexterm>After selecting the Change Passwords tab, the dialog box in <link linkend="ch03-26778">Figure 3.2</link> will appear.</para>
64
65
66 <figure label="3.2" id="ch03-26778">
67 <title>The Change Passwords tab</title>
68
69 <graphic width="502" depth="306" fileref="figs/sam.0302.gif"></graphic>
70 </figure>
71
72 <para>Select the Change Windows Password button. The <indexterm id="ch03-idx-947967-0"><primary>Change Windows Password dialog box</primary></indexterm>Change Windows Password dialog box should appear, as shown in <link linkend="ch03-97002">Figure 3.3</link>. From here, you can change your password to match the password of the account on the Samba server through which you intend to log in.</para>
73
74
75 <figure label="3.3" id="ch03-97002">
76 <title>The Change Windows Password dialog box</title>
77
78 <graphic width="502" depth="135" fileref="figs/sam.0303.gif"></graphic>
79 </figure>
80 </sect3>
81
82
83
84 <sect3 role="" label="3.1.1.2" id="ch03-57581">
85 <title>Logging in for the first time</title>
86
87
88 <para>
89 <indexterm id="ch03-idx-947969-0"><primary>log files/logging</primary><secondary>in for the first time (Samba)</secondary></indexterm>
90 <indexterm id="ch03-idx-947969-1"><primary>Samba</primary><secondary>logging in for the first time</secondary></indexterm>If you didn't have a Change Passwords tab in the Passwords Properties window, then after Windows has finished rebooting, it will ask you to log in with a username and a password. Give yourself the same username and password that you have on the Samba server. After confirming your new username and password, or if you already have one, Windows should ask you if you want to have a <indexterm id="ch03-idx-947970-0"><primary>profiles</primary><secondary>creating</secondary></indexterm>profile, using the dialog shown in <link linkend="ch03-48947">Figure 3.4</link>. <indexterm id="ch03-idx-947961-0" class="endofrange" startref="ch03-idx-947956-0"/>
91 <indexterm id="ch03-idx-947961-1" class="endofrange" startref="ch03-idx-947956-1"/>
92 <indexterm id="ch03-idx-947961-2" class="endofrange" startref="ch03-idx-947956-2"/></para>
93
94
95 <figure label="3.4" id="ch03-48947">
96 <title>Windows Networking profiles</title>
97
98 <graphic width="502" depth="121" fileref="figs/sam.0304.gif"></graphic>
99 </figure>
100
101 <para>Answer Yes, upon which Windows will create a separate profile and password file for you and save a copy of your password in the file. Now when you connect to Samba, Windows will send its password, which will be used to authenticate you for each share. We won't worry about profiles for the moment; we'll cover them in <link linkend="SAMBA-CH-6">Chapter 6</link>. We should point out, however, that there is a small security risk: someone can steal the <indexterm id="ch03-idx-947972-0"><primary>password file, security and</primary></indexterm>password file and decrypt the passwords because it's weakly encrypted. Unfortunately, there isn't a solution to this with Windows 95/98. In Windows 2000 (NT 5.0), the password encryption should be replaced with a much better algorithm.</para>
102 </sect3>
103 </sect2>
104
105
106
107
108
109 <sect2 role="" label="3.1.2" id="ch03-36280">
110 <title>Setting Up the Network</title>
111
112
113 <para>
114 <indexterm id="ch03-idx-947983-0" class="startofrange"><primary>networking</primary><secondary>setting up</secondary></indexterm>The next thing we need to do is make sure we have the <indexterm id="ch03-idx-947973-0"><primary>TCP/IP networking protocol</primary><secondary>checking setup</secondary></indexterm>TCP/IP networking protocol set up correctly. To do this, double-click on the <indexterm id="ch03-idx-947975-0"><primary>Network icon</primary><secondary>Windows 95/98</secondary></indexterm>Network icon in the Control Panel. You should see the network configuration dialog box, as shown in <link linkend="ch03-15320">Figure 3.5</link>.</para>
115
116
117 <figure label="3.5" id="ch03-15320">
118 <title>The Windows 95/98 Network panel</title>
119
120 <graphic width="502" depth="371" fileref="figs/sam.0305.gif"></graphic>
121 </figure>
122
123 <para>Microsoft networking works by binding specific protocols, such as IPX or TCP/IP, to a specific hardware device, such as an <indexterm id="ch03-idx-947977-0"><primary>Ethernet adaptor cards</primary></indexterm>Ethernet card or a <indexterm id="ch03-idx-948013-0"><primary>dialup connection</primary></indexterm>dialup connection. By routing a <indexterm id="ch03-idx-947976-0"><primary>protocols</primary><secondary>routed through a hardware device</secondary></indexterm>protocol through a hardware device, the machine can act as a client or server for a particular type of network. For Samba, we are interested in binding the TCP/IP protocol through a networking device, making the machine a client for Microsoft networks. Thus, when the dialog box appears, you should see at least the Client for Microsoft Networks component installed on the machine, and hopefully a networking device (preferably an Ethernet card) bound to the TCP/IP protocol. If there is only one networking hardware device, you'll see the TCP/IP protocol listed below that device. If it appears similar to <link linkend="ch03-15320">Figure 3.5</link>, the protocol is bound to the device.</para>
124
125
126 <para>You may also see <indexterm id="ch03-idx-947979-0"><primary sortas="File and Printer Sharing for Microsoft Networks">"File and Printer Sharing for Microsoft Networks"</primary></indexterm>"File and printer sharing for Microsoft Networks," which is useful. In addition, you might see <indexterm id="ch03-idx-947981-0"><primary>NetBEUI (NetBIOS Extended User Interface)</primary></indexterm>NetBEUI or <indexterm id="ch03-idx-947982-0"><primary>Novell Networking</primary></indexterm>Novell Networking, which are standard with Windows installations but undesirable when TCP/IP is running. Remove NetBEUI if you possibly can&mdash;it's unnecessary and makes debugging Windows browsing difficult. If you don't have any Novell servers on your network, you can remove Novell (IPX/SPX) as well.</para>
127
128
129 <sect3 role="" label="3.1.2.1" id="ch03-SECT-1.2.1">
130 <title>Adding TCP/IP</title>
131
132
133 <para>
134 <indexterm id="ch03-idx-947991-0" class="startofrange"><primary>TCP/IP networking protocol</primary><secondary>adding/configuring</secondary></indexterm>If you don't see TCP/IP listed at all, you'll need to install the protocol. If you already have TCP/IP, skip this section, and continue with <link linkend="ch03-48802">Section 3.1.3</link>, later in this chapter.</para>
135
136
137 <para>Installing TCP/IP isn't difficult since Microsoft distributes its own version of TCP/IP for free on their installation CD-ROM. You can add the protocol by clicking on the Add button below the component window. Indicate that you wish to add a specific protocol by selecting Protocol and clicking Add... on the following dialog box, which should look similar to <link linkend="ch03-24245">Figure 3.6</link>.</para>
138
139
140 <figure label="3.6" id="ch03-24245">
141 <title>Selecting a protocol to install</title>
142
143 <graphic width="502" depth="195" fileref="figs/sam.0306.gif"></graphic>
144 </figure>
145
146 <para>After that, select the protocol TCP/IP from manufacturer Microsoft, as shown in <link linkend="ch03-50801">Figure 3.7</link>, then click OK. After doing so, you will be returned to the network dialog. Click OK there to close the dialog box, upon which Windows will install the necessary components from disk and reboot the machine.</para>
147
148
149 <figure label="3.7" id="ch03-50801">
150 <title>Selecting a protocol to install</title>
151
152 <graphic width="502" depth="296" fileref="figs/sam.0307.gif"></graphic>
153 </figure>
154 </sect3>
155
156
157
158 <sect3 role="" label="3.1.2.2" id="ch03-SECT-1.2.2">
159 <title>Configuring TCP/IP</title>
160
161
162 <para>
163 <indexterm id="ch03-idx-948011-0"><primary>configuring TCP/IP networking protocol</primary></indexterm>If you have more than one networking device (for example, both an <indexterm id="ch03-idx-948014-0"><primary>Ethernet adaptor cards</primary><secondary>linking to TCP/IP networking protocol</secondary></indexterm>Ethernet card and a dialup networking <indexterm id="ch03-idx-948015-0"><primary>modem, linking to TCP/IP networking protocol</primary></indexterm>modem), each appropriate hardware device should be "linked" to the TCP/IP protocol with an arrow, as shown in <link linkend="ch03-61576">Figure 3.8</link>. Select the TCP/IP protocol linked to the networking device that will be accessing the Samba network. When it is highlighted, click the<indexterm id="ch03-idx-948019-0"><primary>Properties button (Windows 95/98)</primary></indexterm> Properties button.</para>
164
165
166 <figure label="3.8" id="ch03-61576">
167 <title>Selecting the correct TCP/IP protocol</title>
168
169 <graphic width="502" depth="389" fileref="figs/sam.0308.gif"></graphic>
170 </figure>
171
172 <para>After doing so, the <indexterm id="ch03-idx-948028-0"><primary>TCP/IP Properties panel (Windows 95/98)</primary></indexterm>TCP/IP Properties panel for that device is displayed, as shown in <link linkend="ch03-73526">Figure 3.9</link>.</para>
173
174
175 <figure label="3.9" id="ch03-73526">
176 <title>STCP/IP Properties panel</title>
177
178 <graphic width="502" depth="303" fileref="figs/sam.0309.gif"></graphic>
179 </figure>
180
181 <para>There are seven tabs near the top of this panel, and you will need to configure four of them:</para>
182
183
184 <itemizedlist>
185 <listitem><para>IP address</para></listitem>
186 <listitem><para>DNS configuration</para></listitem>
187 <listitem><para>WINS configuration</para></listitem>
188 <listitem><para>Bindings</para></listitem>
189 </itemizedlist>
190 </sect3>
191
192
193
194 <sect3 role="" label="3.1.2.3" id="ch03-SECT-1.2.3">
195 <title>IP Address tab </title>
196
197
198 <para>The <indexterm id="ch03-idx-948038-0"><primary>IP Address tab</primary><secondary>Windows 95/98</secondary></indexterm>
199 <indexterm id="ch03-idx-948038-1"><primary>DHCP (Dynamic Host Configuration Protocol)</primary></indexterm>IP Address tab is shown in <link linkend="ch03-73526">Figure 3.9</link>. Press the "Specify an IP address" radio button and enter the client's address and subnet <indexterm id="ch03-idx-948214-0"><primary>masks</primary><secondary>subnet</secondary></indexterm>
200 <indexterm id="ch03-idx-948214-1"><primary>subnets</primary><secondary>mask</secondary></indexterm>mask in the space provided. You or your network manager should have selected an address for the machine. The values should place the computer on the same subnet as the Samba server. For example, if the server's address is 192.168.236.86, and its network <indexterm id="ch03-idx-948217-0"><primary>masks</primary><secondary>netmasks</secondary></indexterm>
201 <indexterm id="ch03-idx-948217-1"><primary>netmasks</primary></indexterm>
202 <indexterm id="ch03-idx-948217-2"><primary>network masks</primary><see>netmasks</see></indexterm>mask 255.255.255.0, you might use address 192.168.236.10 (if it is available) for the Windows 98 computer, along with the same netmask as the server. If you already use DHCP on your network to provide IP addresses to Windows machines, select the "Obtain an IP address automatically" button.</para>
203 </sect3>
204
205
206
207 <sect3 role="" label="3.1.2.4" id="ch03-SECT-1.2.4">
208 <title>DNS Configuration tab</title>
209
210
211 <para>
212 <indexterm id="ch03-idx-948039-0"><primary>DNS Configuration tab</primary></indexterm>Domain Name Service (<indexterm id="ch03-idx-948040-0"><primary>DNS (Domain Name System)</primary></indexterm>
213 <indexterm id="ch03-idx-948040-1"><primary>Domain Name System</primary><see>DNS</see></indexterm>DNS) is responsible for translating Internet computer names such as <emphasis>hobbes.example.com</emphasis> into machine-readable IP addresses such as 192.168.236.10. There are two ways to accomplish this on a Windows 98 machine: you can specify a server to do the translation for you or you can keep a local list of name/address pairs to refer to.</para>
214
215
216 <para>Networks that are connected to the Internet typically use a server, since the hosts files required would otherwise be huge. For an unconnected LAN, the list of possible hosts is small and well-known and might be kept on a Unix machine in the <emphasis>/etc/hosts</emphasis>
217 <indexterm id="ch03-idx-948046-0"><primary sortas="etc/hosts file">/etc/hosts file</primary></indexterm> file. If you are in doubt as to whether a DNS server is being used, or what its address might be, look at the file <emphasis>/etc/resolv.conf</emphasis>
218 <indexterm id="ch03-idx-948047-0"><primary sortas="etc/resolv.conf file">/etc/resolv.conf file </primary></indexterm> on your Unix servers. Any machine using DNS will have this file, which looks like:</para>
219
220
221 <programlisting>#resolv.conf
222 domain example.com
223 nameserver 127.0.0.1
224 nameserver 192.168.236.20</programlisting>
225
226
227 <para>In the example shown, the second <literal>nameserver</literal> line in the list contains the IP address of another machine on the local network: 192.168.236.20. It's a good candidate for a DNS server.<footnote label="1" id="ch03-pgfId-942097">
228
229
230 <para>We can disqualify the other address because every Unix machine has a localhost address of 127.0.0.1 whether it is connected to a network or not. This address is required for some system tools to operate correctly.</para>
231
232
233 </footnote></para>
234
235
236 <para>You must type the correct IP address of one or more DNS servers (note that you <emphasis>cannot</emphasis> use its Internet name, such as <emphasis>dns.oreilly.com</emphasis>) into the appropriate field in <link linkend="ch03-86883">Figure 3.10</link>. Be sure not to use 127.0.0.1&mdash;that will never be the correct DNS server address!</para>
237
238
239 <para>Try to select addresses on your own network. Any name servers listed in <emphasis>/etc/resolv.conf</emphasis> should work, but you'll get better performance by using a server nearby. (If you don't find <emphasis>/etc/resolv.conf</emphasis> files on your Unix machines, just disable DNS until you can find the address of at least one DNS server.) Let's assume you only have one DNS server, and its address is 192.168.236.20. Click the Enable DNS radio button, as shown in <link linkend="ch03-86883">Figure 3.10</link>, and add the server's address to the top DNS Server Search Order field.</para>
240
241
242 <figure label="3.10" id="ch03-86883">
243 <title>The DNS Configuration tab</title>
244
245 <graphic width="502" depth="360" fileref="figs/sam.0310.gif"></graphic>
246 </figure>
247
248 <para>Also, provide the name of the Windows 95/98 machine and the Internet domain you're in. You can safely ignore the Domain Suffix Search Order field for anything related to Samba.</para>
249 </sect3>
250
251
252
253 <sect3 role="" label="3.1.2.5" id="ch03-SECT-1.2.5">
254 <title>WINS Configuration tab</title>
255
256
257 <para>
258 <indexterm id="ch03-idx-948063-0"><primary>WINS Configuration tab</primary></indexterm>WINS is the <indexterm id="ch03-idx-948065-0"><primary>WINS (Windows Internet Name Service)</primary></indexterm>
259 <indexterm id="ch03-idx-948065-1"><primary>Windows Internet Name Service</primary><see>WINS</see></indexterm>Windows Internet Name Service, its version of a <indexterm id="ch03-idx-948066-0"><primary>NetBIOS (Network Basic Input/Output System)</primary><secondary>name server (NBNS)</secondary></indexterm>NetBIOS name server. If you've enabled WINS on Samba, you must tell Windows the Samba server's address. If you are using WINS servers that are entirely Windows NT, enter each of them here as well. The dialog box shown after selecting the WINS Configuration tab is shown in <link linkend="ch03-95608">Figure 3.11</link>.</para>
260
261
262 <figure label="3.11" id="ch03-95608">
263 <title>The WINS Configuration tab</title>
264
265 <graphic width="502" depth="389" fileref="figs/sam.0311.gif"></graphic>
266 </figure>
267
268 <warning role="ora">
269 <para>Do <emphasis>not</emphasis> mix a Samba WINS server and a Windows NT server as a primary/backup combination in the WINS dialog. Because the two cannot replicate their databases, this will cause name resolution to perform incorrectly.</para>
270
271 </warning>
272
273 <para>From here, select Enable WINS Resolution and enter the <indexterm id="ch03-idx-948058-0"><primary>WINS (Windows Internet Name Service)</primary><secondary>servers</secondary></indexterm>WINS server's address in the space provided, then press Add. Do not enter anything in the Scope ID field.</para>
274 </sect3>
275
276
277
278 <sect3 role="" label="3.1.2.6" id="ch03-SECT-1.2.6">
279 <title>Hosts files</title>
280
281
282 <para>
283 <indexterm id="ch03-idx-948067-0"><primary>hosts</primary><secondary>files (Windows 95/98)</secondary></indexterm>If you do not have either DNS or WINS, and you don't wish to use <indexterm id="ch03-idx-948070-0"><primary>broadcast resolution</primary></indexterm>broadcast resolution, you'll need to provide a table of IP addresses and hostnames, in the standard Unix <filename>/etc/hosts</filename> format. On a Windows machine, this goes in <indexterm id="ch03-idx-948075-0"><primary sortas="Windows/HOSTS directory">\WINDOWS\HOSTS directory</primary></indexterm>\WINDOWS\HOSTS under whichever drive you installed Windows on (typically C:\). A sample host file follows:</para>
284
285
286 <programlisting># 127.0.0.1             localhost
287 192.168.236.1       escrime.example.com         escrime
288 192.168.236.2      riposte.example.com  riposte
289 192.168.236.3       wizzin.example.com  wizzin
290 192.168.236.4       touche.example.com  touche
291 192.168.236.10     hobbes.example.com   hobbes</programlisting>
292
293
294 <para>You can copy this file directly from any of your Unix machines' <emphasis>/etc/hosts</emphasis> <indexterm id="ch03-idx-948074-0"><primary sortas="etc/hosts file">/etc/hosts file</primary></indexterm>; the format is identical. However, <emphasis>you should only use hosts files in Windows as a last resort for name resolution</emphasis>
295 <indexterm id="ch03-idx-948069-0"><primary>name resolution</primary></indexterm>.</para>
296 </sect3>
297
298
299
300 <sect3 role="" label="3.1.2.7" id="ch03-SECT-1.2.7">
301 <title>Check the bindings</title>
302
303
304 <para>The final tab to look at is <indexterm id="ch03-idx-948076-0"><primary>Bindings tab</primary></indexterm>Bindings, as shown in <link linkend="ch03-42906">Figure 3.12</link>.</para>
305
306
307 <figure label="3.12" id="ch03-42906">
308 <title>The Bindings tab</title>
309
310 <graphic width="502" depth="249" fileref="figs/sam.0312.gif"></graphic>
311 </figure>
312
313 <para>You should have a check beside Client for Microsoft Networks, indicating that it's using TCP/IP. If you have <indexterm id="ch03-idx-948077-0"><primary sortas="File and Printer Sharing for Microsoft Networks">"File and Printer Sharing for Microsoft Networks"</primary></indexterm>"File and printer sharing for Microsoft Networks" in the dialog, it should also be checked, as shown in the figure.<indexterm id="ch03-idx-947986-0" class="endofrange" startref="ch03-idx-947983-0"/></para>
314 </sect3>
315 </sect2>
316
317
318
319
320
321 <sect2 role="" label="3.1.3" id="ch03-48802">
322 <title>Setting Your Name and Workgroup </title>
323
324
325 <para>
326 <indexterm id="ch03-idx-948082-0"><primary>naming</primary><secondary>TCP/IP networking protocol, setting machine name for</secondary></indexterm>
327 <indexterm id="ch03-idx-948082-1"><primary>workgroups</primary><secondary>setting</secondary></indexterm>Finally, press the OK button in the TCP/IP configuration panel, and you'll be taken back to the Network Configuration screen. Then select the <indexterm id="ch03-idx-948078-0"><primary>Identification tab</primary></indexterm>Identification tab, which will take you to the dialog box shown in <link linkend="ch03-42408">Figure 3.13</link>.</para>
328
329
330 <figure label="3.13" id="ch03-42408">
331 <title>The Identification tab</title>
332
333 <graphic width="502" depth="285" fileref="figs/sam.0313.gif"></graphic>
334 </figure>
335
336 <para>Here, for the second time, set your machine's name. This time, instead of your DNS hostname and domain, you're setting your <indexterm id="ch03-idx-948084-0"><primary>NetBIOS name</primary><secondary>setting</secondary><tertiary>Windows 95/98</tertiary></indexterm>NetBIOS name. However, it is best to make this the <emphasis>same</emphasis> as your hostname. Try not to make a <indexterm id="ch03-idx-948085-0"><primary>spelling, caution with</primary></indexterm>spelling mistake: it can be very confusing to configure a machine if TCP thinks it's <literal>fred</literal> and SMB thinks its <literal>ferd</literal> !</para>
337
338
339 <para>You also set your workgroup name here. In our case, it's SIMPLE, but if you used a different one in <link linkend="SAMBA-CH-2">Chapter 2</link>, when creating the Samba configuration file, use that here as well. Try to avoid calling it WORKGROUP or you'll be in the same workgroup as every unconfigured (or ill-configured) machine in the world.</para>
340 </sect2>
341
342
343
344
345
346 <sect2 role="" label="3.1.4" id="ch03-13238">
347 <title>Accessing the Samba Server</title>
348
349
350 <para>
351 <indexterm id="ch03-idx-948086-0"><primary>Samba server</primary><secondary>accessing</secondary></indexterm>
352 <indexterm id="ch03-idx-948086-1"><primary>accessing Samba server</primary></indexterm>Click on the OK button to complete the configuration; you will need to reboot in order for your changes to take effect.</para>
353
354
355 <para>Now for the big moment. Your Samba server is running, and you have set up your Windows 95/98 client to communicate with it. After rebooting, log in and double-click the <indexterm id="ch03-idx-948087-0"><primary>Network Neighborhood icon</primary></indexterm>Network Neighborhood icon on the desktop. You should see your Samba server listed as a member of the workgroup, as shown in <link linkend="ch03-88553">Figure 3.14</link>.</para>
356
357
358 <figure label="3.14" id="ch03-88553">
359 <title>Windows Network Neighborhood</title>
360
361 <graphic width="502" depth="139" fileref="figs/sam.0314.gif"></graphic>
362 </figure>
363
364 <para>Double-clicking the server name will show the resources that the server is offering to the network, as shown in <link linkend="ch03-17463">Figure 3.15</link> (in this case a printer and the <emphasis>test</emphasis> directory).</para>
365
366
367 <figure label="3.15" id="ch03-17463">
368 <title>Shares on Server</title>
369
370 <graphic width="502" depth="152" fileref="figs/sam.0315.gif"></graphic>
371 </figure>
372
373 <warning role="ora">
374 <para>If you are presented with a dialog requesting the password for a user <literal>IPC$</literal>, then Samba did not accept the password that was sent from the client. In this case, the username and the password that were created on the client side <emphasis>must</emphasis> match the username/password combination on the Samba server. If you are using Windows 98 or Windows NT Service Pack 3 or above, this is probably because the client is sending encrypted passwords instead of plaintext passwords. You can remedy this situation by performing two steps on the Samba server. First, add the following entry to the <literal>[global]</literal> section of your Samba configuration file: <literal>encrypt password=yes</literal>. Second, find the <filename>smbpasswd</filename> program on the samba server (it is located in <filename>/usr/local/samba/bin</filename> by default) and use it to add an entry to Samba's encrypted password database. For example, to add user <literal>steve</literal> to Samba's encrypted password database, type <replaceable>smbpasswd  -a steve</replaceable>. The first time you enter this password, the program will output an error message indicating that the password database does not exist; it will then create the database, which is typically stored in <filename>/usr/local/samba/private/smbpasswd</filename>.</para>
375
376 </warning>
377
378 <para>If you don't see the server listed, start Windows Explorer (not Internet Explorer!) and select <indexterm id="ch03-idx-948088-0"><primary>Map Network Drive option</primary></indexterm>Map Network Drive from the Tools menu. This will give you a dialog box into which you can type the name of your server and the share <literal>test </literal>in the <indexterm id="ch03-idx-948089-0"><primary>Windows UNC format</primary></indexterm>Windows UNC format: <filename>\\</filename><replaceable>server</replaceable><filename>\test</filename>, like we did in the first chapter. This should attempt to contact the Samba server and its temporary share. If things still aren't right, go to <link linkend="SAMBA-CH-9">Chapter 9</link>, for troubleshooting assistance.<indexterm id="ch03-idx-947933-0" class="endofrange" startref="ch03-idx-947927-0"/>
379 <indexterm id="ch03-idx-947933-1" class="endofrange" startref="ch03-idx-947927-1"/></para>
380 </sect2>
381 </sect1>
382
383
384
385
386
387
388
389
390
391 <sect1 role="" label="3.2" id="ch03-23093">
392 <title>Setting Up Windows NT 4.0 Computers</title>
393
394
395 <para>
396 <indexterm id="ch03-idx-947940-0" class="startofrange"><primary>Windows clients</primary><secondary>configuring</secondary><tertiary>Windows NT 4.0 computers</tertiary></indexterm>
397 <indexterm id="ch03-idx-947940-1" class="startofrange"><primary>configuring Windows clients</primary><secondary>Windows NT 4.0 computers</secondary></indexterm>Configuring Windows NT is a little different than configuring Windows 95/98. In order to use Samba with Windows NT, you will need both the Workstation service and the TCP/IP protocol. Both come standard with NT, but we'll work through installing and configuring them because they may not be configured correctly.</para>
398
399
400 <para>There are six basic steps:</para>
401
402
403 <orderedlist>
404 <listitem><para>Assign the machine a name.</para></listitem>
405 <listitem><para>Install the Workstation service.</para></listitem>
406 <listitem><para>Install the TCP/IP protocol.</para></listitem>
407 <listitem><para>Set the machine's name and IP address.</para></listitem>
408 <listitem><para>Configure the DNS and WINS name services.</para></listitem>
409 <listitem><para>Bind the protocol and service together.</para></listitem>
410 </orderedlist>
411
412 <sect2 role="" label="3.2.1" id="ch03-SECT-2.1">
413 <title>Basic Configuration</title>
414
415
416 <para>
417 <indexterm id="ch03-idx-948108-0" class="startofrange"><primary>configuring Windows clients</primary><secondary>Windows NT 4.0 computers</secondary><tertiary>basic configuration</tertiary></indexterm>This section presents an outline of the steps to follow for getting Windows NT to cooperate with Samba. If you need more details on Windows NT network administration, refer to Craig Hunt and Robert Bruce Thompsom's <citetitle>Windows NT TCP/IP Network Administration </citetitle>(O'Reilly), an excellent guide. You should perform these steps as the "Administrator" user.</para>
418
419
420 <sect3 role="" label="3.2.1.1" id="ch03-SECT-2.1.1">
421 <title>Name the machine</title>
422
423
424 <para>
425 <indexterm id="ch03-idx-948120-0"><primary>naming</primary><secondary>NT computers</secondary></indexterm>
426 <indexterm id="ch03-idx-948120-1"><primary>Windows NT</primary><secondary>naming, caution with</secondary></indexterm>The first thing you need to do is to give the machine a <indexterm id="ch03-idx-948122-0"><primary>NetBIOS name</primary><secondary>setting</secondary><tertiary>Windows NT</tertiary></indexterm>NetBIOS name. From the Control Panel, double click on the <indexterm id="ch03-idx-948123-0"><primary>Network icon</primary><secondary>Windows NT</secondary></indexterm>Network icon. This will take you to the <indexterm id="ch03-idx-948124-0"><primary>Network dialog box (Windows NT)</primary></indexterm>Network dialog box for the machine. The first tab in this dialog box should be the Identification tab, as illustrated in <link linkend="ch03-82592">Figure 3.16</link>.</para>
427
428
429 <figure label="3.16" id="ch03-82592">
430 <title>Network panel Identification tab</title>
431
432 <graphic width="502" depth="260" fileref="figs/sam.0316.gif"></graphic>
433 </figure>
434
435 <para>Here, you need to identify your machine with a name (we use the name Artish here) and change the default workgroup to the one you specified in the <emphasis>smb.conf</emphasis>
436 <indexterm id="ch03-idx-948125-0"><primary>smb.conf (Samba configuration) file</primary></indexterm> file of your Samba server. In this case, the workgroup name is SIMPLE. However, you cannot edit either name here (as you could in Windows 95/98), but instead must use the Change button below the two text fields. Pressing this button raises an <indexterm id="ch03-idx-948126-0"><primary>Identification Changes dialog box (Windows NT)</primary></indexterm>Identification Changes dialog box, where you can reset the workgroup and the machine name, as shown in <link linkend="ch03-67735">Figure 3.17</link>.</para>
437
438
439 <figure label="3.17" id="ch03-67735">
440 <title>Changing the identification</title>
441
442 <graphic width="502" depth="360" fileref="figs/sam.0317.gif"></graphic>
443 </figure>
444
445 <para>
446 <indexterm id="ch03-idx-948129-0"><primary>naming</primary><secondary>NT computers</secondary><tertiary>caution with</tertiary></indexterm>A word of warning: you will have to set the machine name again later while configuring TCP/IP, so be sure that the two names match. The name you set here is the NetBIOS name. You're allowed to make it different from the TCP/IP hostname, but doing so is usually not a good thing. Don't worry that Windows NT forces the computer name and the workgroup to be all capital letters; it's smart enough to figure out what you mean when it connects to the network.</para>
447 </sect3>
448
449
450
451 <sect3 role="" label="3.2.1.2" id="ch03-SECT-2.1.2">
452 <title>Installing the TCP/IP protocol</title>
453
454
455 <para>
456 <indexterm id="ch03-idx-948143-0"><primary>TCP/IP networking protocol</primary><secondary>installing</secondary></indexterm>
457 <indexterm id="ch03-idx-948143-1"><primary>installing TCP/IP protocol</primary></indexterm>Next, select the <indexterm id="ch03-idx-948150-0"><primary>Protocols tab</primary></indexterm>Protocols tab in the Network dialog box, and look to see if you have the TCP/IP protocol installed, as shown in <link linkend="ch03-66055">Figure 3.18</link>.</para>
458
459
460 <figure label="3.18" id="ch03-66055">
461 <title>The Protocols tab</title>
462
463 <graphic width="502" depth="257" fileref="figs/sam.0318.gif"></graphic>
464 </figure>
465
466 <para>If the protocol is not installed, you need to add it. Press the Add button, which will display the <indexterm id="ch03-idx-948148-0"><primary>Select Network Protocol dialog box</primary></indexterm>Select Network Protocol dialog box shown in <link linkend="ch03-22321">Figure 3.19</link>. Unlike Windows 95/98, you should immediately see the TCP/IP protocol as one of the last protocols listed.</para>
467
468
469 <figure label="3.19" id="ch03-22321">
470 <title>Select Network Protocol dialog box</title>
471
472 <graphic width="502" depth="285" fileref="figs/sam.0319.gif"></graphic>
473 </figure>
474
475 <para>Select TCP/IP<emphasis></emphasis> as the protocol and confirm it. If possible, install only the TCP/IP protocol. You usually do not want <indexterm id="ch03-idx-948149-0"><primary>NetBEUI (NetBIOS Extended User Interface)</primary><secondary>Windows NT computers and</secondary></indexterm>NetBEUI installed because this causes the machine to look for services under two different protocols, only one of which is likely in use.<footnote label="2" id="ch03-pgfId-943371">
476
477
478 <para>A common occurrence: after looking at the unused protocol for a while, the machine will time out and try the good one. This fruitless searching gives you terrible performance and mysterious delays.</para>
479
480
481 </footnote></para>
482 </sect3>
483
484
485
486 <sect3 role="" label="3.2.1.3" id="ch03-SECT-2.1.3">
487 <title>Installing the Workstation service</title>
488
489
490 <para>
491 <indexterm id="ch03-idx-948151-0"><primary>Workstation service, installing</primary></indexterm>
492 <indexterm id="ch03-idx-948151-1"><primary>installing Workstation service</primary></indexterm>
493 <indexterm id="ch03-idx-948151-2"><primary>services</primary><secondary>Workstation</secondary></indexterm>After installing TCP/IP, press the <indexterm id="ch03-idx-948152-0"><primary>Services tab</primary></indexterm>Services tab in the Network panel and check that you have a Workstation service, as shown at the end of the list in <link linkend="ch03-97222">Figure 3.20</link>.</para>
494
495
496 <figure label="3.20" id="ch03-97222">
497 <title>Network Services panel dialog box</title>
498
499 <graphic width="502" depth="289" fileref="figs/sam.0320.gif"></graphic>
500 </figure>
501
502 <para>This service is actually the <indexterm id="ch03-idx-948153-0"><primary>Microsoft Networking Client</primary></indexterm>Microsoft Networking Client, which allows the machine to access SMB services. The Workstation service is mandatory. The service is installed by default on both <indexterm id="ch03-idx-948154-0"><primary>Windows NT Workstation 4.0</primary></indexterm>
503 <indexterm id="ch03-idx-948155-0"><primary>Windows NT Server 4.0</primary></indexterm>Windows NT Workstation 4.0 and <indexterm id="ch03-idx-948159-0"><primary>TCP/IP networking protocol</primary><secondary>installing</secondary></indexterm>
504 <indexterm id="ch03-idx-948159-1"><primary>installing TCP/IP protocol</primary></indexterm>Server 4.0. If it's not there, you can install it much like TCP/IP. In this case you need to press the Add button and then select Workstation Service, as shown in <link linkend="ch03-40000">Figure 3.21</link>.</para>
505
506
507 <figure label="3.21" id="ch03-40000">
508 <indexterm id="ch03-idx-948115-0" class="endofrange" startref="ch03-idx-948108-0"/><title>Select Network Service dialog box </title>
509
510 <graphic width="502" depth="285" fileref="figs/sam.0321.gif"></graphic>
511 </figure>
512 </sect3>
513 </sect2>
514
515
516
517
518
519 <sect2 role="" label="3.2.2" id="ch03-85837">
520 <title>Configuring TCP/IP</title>
521
522
523 <para>
524 <indexterm id="ch03-idx-948163-0" class="startofrange"><primary>TCP/IP networking protocol</primary><secondary>configuring</secondary></indexterm>
525 <indexterm id="ch03-idx-948163-1" class="startofrange"><primary>configuring TCP/IP networking protocol</primary></indexterm>After you've installed the Workstation service, return to the <indexterm id="ch03-idx-948172-0"><primary>Protocols tab</primary></indexterm>Protocols tab and select the TCP/IP Protocol entry in the window. Then click the Properties button below the window. The Microsoft TCP/IP Protocol panel will be displayed. There are five tabs on the Windows NT panel, and (like Windows 95/98) you will need to work on three of them:</para>
526
527
528 <itemizedlist>
529 <listitem><para>IP address</para></listitem>
530 <listitem><para>DNS</para></listitem>
531 <listitem><para>WINS address</para></listitem>
532 </itemizedlist>
533
534 <sect3 role="" label="3.2.2.1" id="ch03-SECT-2.2.1">
535 <title>IP Address tab</title>
536
537
538 <para>
539 <indexterm id="ch03-idx-948191-0"><primary>IP Address tab</primary><secondary>Windows NT</secondary></indexterm>The IP Address tab is shown in <link linkend="ch03-97098">Figure 3.22</link>.</para>
540
541
542 <figure label="3.22" id="ch03-97098">
543 <title>Microsoft TCP/IP Properties for Windows NT</title>
544
545 <graphic width="502" depth="380" fileref="figs/sam.0322.gif"></graphic>
546 </figure>
547
548 <para>
549 <indexterm id="ch03-idx-948212-0"><primary>Windows NT</primary><secondary>IP address, setting</secondary></indexterm>
550 <indexterm id="ch03-idx-948212-1"><primary>IP address</primary><secondary>setting for Windows NT computers</secondary></indexterm>Select the "Specify an IP address" radio button and enter the computer's address and <indexterm id="ch03-idx-948231-0"><primary>subnets</primary><secondary>mask</secondary></indexterm>
551 <indexterm id="ch03-idx-948231-1"><primary>masks</primary><secondary>subnet</secondary></indexterm>subnet mask in the space provided for the proper adapter (Ethernet card). You or your network manager should have selected an address for the client on the same subnet (LAN) as the Samba server. For example, if the server's address is 192.168.236.86 and its network mask 255.255.255.0, you might use the address 192.168.236.10, if it is available, for the NT workstation, along with the same <indexterm id="ch03-idx-948235-0"><primary>netmasks</primary></indexterm>netmask. If you use <indexterm id="ch03-idx-948242-0"><primary>DHCP (Dynamic Host Configuration Protocol)</primary></indexterm>DHCP on your network, select the "Obtain an IP Address from a DHCP server" button.</para>
552
553
554 <tip role="ora">
555 <para>If you don't have an IP address to use, and you are on a network by yourself, steal ours, as the 192.168.<emphasis>x.x</emphasis> subnet is specifically reserved by the Internic for LANs. If you're not by yourself, see your system administrator for some available addresses on your network.</para>
556
557 </tip>
558
559 <para>The<indexterm id="ch03-idx-948244-0"><primary>gateway field</primary></indexterm> gateway field refers to a machine typically known as a <emphasis>router</emphasis>
560 <indexterm id="ch03-idx-948243-0"><primary>routers, TCP/IP configuring and</primary></indexterm>. If you have routers connecting multiple networks, you should put in the IP address of the one on your subnet.</para>
561 </sect3>
562
563
564
565 <sect3 role="" label="3.2.2.2" id="ch03-SECT-2.2.2">
566 <title>DNS tab</title>
567
568
569 <para>
570 <indexterm id="ch03-idx-948199-0"><primary>DNS (Domain Name System)</primary><secondary>tab</secondary></indexterm>Next we go to the tab for DNS, as shown in <link linkend="ch03-61878">Figure 3.23</link>. This brings up the DNS panel.</para>
571
572
573 <figure label="3.23" id="ch03-61878">
574 <title>The DNS panel</title>
575
576 <graphic width="502" depth="407" fileref="figs/sam.0323.gif"></graphic>
577 </figure>
578
579 <para>The <indexterm id="ch03-idx-948248-0"><primary>DNS (Domain Name System)</primary><secondary>configuring</secondary></indexterm>
580 <indexterm id="ch03-idx-948248-1"><primary>configuring DNS (Windows NT)</primary></indexterm>Domain Name System (DNS) is responsible for translating human-readable computer names such as <emphasis>atrish.example.com</emphasis> into IP addresses such as 192.168.236.10. There are two ways to accomplish this on a NT machine. First, you can specify a DNS server to do the translation for you, or you can keep a local list of name/address pairs for your workstation to refer to.</para>
581
582
583 <para>For a LAN that's not on the Internet, the list of possible hosts is typically small and well known, and may be kept in a file locally. Networks that are connected to the Internet typically use DNS service since it isn't possible to guess ahead of time what addresses you might be accessing out on the net. If you are in doubt as to whether a DNS server is being used, or what its address might be, look at the file <emphasis>/etc/resolv.conf</emphasis> on your Samba server: any machine using DNS will have this file. It looks like the following:</para>
584
585
586 <programlisting>#resolv.conf
587 domain example.com
588 nameserver 127.0.0.1
589 nameserver 192.168.236.20</programlisting>
590
591
592 <para>In this example, the first nameserver in the list is 127.0.0.1, which indicates that the Samba server is also a DNS server for this LAN.<footnote label="3" id="ch03-pgfId-946587">
593
594
595 <para>The address 127.0.0.1 is known as the <emphasis>localhost</emphasis>
596 <indexterm id="ch03-idx-948263-0"><primary>localhost</primary><secondary>address</secondary></indexterm> address, and always refers to itself. For example, if you type <literal>ping 127.0.0.1</literal> on a Unix server, you should always get a response, as you're pinging the host itself.</para>
597
598
599 </footnote> In that case, you would use its network IP address (not 127.0.0.1, its localhost address) when filling in the DNS Configuration dialog box. Otherwise, use the other addresses you find in the lines beginning with <literal>nameserver</literal>. Try to select ones on your own network. Any name servers listed in <emphasis>/etc/resolv.conf</emphasis> should work, but you'll get better performance by using a server nearby.</para>
600
601
602 <para>Finally, enter the machine name once more, making sure that it's the same one listed in the Identification tab of the Network dialog box (before the NetBIOS name). Also, enter the DNS domain on which this machine resides. For example, if your workstation has a domain name such as <emphasis>example.com</emphasis>, enter it here. You can safely ignore the other options.</para>
603 </sect3>
604
605
606
607 <sect3 role="" label="3.2.2.3" id="ch03-SECT-2.2.3">
608 <title>WINS Address tab</title>
609
610
611 <para>
612 <indexterm id="ch03-idx-948207-0"><primary>WINS Address tab (Windows NT panel)</primary></indexterm>
613 <indexterm id="ch03-idx-948207-1"><primary>WINS (Windows Internet Name Service)</primary><secondary>address, configuring</secondary></indexterm>
614 <indexterm id="ch03-idx-948207-2"><primary>configuring WINS address</primary></indexterm>If you are not using a DNS server, you still need a way of translating NetBIOS names to addresses and back again. We recommend that you configure both DNS and WINS; <indexterm id="ch03-idx-948268-0"><primary>Windows NT</primary><secondary>WINS address and</secondary></indexterm>NT has a preference for WINS and WINS can use DNS as a fallback if  it cannot resolve any machine address. The WINS Address tab is shown in <link linkend="ch03-20855">Figure 3.24</link>.</para>
615
616
617 <figure label="3.24" id="ch03-20855">
618 <title>The WINS Address tab</title>
619
620 <graphic width="502" depth="342" fileref="figs/sam.0324.gif"></graphic>
621 </figure>
622
623 <para>If you have a WINS server, enter its address in the space marked Primary WINS Server. If your Samba server is providing WINS service (in other words, you have the line <literal>wins</literal> <literal>service</literal> <literal>=</literal> <literal>yes</literal> in the <emphasis>smb.conf</emphasis> file of your Samba server), provide the Samba server's IP address here. Otherwise, provide the address of another WINS server on your network.</para>
624
625
626 <para>You probably noticed that there is a field here for the adaptor; this field must specify the <indexterm id="ch03-idx-948269-0"><primary>Ethernet adaptor cards</primary></indexterm>Ethernet adaptor that you're running TCP/IP on so that WINS will provide name service on the correct network. If you have both a LAN and a dialup adaptor, make sure you have the LAN's adaptor here.</para>
627
628
629 <para>Finally, select the "Enable DNS for Windows Resolution" checkbox, so WINS will try <indexterm id="ch03-idx-948270-0"><primary>DNS (Domain Name System)</primary><secondary sortas="fallback for WINS address">as fallback for WINS address</secondary></indexterm>DNS as a fallback if it can't find a name. You can safely ignore the other options.</para>
630 </sect3>
631
632
633
634 <sect3 role="" label="3.2.2.4" id="ch03-SECT-2.2.4">
635 <title>Hosts files</title>
636
637
638 <para>
639 <indexterm id="ch03-idx-948271-0"><primary>hosts</primary><secondary>files (Windows NT computers)</secondary></indexterm>If you don't have either DNS or WINS, and you don't wish to use broadcast name resolution, you'll need to provide a table of IP addresses and hosts names, in standard Unix <filename>/etc/hosts</filename> format. We recommend against this because maintenance of this file on any dynamic network is troublesome, but we will explain it just the same. The Windows host file should appear in the <emphasis>\WINDOWS\HOSTS</emphasis>
640 <indexterm id="ch03-idx-948273-0"><primary sortas="WINDOWS\HOSTS directory">\WINDOWS\HOSTS directory</primary></indexterm> directory of whatever local drive Windows is installed on. A sample follows:</para>
641
642
643 <programlisting>127.0.0.1       localhost
644 192.168.236.1    escrime    escrime.example.com
645 192.168.236.2    riposte    riposte.example.com
646 192.168.236.3    wizzin     wizzin.example.com
647 192.168.236.4    touche     touche.example.com
648 192.168.236.5    gurgi      gurgi.example.com
649 192.168.236.6    jessiac    jessiac.example.com
650 192.168.236.7    skyline    skyline.example.com</programlisting>
651
652
653 <para>If you wish, you can copy the contents directly from the Samba server's<filename> /etc/hosts</filename>. The format is identical. This file will then serve the same purpose as the hosts file on the Unix server. Again, <emphasis>hosts</emphasis> files on Windows should only be used as a last resort.</para>
654 </sect3>
655
656
657
658 <sect3 role="" label="3.2.2.5" id="ch03-SECT-2.2.5">
659 <title>Bindings</title>
660
661
662 <para>The term <firstterm>bindings</firstterm>
663 <indexterm id="ch03-idx-948274-0"><primary>bindings</primary></indexterm>
664 <indexterm id="ch03-idx-948274-1"><primary>service bindings</primary></indexterm> is a way of saying "connected together at configuration time." It means that the TCP/IP protocol will channel through the Ethernet card (instead of, say, a dialup connection), and is actually connected properly. If you return to the Network dialog box and set the Show field to "all services" and click on all the + buttons in the tree, you should see a display similar to <link linkend="ch03-83060">Figure 3.25</link>.</para>
665
666
667 <figure label="3.25" id="ch03-83060">
668 <title>Service bindings</title>
669
670 <graphic width="502" depth="332" fileref="figs/sam.0325.gif"></graphic>
671 </figure>
672
673 <para>This means that the Workstation, Server, and NetBIOS interface services are connected to the WINS client. This is the correct binding for Microsoft TCP/IP.<indexterm id="ch03-idx-948166-0" class="endofrange" startref="ch03-idx-948163-0"/>
674 <indexterm id="ch03-idx-948166-1" class="endofrange" startref="ch03-idx-948163-1"/></para>
675 </sect3>
676 </sect2>
677
678
679
680
681
682 <sect2 role="" label="3.2.3" id="ch03-SECT-2.3">
683 <title>Connecting to the Samba Server</title>
684
685
686 <para>
687 <indexterm id="ch03-idx-948286-0"><primary>Samba server</primary><secondary>connecting to</secondary></indexterm>You can safely leave the default values for the remainder of the tabs in the Network dialog box. Click on the OK button to complete the configuration. Once the proper files are loaded (if any), you will need to reboot in order for your changes to take effect.</para>
688
689
690 <para>Now for the big moment. Your Samba server is running and you have set up your NT client to communicate with it. After the machine reboots, login and double-click the <indexterm id="ch03-idx-948283-0"><primary>Network Neighborhood icon</primary><secondary>viewing Samba server</secondary></indexterm>
691 <indexterm id="ch03-idx-948283-1"><primary>Samba server</primary><secondary>viewing via Network Neighborhood icon</secondary></indexterm>Network Neighborhood icon on the desktop, and you should see your Samba server listed as a member of the workgroup, as shown in <link linkend="ch03-50785">Figure 3.26</link>.</para>
692
693
694 <figure label="3.26" id="ch03-50785">
695 <title>Windows NT Network Neighborhood</title>
696
697 <graphic width="502" depth="163" fileref="figs/sam.0326.gif"></graphic>
698 </figure>
699
700 <para>
701 <indexterm id="ch03-idx-949153-0"><primary>Samba server</primary><secondary>resources offered</secondary></indexterm>Double-clicking the server name will show the resources that the server is offering to the network, as shown in <link linkend="ch03-89532">Figure 3.27</link>. In this case, the test and the default printer are offered to the Window NT workstation. For more information, see the warning under <link linkend="ch03-13238">Section 3.1.4</link> earlier in this chapter.</para>
702
703
704 <figure label="3.27" id="ch03-89532">
705 <title>Server's shares</title>
706
707 <graphic width="502" depth="152" fileref="figs/sam.0327.gif"></graphic>
708 </figure>
709
710 <warning role="ora">
711 <para>If you are presented with a dialog requesting the password for a user <literal>IPC$</literal>, then Samba did not accept the password that was sent from the client. In this case, the username and the password that were created on the client side <emphasis>must</emphasis> match the username/password combination on the Samba server. If you are using Windows 98 or Windows NT Service Pack 3 or above, this is probably because the client is sending encrypted passwords instead of plaintext passwords. You can remedy this situation by performing two steps on the Samba server. First, add the following entry to the <literal>[global]</literal> section of your Samba configuration file: <literal>encrypt password=yes</literal>. Second, find the <filename>smbpasswd</filename> program on the samba server (it is located in <filename>/usr/local/samba/bin</filename> by default) and use it to add an entry to Samba's encrypted password database. For example, to add user <literal>steve</literal> to Samba's encrypted password database, type <replaceable>smbpasswd  -a steve</replaceable>. The first time you enter this password, the program will output an error message indicating that the password database does not exist; it will then create the database, which is typically stored in <filename>/usr/local/samba/private/smbpasswd</filename>.</para>
712
713 </warning>
714
715 <para>If you don't see the server listed, don't panic. Start the Windows NT Explorer (not Internet Explorer!) and select Map Network Drive from the Tools menu. A dialog box appears that allows you to type the name of your server and its share directory in Windows format. For example, you would enter <filename>\\</filename><replaceable>server</replaceable><filename>\temp</filename> if your server happened to be named "server." If things still aren't right, go directly to <link linkend="ch09-29538">Section 9.2</link> in <link linkend="SAMBA-CH-9">Chapter 9</link>, to see if you can troubleshoot what is wrong with the network.</para>
716
717
718 <para>If it works, congratulations! Try writing to the server and sending data to the network printer. You will be pleasantly surprised how seamlessly everything works! Now that you've finished setting up the Samba server and its clients, we can starting talking about how Samba works and how to configure it to your liking. <indexterm id="ch03-idx-947946-0" class="endofrange" startref="ch03-idx-947940-0"/>
719 <indexterm id="ch03-idx-947946-1" class="endofrange" startref="ch03-idx-947940-1"/></para>
720 </sect2>
721 </sect1>
722
723
724
725
726
727
728
729
730
731 <sect1 role="" label="3.3" id="ch03-64069">
732 <title>An Introduction to SMB/CIFS</title>
733
734
735 <para>
736 <indexterm id="ch03-idx-948288-0" class="startofrange"><primary>SMB (Server Message Block)</primary></indexterm>We'll wrap up this chapter with a short tutorial on SMB/CIFS. SMB/CIFS is the protocol that Windows 95/98 and NT machines use to communicate with the Samba server and each other. At a high level, the SMB protocol suite is relatively simple. It includes commands for all of the file and print operations that you might do on a local disk or printer, such as:</para>
737
738
739 <itemizedlist>
740 <listitem><para> Opening and closing a file</para></listitem>
741 <listitem><para> Creating and deleting files and directories</para></listitem>
742 <listitem><para> Reading and writing a file</para></listitem>
743 <listitem><para> Searching for files</para></listitem>
744 <listitem><para> Queueing and dequeueing files to a print spool</para></listitem>
745 </itemizedlist>
746
747 <para>Each of these operations can be encoded into an SMB message and transmitted to and from a server. The original name SMB comes from their data format: these are versions of the standard DOS system-call data structures, or <firstterm>Server Message Blocks</firstterm>, redesigned for transmitting to another machine across a network.</para>
748
749
750 <sect2 role="" label="3.3.1" id="ch03-SECT-3.1">
751 <title>SMB Format</title>
752
753
754 <para>
755 <indexterm id="ch03-idx-948317-0"><primary>SMB (Server Message Block)</primary><secondary>format of</secondary></indexterm>Richard <indexterm id="ch03-idx-948318-0"><primary>Sharpe, Richard</primary></indexterm>Sharpe of the Samba team defines SMB as a "request-response" protocol.<footnote label="4" id="ch03-pgfId-942928">
756
757
758 <para>See <systemitem role="url">http://anu.samba.org/cifs/docs/what-is-smb.html</systemitem> for Richard's excellent summary of SMB.</para>
759
760
761 </footnote> In effect, this means that a client sends an SMB request to a server, and the server sends an <indexterm id="ch03-idx-948320-0"><primary>SMB (Server Message Block)</primary><secondary>resources for further information</secondary></indexterm>
762 <indexterm id="ch03-idx-948320-1"><primary>URLs (uniform resource locators)</primary><secondary>SMB (Server Message Block)</secondary></indexterm>SMB response back to the client. Rarely does a server send a message that is not in response to a client.</para>
763
764
765 <para>An SMB message is not as complex as you might think. Let's take a closer look at the internal structure of such a message. It can be broken down into two parts: the <firstterm>header</firstterm>
766 <indexterm id="ch03-idx-948321-0"><primary>header, SMB</primary></indexterm>, which is a fixed size, and the <firstterm>command string</firstterm>, whose size can vary dramatically based on the contents of the message.</para>
767
768
769 <sect3 role="" label="3.3.1.1" id="ch03-SECT-3.1.1">
770 <title>SMB header format</title>
771
772
773 <para><link linkend="ch03-31015">Table 3.1</link> shows the format of an SMB header. SMB commands are not required to use all the fields in the SMB header. For example, when a client first attempts to connect to a server, it does not yet have a <indexterm id="ch03-idx-948332-0"><primary>tree identifier (TID)</primary></indexterm>
774 <indexterm id="ch03-idx-948332-1"><primary>TID (tree identifier)</primary></indexterm>tree identifier (TID) value&mdash;one is assigned after it successfully connects&mdash;so a <indexterm id="ch03-idx-948333-0"><primary>null TID</primary></indexterm>null TID (0xFFFF) is placed in its header field. Other fields may be padded with zeros when not used.</para>
775
776
777 <para>The fields of the SMB header are listed in <link linkend="ch03-31015">Table 3.1</link>.</para>
778
779
780 <table label="3.1" id="ch03-31015">
781 <title>SMB Header Fields  </title>
782
783 <tgroup cols="3">
784 <colspec colnum="1" colname="col1"/>
785 <colspec colnum="2" colname="col2"/>
786 <colspec colnum="3" colname="col3"/>
787 <thead>
788 <row>
789
790 <entry colname="col1"><para>Field</para></entry>
791
792 <entry colname="col2"><para>Size (bytes)</para></entry>
793
794 <entry colname="col3"><para>Description</para></entry>
795
796 </row>
797
798 </thead>
799
800 <tbody>
801 <row>
802
803 <entry colname="col1"><para><literal>0xFF 'SMB'</literal></para></entry>
804
805 <entry colname="col2"><para><literal>1</literal></para></entry>
806
807 <entry colname="col3"><para>
808 <indexterm id="ch03-idx-948337-0"><primary>SMB (Server Message Block)</primary><secondary>header</secondary></indexterm>Protocol identifier</para></entry>
809
810 </row>
811
812 <row>
813
814 <entry colname="col1"><para><literal>COM</literal></para></entry>
815
816 <entry colname="col2"><para><literal>1</literal></para></entry>
817
818 <entry colname="col3"><para>Command code, from 0x00 to 0xFF</para></entry>
819
820 </row>
821
822 <row>
823
824 <entry colname="col1"><para><literal>RCLS</literal></para></entry>
825
826 <entry colname="col2"><para><literal>1</literal></para></entry>
827
828 <entry colname="col3"><para>Error class</para></entry>
829
830 </row>
831
832 <row>
833
834 <entry colname="col1"><para><literal>REH</literal></para></entry>
835
836 <entry colname="col2"><para><literal>1</literal></para></entry>
837
838 <entry colname="col3"><para>Reserved</para></entry>
839
840 </row>
841
842 <row>
843
844 <entry colname="col1"><para><literal>ERR</literal></para></entry>
845
846 <entry colname="col2"><para><literal>2</literal></para></entry>
847
848 <entry colname="col3"><para>Error code</para></entry>
849
850 </row>
851
852 <row>
853
854 <entry colname="col1"><para><literal>REB</literal></para></entry>
855
856 <entry colname="col2"><para><literal>1</literal></para></entry>
857
858 <entry colname="col3"><para>Reserved</para></entry>
859
860 </row>
861
862 <row>
863
864 <entry colname="col1"><para><literal>RES</literal></para></entry>
865
866 <entry colname="col2"><para><literal>14</literal></para></entry>
867
868 <entry colname="col3"><para>Reserved</para></entry>
869
870 </row>
871
872 <row>
873
874 <entry colname="col1"><para><literal>TID</literal></para></entry>
875
876 <entry colname="col2"><para><literal>2</literal></para></entry>
877
878 <entry colname="col3"><para>Tree identifier; a unique ID for a resource in use by client</para></entry>
879
880 </row>
881
882 <row>
883
884 <entry colname="col1"><para><literal>PID</literal></para></entry>
885
886 <entry colname="col2"><para><literal>2</literal></para></entry>
887
888 <entry colname="col3"><para>Caller process ID</para></entry>
889
890 </row>
891
892 <row>
893
894 <entry colname="col1"><para><literal>UID</literal></para></entry>
895
896 <entry colname="col2"><para><literal>2</literal></para></entry>
897
898 <entry colname="col3"><para>User identifier</para></entry>
899
900 </row>
901
902 <row>
903
904 <entry colname="col1"><para><literal>MID</literal></para></entry>
905
906 <entry colname="col2"><para><literal>2</literal></para></entry>
907
908 <entry colname="col3"><para>Multiplex identifier; used to route requests inside a process</para></entry>
909
910 </row>
911
912 </tbody>
913 </tgroup>
914 </table>
915 </sect3>
916
917
918
919 <sect3 role="" label="3.3.1.2" id="ch03-SECT-3.1.2">
920 <title>SMB command format</title>
921
922
923 <para><firstterm></firstterm>
924 <indexterm id="ch03-idx-948328-0"><primary>command string, SMB</primary></indexterm>Immediately after the header is a variable number of bytes that constitute an SMB command or reply. Each command, such as Open File (COM field identifier: <literal>SMBopen</literal>) or Get Print Queue (<literal>SMBsplretq </literal>), has its own set of parameters and data. Like the SMB header fields, not all of the command fields need to be filled, depending on the specific command. For example, the Get Server Attributes (<literal>SMBdskattr</literal>) command sets the WCT and BCC fields to zero. The fields of the command segment are shown in <link linkend="ch03-38178">Table 3.2</link>.</para>
925
926
927 <table label="3.2" id="ch03-38178">
928 <title>SMB Command Contents </title>
929
930 <tgroup cols="3">
931 <colspec colnum="1" colname="col1"/>
932 <colspec colnum="2" colname="col2"/>
933 <colspec colnum="3" colname="col3"/>
934 <thead>
935 <row>
936
937 <entry colname="col1"><para>Field</para></entry>
938
939 <entry colname="col2"><para>Size in Bytes</para></entry>
940
941 <entry colname="col3"><para>Description</para></entry>
942
943 </row>
944
945 </thead>
946
947 <tbody>
948 <row>
949
950 <entry colname="col1"><para><literal>WCT</literal></para></entry>
951
952 <entry colname="col2"><para><literal>1</literal></para></entry>
953
954 <entry colname="col3"><para><firstterm></firstterm>
955 <indexterm id="ch03-idx-948340-0"><primary>SMB (Server Message Block)</primary><secondary>command string</secondary></indexterm>Word count</para></entry>
956
957 </row>
958
959 <row>
960
961 <entry colname="col1"><para><literal>VWV</literal></para></entry>
962
963 <entry colname="col2"><para>Variable</para></entry>
964
965 <entry colname="col3"><para>Parameter words (size given by WCT)</para></entry>
966
967 </row>
968
969 <row>
970
971 <entry colname="col1"><para><literal>BCC</literal></para></entry>
972
973 <entry colname="col2"><para><literal>2</literal></para></entry>
974
975 <entry colname="col3"><para>Parameter byte count</para></entry>
976
977 </row>
978
979 <row>
980
981 <entry colname="col1"><para><literal>DATA</literal></para></entry>
982
983 <entry colname="col2"><para>Variable</para></entry>
984
985 <entry colname="col3"><para>Data (size given by BCC)</para></entry>
986
987 </row>
988
989 </tbody>
990 </tgroup>
991 </table>
992
993
994 <para>Don't worry if you don't understand each of these fields; they are not necessary for using Samba at an administrator level. However, they do come in handy when debugging system messages. We will show you some of the more common SMB messages that clients and servers send using a modified version of <filename>tcpdump</filename> later in this section. (If you would like an SMB sniffer with a graphical interface, try "ethereal," which uses the GTK libraries; see the Samba homepage for more information on this tool.)</para>
995
996
997 <tip id="ch03-resources-for-further-information" role="ora">
998 <para>If you would like more information on each of the commands for the SMB protocol, see the SMB/CIFS documentation at <systemitem role="ftpurl">ftp://ftp.microsoft.com/developr/drg/CIFS/</systemitem>.</para>
999
1000 </tip>
1001 </sect3>
1002
1003
1004
1005 <sect3 role="" label="3.3.1.3" id="ch03-SECT-3.1.3">
1006 <title>SMB variations</title>
1007
1008
1009 <para>The SMB protocol has been extended with new commands several times since its inception. Each new version is backwards compatible with the previous versions. This makes it quite possible for a LAN to have various clients and servers running different versions of the SMB protocol at once.</para>
1010
1011
1012 <para><link linkend="ch03-67366">Table 3.3</link> outlines the major versions of the SMB protocol. Within each "dialect" of SMB are many sub-versions that include commands supporting particular releases of major operating systems. The ID string is used by clients and servers to determine what level of the protocol they will speak to each other.</para>
1013
1014
1015 <table label="3.3" id="ch03-67366">
1016 <title>SMB Protocol Dialects </title>
1017
1018 <tgroup cols="3">
1019 <colspec colnum="1" colname="col1"/>
1020 <colspec colnum="2" colname="col2"/>
1021 <colspec colnum="3" colname="col3"/>
1022 <thead>
1023 <row>
1024
1025 <entry colname="col1"><para>Protocol Name</para></entry>
1026
1027 <entry colname="col2"><para>ID String</para></entry>
1028
1029 <entry colname="col3"><para>Used By</para></entry>
1030
1031 </row>
1032
1033 </thead>
1034
1035 <tbody>
1036 <row>
1037
1038 <entry colname="col1"><para>Core</para></entry>
1039
1040 <entry colname="col2"><para><literal>PC NETWORK PROGRAM 1.0</literal></para></entry>
1041
1042 <entry colname="col3"></entry>
1043
1044 </row>
1045
1046 <row>
1047
1048 <entry colname="col1"><para>Core Plus</para></entry>
1049
1050 <entry colname="col2"><para><literal>MICROSOFT NETWORKS 1.03 </literal></para></entry>
1051
1052 <entry colname="col3"></entry>
1053
1054 </row>
1055
1056 <row>
1057
1058 <entry colname="col1"><para>LAN Manager 1.0</para></entry>
1059
1060 <entry colname="col2"><para><literal>LANMAN1.0</literal></para></entry>
1061
1062 <entry colname="col3"></entry>
1063
1064 </row>
1065
1066 <row>
1067
1068 <entry colname="col1"><para>LAN Manager 2.0</para></entry>
1069
1070 <entry colname="col2"><para><literal>LM1.2X002</literal></para></entry>
1071
1072 <entry colname="col3"></entry>
1073
1074 </row>
1075
1076 <row>
1077
1078 <entry colname="col1"><para>LAN Manager 2.1</para></entry>
1079
1080 <entry colname="col2"><para><literal>LANMAN2.1</literal></para></entry>
1081
1082 <entry colname="col3"></entry>
1083
1084 </row>
1085
1086 <row>
1087
1088 <entry colname="col1"><para>NT LAN Manager 1.0</para></entry>
1089
1090 <entry colname="col2"><para><literal>NT LM 0.12</literal></para></entry>
1091
1092 <entry colname="col3"><para>Windows NT 4.0</para></entry>
1093
1094 </row>
1095
1096 <row>
1097
1098 <entry colname="col1"><para>Samba's NT LM 0.12</para></entry>
1099
1100 <entry colname="col2"><para><literal>Samba</literal></para></entry>
1101
1102 <entry colname="col3"><para>Samba</para></entry>
1103
1104 </row>
1105
1106 <row>
1107
1108 <entry colname="col1"><para>Common Internet File System</para></entry>
1109
1110 <entry colname="col2"><para><literal>CIFS 1.0</literal></para></entry>
1111
1112 <entry colname="col3"><para>Windows 2000</para></entry>
1113
1114 </row>
1115
1116 </tbody>
1117 </tgroup>
1118 </table>
1119
1120
1121 <para>Samba implements the <literal>NT</literal> <literal>LM</literal> <literal>0.12</literal> specification for NT LAN Manager 1.0. It is backwards compatible with all of the other SMB variants. The CIFS specification is, in reality, LAN Manager 0.12 with a few specific additions.</para>
1122 </sect3>
1123 </sect2>
1124
1125
1126
1127
1128
1129 <sect2 role="" label="3.3.2" id="ch03-SECT-3.2">
1130 <title>SMB Clients and Servers</title>
1131
1132
1133 <para>As mentioned earlier, SMB is a client/server protocol. In the purest sense, this means that a client sends a request to a server, which acts on the request and returns a reply. However, the client/server roles can often be reversed, sometimes within the context of a single SMB session. For example, consider the two Windows 95/98 computers in <link linkend="ch03-69480">Figure 3.28</link>. The computer named WIZZIN shares a printer to the network, and the computer named ESCRIME shares a disk directory. WIZZIN is in the client role when accessing ESCRIME's network drive, and in the server role when printing a job for ESCRIME.</para>
1134
1135
1136 <figure label="3.28" id="ch03-69480">
1137 <title>Two computers that both have resources to share</title>
1138
1139 <graphic width="502" depth="153" fileref="figs/sam.0328.gif"></graphic>
1140 </figure>
1141
1142 <para>This brings out an important point in Samba terminology:</para>
1143
1144
1145 <itemizedlist>
1146 <listitem><para>A <firstterm>server</firstterm> is a machine with a resource to share.</para></listitem>
1147 <listitem><para>A <firstterm>client</firstterm> is a machine that wishes to use that resource.</para></listitem>
1148 <listitem><para>A server can be a client (of another computer's resource) at any given time.</para></listitem>
1149 </itemizedlist>
1150
1151 <para>Note that there are no implications as to the amount of resources that make up a server, or whether it has a large disk space or fast processor. A server could be an old 486 with a printer attached to it, or it could be an UltraSparc station with a 10 gigabyte disk service.</para>
1152
1153
1154 <para>Microsoft Windows products have both the SMB client and server built in to the operating system. <indexterm id="ch03-idx-948356-0"><primary>Windows NT</primary><secondary>client/server and</secondary></indexterm>Wndows NT 4.0 uses a newer SMB protocol than Windows for Workgroups, and it offers an enhanced form of network security which will be discussed in <link linkend="SAMBA-CH-6">Chapter 6</link>. In addition, there are a large number of commercial <indexterm id="ch03-idx-948361-0"><primary>SMB (Server Message Block)</primary><secondary>commercial products for</secondary></indexterm>SMB server products available from companies such as Sun, Compaq, SCO, Hewlett-Packard, Syntax, and IBM. Unfortunately, on the client side there are far fewer offerings, limited mainly to Digital Equipment's Pathworks product, and of course, Samba.</para>
1155 </sect2>
1156
1157
1158
1159
1160
1161 <sect2 role="" label="3.3.3" id="ch03-SECT-3.3">
1162 <title>A Simple SMB Connection</title>
1163
1164
1165 <para>
1166 <indexterm id="ch03-idx-948363-0"><primary>SMB (Server Message Block)</primary><secondary>making a simple connection</secondary></indexterm>
1167 <indexterm id="ch03-idx-948363-1"><primary>connections</primary><secondary>SMB</secondary></indexterm>Before we close this chapter, let's take a look at a simple SMB connection. This is some pretty technical data&mdash;which isn't really necessary to administer Samba&mdash;so you can skip over it if you like. We present this information largely as a way to help you get familiar with how the SMB protocol negotiates connections with other computers on the network.</para>
1168
1169
1170 <para>There are four steps that the client and server must complete in order to establish a connection to a resource:</para>
1171
1172
1173 <orderedlist>
1174 <listitem><para> Establish a virtual connection.</para></listitem>
1175 <listitem><para> Negotiate the protocol variant to speak.</para></listitem>
1176 <listitem><para> Set session parameters.</para></listitem>
1177 <listitem><para> Make a tree connection to a resource.</para></listitem>
1178 </orderedlist>
1179
1180 <para>We will examine each of these steps through the eyes of a useful tool that we mentioned earlier: the modified <filename>tcpdump</filename>
1181 <indexterm id="ch03-idx-948362-0"><primary>tcpdump utility</primary></indexterm>
1182 <indexterm id="ch03-idx-948362-1"><primary>downloads</primary><secondary>tcpdump utility</secondary></indexterm> that is available from the Samba web site.</para>
1183
1184
1185 <tip role="ora">
1186 <para>You can download this program at <filename>samba.org</filename> in the <filename>samba/ftp/tcpdump-smb</filename> directory; the latest version as of this writing is 3.4-5. Use this program as you would use the standard <filename>tcpdump</filename> application, but add the <literal>-s 1500</literal> switch to ensure that you get the whole packet and not just the first few bytes.</para>
1187
1188 </tip>
1189
1190 <sect3 role="" label="3.3.3.1" id="ch03-SECT-3.3.1">
1191 <title>Establishing a virtual connection</title>
1192
1193
1194 <para>
1195 <indexterm id="ch03-idx-948365-0"><primary>connections</primary><secondary>virtual</secondary></indexterm>
1196 <indexterm id="ch03-idx-948365-1"><primary>virtual connection</primary></indexterm>When a user first makes a request to access a network disk or send a print job to a remote printer, NetBIOS takes care of making a connection at the <indexterm id="ch03-idx-948366-0"><primary>session layer, connection at</primary></indexterm>session layer. The result is a bidirectional virtual channel between the client and server. In reality, there are only two messages that the client and server need to establish this connection. This is shown in the following example session request and response, as captured by <filename>tcpdump</filename> :</para>
1197
1198
1199 <programlisting>&gt;&gt;&gt; NBT Packet
1200 NBT Session Request
1201 Flags=0x81000044
1202 Destination=ESCRIME      NameType=0x20 (Server)
1203 Source=WIZZIN            NameType=0x00 (Workstation)
1204
1205 &gt;&gt;&gt; NBT Packet
1206 NBT Session Granted
1207 Flags=0x82000000</programlisting>
1208 </sect3>
1209 </sect2>
1210
1211
1212
1213
1214
1215 <sect2 role="" label="3.3.4" id="ch03-SECT-3.4">
1216 <title>Negotiating the Protocol Variant</title>
1217
1218
1219 <para>
1220 <indexterm id="ch03-idx-948367-0"><primary>protocols</primary><secondary>variant, negotiating</secondary></indexterm>At this point, there is an open channel between the client and server. Next, the client sends a message to the server to negotiate an SMB protocol. As mentioned earlier, the client sets its <indexterm id="ch03-idx-948373-0"><primary>tree identifier (TID)</primary></indexterm>
1221 <indexterm id="ch03-idx-948373-1"><primary>TID (tree identifier)</primary></indexterm>tree identifier (TID) field to zero, since it does not yet know what TID to use. A <emphasis>tree identifier</emphasis> is a number that represents a connection to a share on a server.</para>
1222
1223
1224 <para>The command in the message is <literal>SMBnegprot</literal>, a request to negotiate a protocol variant that will be used for the entire session. Note that the client sends to the server a list of all of the variants that it can speak, not vice versa.</para>
1225
1226
1227 <para>The server responds to the <literal>SMBnegprot</literal> request with an index into the list of variants that the client offered, starting with index 0, or with the value 0xFF if none of the protocol variants are acceptable. Continuing this example, the server responds with the value 5, which indicates that the <literal>NT</literal> <literal>LM</literal> <literal>0.12</literal> dialect will be used for the remainder of the session:</para>
1228
1229
1230 <programlisting>&gt;&gt;&gt; NBT Packet
1231 NBT Session Packet
1232 Flags=0x0
1233 Length=154
1234
1235 SMB PACKET: SMBnegprot (REQUEST)
1236 SMB Command   =  0x72
1237 Error class   =  0x0
1238 Error code    =  0
1239 Flags1        =  0x0
1240 Flags2        =  0x0
1241 Tree ID       =  0
1242 Proc ID       =  5371
1243 UID           =  0
1244 MID           =  385
1245 Word Count    =  0
1246 Dialect=PC NETWORK PROGRAM 1.0
1247 Dialect=MICROSOFT NETWORKS 3.0
1248 Dialect=DOS LM1.2X002
1249 Dialect=DOS LANMAN2.1
1250 Dialect=Windows for Workgroups 3.1a
1251 Dialect=NT LM 0.12
1252
1253 &gt;&gt;&gt; NBT Packet
1254 NBT Session Packet
1255 Flags=0x0
1256 Length=69
1257
1258 SMB PACKET: SMBnegprot (REPLY)
1259 SMB Command   =  0x72
1260 Error class   =  0x0
1261 Error code    =  0
1262 Flags1        =  0x0
1263 Flags2        =  0x1
1264 Tree ID       =  0
1265 Proc ID       =  5371
1266 UID           =  0
1267 MID           =  385
1268 Word Count    =  02
1269 [000] 05 00</programlisting>
1270 </sect2>
1271
1272
1273
1274
1275
1276 <sect2 role="" label="3.3.5" id="ch03-SECT-3.5">
1277 <title>Set Session and Login Parameters</title>
1278
1279
1280 <para>
1281 <indexterm id="ch03-idx-948377-0"><primary>session parameters, setting</primary></indexterm>
1282 <indexterm id="ch03-idx-948377-1"><primary>login parameters, setting</primary></indexterm>The next step is to transmit session and login parameters for the session. This includes the account name and password (if there is one), the workgroup name, the maximum size of data that can be transferred, and the number of pending requests that may be in the queue at any one time.</para>
1283
1284
1285 <para>In the following example, the Session Setup command presented allows for an additional SMB command to be piggybacked onto it. The letter X at the end of the command name indicates this, and the hexadecimal code of the second command is given in the <literal>Com2</literal> field. In this case the command is <literal>0x75</literal>, which is the Tree Connect and X command. The <literal>SMBtconX</literal> message looks for the name of the resource in the <command>smb_buf</command> buffer. (This is the last field listed in the following request.) In this example, <command>smb_buf</command> contains the string <literal>\\ESCRIME\PUBLIC</literal>, which is the full pathname to a shared directory on node ESCRIME. Using the "and X" commands like this speeds up each transaction, since the server doesn't have to wait on the client to make a second request.</para>
1286
1287
1288 <para>Note that the <indexterm id="ch03-idx-948382-0"><primary>TID (tree identifier)</primary></indexterm>
1289 <indexterm id="ch03-idx-948382-1"><primary>tree identifier (TID)</primary></indexterm>TID is still zero. The server will provide a TID to the client once the session has been established and a connection has been made to the requested resource. In addition, note that the password is sent in the open. We can change this later using encrypted passwords:</para>
1290
1291
1292 <programlisting>&gt;&gt;&gt; NBT Packet
1293 NBT Session Packet
1294 Flags=0x0
1295 Length=139
1296
1297 SMB PACKET: SMBsesssetupX (REQUEST)
1298 SMB Command   =  0x73
1299 Error class   =  0x0
1300 Error code    =  0
1301 Flags1        =  0x10
1302 Flags2        =  0x0
1303 Tree ID       =  0
1304 Proc ID       =  5371
1305 UID           =  1
1306 MID           =  385
1307 Word Count    =  13
1308 Com2=0x75
1309 Res1=0x0
1310 Off2=106
1311 MaxBuffer=2920
1312 MaxMpx=2
1313 VcNumber=0
1314 SessionKey=0x1FF2
1315 CaseInsensitivePasswordLength=1
1316 CaseSensitivePasswordLength=1
1317 Res=0x0
1318 Capabilities=0x1
1319 Pass1&amp;Pass2&amp;Account&amp;Domain&amp;OS&amp;LanMan=
1320   KRISTIN PARKSTR Windows 4.0 Windows 4.0
1321 PassLen=2
1322 Passwd&amp;Path&amp;Device=
1323 smb_bcc=22
1324 smb_buf[]=\\ESCRIME\PUBLIC</programlisting>
1325 </sect2>
1326
1327
1328
1329
1330
1331 <sect2 role="" label="3.3.6" id="ch03-SECT-3.6">
1332 <title>Making Connection to a Resource</title>
1333
1334
1335 <para>
1336 <indexterm id="ch03-idx-948383-0"><primary>connections</primary><secondary>resources, connecting to</secondary></indexterm>
1337 <indexterm id="ch03-idx-948383-1"><primary>resources, connecting to</primary></indexterm>For the final step, the server returns a TID to the client, indicating that the user has been authorized access and that the resource is ready to be used. It also sets the <command>ServiceType</command> field to "A" to indicate that this is a file service. Available service types are:</para>
1338
1339
1340 <itemizedlist>
1341 <listitem><para> "A" for a disk or file</para></listitem>
1342 <listitem><para> "LPT1" for a spooled output</para></listitem>
1343 <listitem><para> "COMM" for a direct-connect printer or modem</para></listitem>
1344 <listitem><para> "IPC" for a named pipe</para></listitem>
1345 </itemizedlist>
1346
1347 <para>The output is:</para>
1348
1349
1350 <programlisting>&gt;&gt;&gt; NBT Packet
1351 NBT Session Packet
1352 Flags=0x0
1353 Length=78
1354
1355 SMB PACKET: SMBsesssetupX (REPLY)
1356 SMB Command   =  0x73
1357 Error class   =  0x0
1358 Error code    =  0
1359 Flags1        =  0x80
1360 Flags2        =  0x1
1361 Tree ID       =  121
1362 Proc ID       =  5371
1363 UID           =  1
1364 MID           =  385
1365 Word Count    =  3
1366 Com2=0x75
1367 Off2=68
1368 Action=0x1
1369 [000] Unix Samba 1.9.1
1370 [010] PARKSTR
1371
1372 SMB PACKET: SMBtconX (REPLY) (CHAINED)
1373 smbvwv[]=
1374 Com2=0xFF
1375 Off2=78
1376 smbbuf[]=
1377 ServiceType=A:</programlisting>
1378
1379
1380 <para>Now that a TID has been assigned, the client may issue any sort of command that it would use on a local disk drive. It can open files, read and write to them, delete them, create new files, search for filenames, and so<indexterm id="ch03-idx-948291-0" class="endofrange" startref="ch03-idx-948288-0"/> on.<indexterm id="ch03-idx-947921-0" class="endofrange" startref="ch03-idx-947918-0"/>
1381 <indexterm id="ch03-idx-947921-1" class="endofrange" startref="ch03-idx-947918-1"/></para>
1382 </sect2>
1383 </sect1>
1384 </chapter>