docs: Remove all references to testprns
[vlendec/samba-autobuild/.git] / docs-xml / using_samba / ch07.xml
1 <chapter label="7" id="SAMBA-CH-7">
2 <title>Printing and Name Resolution</title>
3
4
5
6
7 <para>
8 <indexterm id="ch07-idx-956351-0" class="startofrange"><primary>printing</primary></indexterm>This chapter tackles two Samba topics: setting up printers for use with a Samba server and configuring Samba to use or become a Windows Internet Name Service (WINS) server. Samba allows client machines to send documents to printers connected to the Samba server. In addition, Samba can also assist you with printing Unix documents to a printer on a Windows machine. In the first part of this chapter, we will discuss how to get printers configured to work on either side.</para>
9
10
11 <para>In the second half of the chapter, we will introduce the Windows Internet Name Service, Microsoft's implementation of a NetBIOS Name Server (NBNS). As mentioned in <link linkend="ch01-48078">Chapter 1</link>, an NBNS allows machines to perform name resolution on a NetBIOS network without having to rely on broadcasts. Instead, each machine knows exactly where the WINS server is and can query it for the IP addresses of other machines on the network.</para>
12
13
14
15
16
17
18
19
20
21
22
23 <sect1 role="" label="7.1" id="ch07-61388">
24 <title>Sending Print Jobs to Samba</title>
25
26
27 <para>
28 <indexterm id="ch07-idx-956360-0" class="startofrange"><primary>printing</primary><secondary sortas="Samba">through Samba</secondary></indexterm>A printer attached to the Samba server shows up in the list of shares offered in the Network Neighborhood. If the printer is registered on the client machine and the client has the correct printer driver installed, the client can effortlessly send print jobs to a printer attached to a Samba server. <link linkend="ch07-35075">Figure 7.1</link> shows a Samba printer as it appears in the Network Neighborhood of a Windows client.</para>
29
30
31 <para>
32 <indexterm id="ch07-idx-956377-0"><primary>printing</primary><secondary>on a network, steps in</secondary></indexterm>
33 <indexterm id="ch07-idx-956377-1"><primary>networking</primary><secondary>printing on a network, steps in</secondary></indexterm>To administer printers with Samba, you should understand the basic process by which printing takes place on a network. Sending a print job to a printer on a Samba server involves four steps:</para>
34
35
36 <orderedlist>
37 <listitem><para>Opening and authenticating a connection to the printer share</para></listitem>
38 <listitem><para>Copying the file over the network</para></listitem>
39 <listitem><para>Closing the connection</para></listitem>
40 <listitem><para>Printing and deleting the copy of the file</para>
41
42
43 <figure label="7.1" id="ch07-35075">
44 <title>A Samba printer in the Network Neighborhood</title>
45
46 <graphic width="502" depth="171" fileref="figs/sam.0701.gif"></graphic>
47 </figure></listitem>
48 </orderedlist>
49
50 <para>When a print job arrives at a Samba server, the print data is temporarily written to disk in the directory specified by the <literal>path</literal> option of the printer share. Samba then executes a Unix print command to send that data file to the printer. The job is printed as the authenticated user of the share. Note that this may be the guest user, depending on how the share is configured.</para>
51
52
53 <sect2 role="" label="7.1.1" id="ch07-SECT-1.1">
54 <title>Print Commands</title>
55
56
57 <para>
58 <indexterm id="ch07-idx-956378-0"><primary>printing</primary><secondary>commands</secondary></indexterm>In order to print the document, you'll need to tell Samba what the command is to print and delete a file. On Linux, such a command is:</para>
59
60
61 <programlisting>lpr -r -P<replaceable>printer</replaceable> <replaceable>file</replaceable></programlisting>
62
63
64 <para>This tells <literal>lpr</literal> to copy the document to a spool area, usually <filename>/var/spool</filename>, retrieve the name of the printer in the system configuration file (<filename>/etc/printcap</filename>), and interpret the rules it finds there to decide how to process the data and which physical device to send it to. Note that because the <literal>-r</literal> option has been listed, the file specified on the command line will be deleted after it has been printed. Of course, the file removed is just a copy stored on the Samba server; the original file on the client is unaffected.</para>
65
66
67 <para>Linux uses a Berkeley (BSD) style of printing. However, the process is similar on System V Unix. Here, printing and deleting becomes a compound command:</para>
68
69
70 <programlisting>lp -d<replaceable>printer</replaceable> -s <replaceable>file</replaceable>; rm <replaceable>file</replaceable></programlisting>
71
72
73 <para>With System V, the <filename>/etc/printcap</filename> file is replaced with different set of configuration files hiding in <filename>/usr/spool/lp</filename>, and there is no option to delete the file. You have to do it yourself, which is why we have added the <literal>rm</literal> command afterward.</para>
74 </sect2>
75
76
77
78
79
80 <sect2 role="" label="7.1.2" id="ch07-SECT-1.2">
81 <title>Printing Variables</title>
82
83
84 <para>
85 <indexterm id="ch07-idx-956380-0"><primary>printing</primary><secondary>variables for</secondary></indexterm>Samba provides four variables specifically for use with <indexterm id="ch07-idx-956450-0" class="startofrange"><primary>printing</primary><secondary>configuration options</secondary></indexterm>printing configuration options. They are shown in <link linkend="ch07-29758">Table 7.1</link>.</para>
86
87
88 <table label="7.1" id="ch07-29758">
89 <title>Printing Variables </title>
90
91 <tgroup cols="2">
92 <colspec colnum="1" colname="col1"/>
93 <colspec colnum="2" colname="col2"/>
94 <thead>
95 <row>
96
97 <entry colname="col1"><para>Variable</para></entry>
98
99 <entry colname="col2"><para>Definition</para></entry>
100
101 </row>
102
103 </thead>
104
105 <tbody>
106 <row>
107
108 <entry colname="col1"><para><literal>%s</literal></para></entry>
109
110 <entry colname="col2"><para>The full pathname of the file on the Samba server to be printed</para></entry>
111
112 </row>
113
114 <row>
115
116 <entry colname="col1"><para><literal>%f</literal></para></entry>
117
118 <entry colname="col2"><para>The name of the file itself (without the preceding path) on the Samba server to be printed</para></entry>
119
120 </row>
121
122 <row>
123
124 <entry colname="col1"><para><literal>%p</literal></para></entry>
125
126 <entry colname="col2"><para>The name of the Unix printer to use</para></entry>
127
128 </row>
129
130 <row>
131
132 <entry colname="col1"><para><literal>%j</literal></para></entry>
133
134 <entry colname="col2"><para>The number of the print job (for use with <literal>lprm</literal>, <literal>lppause</literal>, and <literal>lpresume</literal>)</para></entry>
135
136 </row>
137
138 </tbody>
139 </tgroup>
140 </table>
141 </sect2>
142
143
144
145
146
147 <sect2 role="" label="7.1.3" id="ch07-SECT-1.3">
148 <title>A Minimal Printing Setup</title>
149
150
151 <para>
152 <indexterm id="ch07-idx-956382-0" class="startofrange"><primary>printing</primary><secondary>configuration, minimal</secondary></indexterm>Let's start with a simple but illustrative printing share. Assuming that you're on a Linux system and you have a printer called <literal>lp</literal> listed in the printer capabilities file, the following addition to your <filename>smb.conf</filename>
153 <indexterm id="ch07-idx-956439-0"><primary>smb.conf (Samba configuration) file</primary><secondary>configuring printers</secondary></indexterm> file will make the printer accessible through the network:</para>
154
155
156 <programlisting>[printer1]
157         printable = yes
158         print command = /usr/bin/lpr -r  %s
159         printer = lp
160         printing = BSD
161         read only = yes
162         guest ok = yes</programlisting>
163
164
165 <para>This configuration allows anyone to send data to the printer, something we may want to change later. For the moment, what's important to understand is that the variable <literal>%s</literal> in the <literal>print</literal> <literal>command</literal> option will be replaced with the name of the file to be printed when Samba executes the command. Changing the <literal>print command</literal> to reflect a different style of Unix machine typically involves only replacing the right side of the <literal>print</literal> <literal>command</literal> option with whatever command you need for your system and changing the target of the <literal>printing</literal> option.</para>
166
167
168 <para>Let's look at the commands for a <indexterm id="ch07-idx-956440-0"><primary>System V Unix</primary><secondary>printer configuration for</secondary></indexterm>
169 <indexterm id="ch07-idx-956440-1"><primary>Unix</primary><secondary>System V</secondary><tertiary>printer configuration for</tertiary></indexterm>System V Unix. With variable substitution, the System V Unix command becomes:</para>
170
171
172 <programlisting>print command = lp -d%p -s %s; rm %s</programlisting>
173
174
175 <para>As mentioned earlier, the <literal>%p</literal> variable resolves to the name of the printer, while the <literal>%s</literal> variable resolves to the name of the file. After that, you can change the <literal>printing</literal> option to reflect that you're using a System V architecture:</para>
176
177
178 <programlisting>printing = SYSV</programlisting>
179
180
181 <para>If you are using <indexterm id="ch07-idx-956441-0"><primary>share-level security</primary><secondary>printing and guest accounts</secondary></indexterm>share-level security, pay special attention to the guest account used by Samba. The typical setting, <literal>nobody</literal>, may not be allowed to print by the operating system. If that's true for your operating system, you should place a <literal>guest</literal> <literal>account</literal> option under the <indexterm id="ch07-idx-956445-0"><primary>print shares</primary></indexterm>printing share (or even perhaps the global share) specifying an account that can. A popular candidate with the Samba authors is the <literal>ftp</literal> account, which is often preconfigured to be safe for untrusted guest users. You can set it with the following command:</para>
182
183
184 <programlisting>guest account = ftp</programlisting>
185
186
187 <para>Another common printing issue is that clients may need to request the status of a <indexterm id="ch07-idx-956443-0"><primary>printing</primary><secondary>print jobs</secondary></indexterm>print job sent to the Samba server. Samba will not reject a document from being sent to an already busy printer share. Consequently, Samba needs the ability to communicate not only the status of the current printing job to the client, but also which documents are currently waiting to be printed on that printer. Samba also has to provide the client the ability to pause print jobs, resume print jobs, and remove print jobs from the printing queue. Samba provides options for each of these tasks. As you might expect, they borrow functionality from existing Unix commands. The options are:</para>
188
189
190 <itemizedlist>
191 <listitem><para><literal>lpq command</literal></para></listitem>
192 <listitem><para><literal>lprm command</literal></para></listitem>
193 <listitem><para><literal>lppause command</literal></para></listitem>
194 <listitem><para><literal>lpresume command</literal></para></listitem>
195 </itemizedlist>
196
197 <para>We will cover these options in more detail below. For the most part, however, the value of the <literal>printing</literal> configuration option will determine their values, and you should not need to alter the default values of these options.</para>
198
199
200 <para>Here are a few important items to remember about printing shares:</para>
201
202
203 <itemizedlist>
204 <listitem><para>You must put <literal>printable</literal> <literal>=</literal> <literal>yes</literal> in all printer shares (even <literal>[printers]</literal>), so that Samba will know that they are printer shares. If you forget, the shares will not be usable for printing and will instead be treated as disk shares.</para></listitem>
205 <listitem><para>If you set the <literal>path</literal> configuration option in the printer section, any files sent to the printer(s) will be copied to the directory you specify instead of to the default location of <filename>/tmp</filename>. As the amount of disk space allocated to <filename>/tmp</filename> can be relatively small in some Unix operating systems, many administrators opt to use <filename>/var/spool</filename> or some other directory instead.</para></listitem>
206 <listitem><para>The <literal>read only</literal> option is ignored for printer shares.</para></listitem>
207 <listitem><para>If you set <literal>guest</literal> <literal>ok</literal> <literal>=</literal> <literal>yes</literal> in a printer share and Samba is configured for share-level security, it will allow anyone to send data to the printer as the <literal>guest</literal> <literal>account</literal> user.</para></listitem>
208 </itemizedlist>
209
210 <para>Using one or more Samba machines as a print server gives you a great deal of flexibility on your LAN. You can easily partition your available printers, restricting some to members of one department, or you can maintain a bank of printers available to all. In addition, you can restrict a printer to a selected few by adding the trusty <literal>valid</literal> <literal>users</literal> option to its share definition:</para>
211
212
213 <programlisting>[deskjet]
214         printable = yes
215         path = /var/spool/samba/print
216         valid users = gail sam</programlisting>
217
218
219 <para>All of the other share accessibility options defined in the previous chapter should work for printing shares as well. Since the printers themselves are accessed through Samba by name, it's also simple to delegate print services among several servers using familiar Unix commands for tasks such as load balancing or maintenance.<indexterm id="ch07-idx-956385-0" class="endofrange" startref="ch07-idx-956382-0"/></para>
220 </sect2>
221
222
223
224
225
226 <sect2 role="" label="7.1.4" id="ch07-SECT-1.4">
227 <title>The [printers] Share</title>
228
229
230 <para>
231 <indexterm id="ch07-idx-956390-0"><primary>print shares</primary></indexterm><link linkend="ch04-21486">Chapter 4</link>, briefly introduced <literal>[printers]</literal>, a special share for automatically creating printing services. Let's review how it works: if you create a share named <literal>[printers]</literal> in the configuration file, Samba will automatically read in your printer capabilities file and create a printing share for each printer that appears in the file. For example, if the Samba server had <literal>lp</literal>, <literal>pcl</literal> and <literal>ps</literal> printers in its printer capabilities file, Samba would provide three printer shares with those names, each configured with the options in the <literal>[printers]</literal> share.</para>
232
233
234 <para>
235 <indexterm id="ch07-idx-956509-0"><primary>print shares</primary><secondary>created by Samba</secondary></indexterm>Recall that Samba obeys following rules when a client requests a share that has not been created through the <filename>smb.conf</filename> file:</para>
236
237
238 <itemizedlist>
239 <listitem><para>If the share name matches a username in the system password file and a <literal>[homes]</literal> share exists, a new share is created with the name of the user and is initialized using the values given in the <literal>[homes]</literal> and <literal>[global]</literal> sections.</para></listitem>
240 <listitem><para>Otherwise, if the name matches a printer in the system printer capabilities file, and a <literal>[printers]</literal> share exists, a new share is created with the name of the printer and initialized using the values given in the <literal>[printers]</literal> section. (Variables in the <literal>[global]</literal> section do not apply here.)</para></listitem>
241 <listitem><para>If neither of those succeed, Samba looks for a <literal>default</literal> <literal>service</literal> share. If none is found, it returns an error.</para></listitem>
242 </itemizedlist>
243
244 <para>This brings to light an important point: be careful that you do not give a <indexterm id="ch07-idx-956508-0"><primary>printers</primary><secondary>names</secondary><tertiary>caution with</tertiary></indexterm>printer the same name as a user. Otherwise, you will end up connecting to a disk share when you may have wanted a printer share instead.</para>
245
246
247 <para>Here is an example <literal>[printers]</literal> share for a Linux (BSD) system. Some of these options are already defaults; however, we have listed them anyway for illustrative purposes:</para>
248
249
250 <programlisting>[global]
251         printing = BSD
252         print command = /usr/bin/lpr -P%p -r %s
253         printcap file = /etc/printcap
254         min print space = 2000
255
256 [printers]
257         path = /usr/spool/public
258         printable = true
259         guest ok = true
260         guest account = pcguest</programlisting>
261
262
263 <para>Here, we've given Samba global options that specify the printing type (BSD), a print command to send data to the printer and remove a temporary file, our default printer capabilities file, and a minimum printing space of 2 megabytes.</para>
264
265
266 <para>In addition, we've created a <literal>[printers]</literal> share for each of the system printers. Our temporary spooling directory is specified by the <literal>path</literal> option: <filename>/usr/spool/public</filename>. Each of the shares is marked as printable&mdash;this is necessary, even in the <literal>[printers]</literal> section. The two <literal>guest</literal> options are useful in the event that Samba is using share-level security: we allow guest access to the printer and we specify the guest user that Samba should use to execute print commands.</para>
267 </sect2>
268
269
270
271
272
273 <sect2 role="" label="7.1.5" id="ch07-SECT-1.5">
274 <title>Test Printing</title>
275
276
277 <para>
278 <indexterm id="ch07-idx-956391-0"><primary>printing</primary><secondary>test for</secondary></indexterm>Here is how you can test printing from the Samba server. Let's assume the most complex case and use a guest account. First, run the Samba <emphasis>testparm</emphasis> command on your configuration file that contains the print shares, as we did in <link linkend="SAMBA-CH-2">Chapter 2</link>. This will tell you if there are any syntactical problems with the configuration file. For example, here is what you would see if you left out the <literal>path</literal> configuration option in the previous example:</para>
279
280
281 <programlisting># testparm
282 Load smb config files from /usr/local/samba/lib/smb.conf
283 Processing configuration file "/usr/local/samba/lib/smb.conf"
284 Processing section "[global]"
285 Processing section "[homes]"
286 Processing section "[data]"
287 Processing section "[printers]"
288 No path in service printers - using /tmp
289 Loaded services file OK.
290 Press enter to see a dump of your service definitions
291 Global parameters:
292         load printers: Yes
293         printcap name: /etc/printcap
294 Default service parameters:
295         guest account: ftp
296         min print space: 0
297         print command: lpr -r -P%p %s
298         lpq command: lpq -P%p
299         lprm command: lprm -P%p %j
300 lppause command:
301         lpresume command:
302  Service parameters [printers]:
303         path: /tmp
304         print ok: Yes
305         read only: true
306         public: true</programlisting>
307
308
309 <para>Next, log on as the guest user, go to the spooling directory, and ensure that you can print using the same command that <emphasis>testparm</emphasis> says Samba will use. As mentioned before, this will tell you if you need to change the guest account, as the default account may not be allowed to print.</para>
310
311
312 <para>Finally, print something to the Samba server via <literal>smbclient</literal>, and see if the following actions occur:</para>
313
314
315 <itemizedlist>
316 <listitem><para>The job appears (briefly) in the Samba spool directory specified by the path.</para></listitem>
317 <listitem><para>The job shows up in your print systems spool directory.</para></listitem>
318 <listitem><para>The job disappears from the spool directory that Samba used.</para></listitem>
319 </itemizedlist>
320
321 <para>If <emphasis>smbclient</emphasis> cannot print, you can reset the <literal>print</literal> <literal>command</literal> option to collect debugging information:</para>
322
323
324 <programlisting>print command = /bin/cat %s &gt;&gt;/tmp/printlog; rm %s</programlisting>
325
326
327 <para>or:</para>
328
329
330 <programlisting>print command = echo "printed %s on %p" &gt;&gt;/tmp/printlog</programlisting>
331
332
333 <para>A common problem with Samba printer configuration is forgetting to use the full <indexterm id="ch07-idx-956511-0"><primary>pathnames</primary><secondary>printer configuration and</secondary></indexterm>
334 <indexterm id="ch07-idx-956511-1"><primary>printing</primary><secondary>pathnames used in commands for</secondary></indexterm>pathnames for commands; simple commands often don't work because the guest account's PATH doesn't include them. Another frequent problem is not having the correct <indexterm id="ch07-idx-956512-0"><primary>permissions</primary><secondary sortas="printing">for printing</secondary></indexterm>
335 <indexterm id="ch07-idx-956512-1"><primary>printing</primary><secondary>permissions for</secondary></indexterm>permissions on the spooling directory.<indexterm id="ch07-idx-956494-0" class="endofrange" startref="ch07-idx-956450-0"/></para>
336
337
338 <tip role="ora">
339 <para>
340 <indexterm id="ch07-idx-956514-0"><primary>resources for further information</primary><secondary>printers, debuggiing</secondary></indexterm>
341 <indexterm id="ch07-idx-956514-1"><primary>printing</primary><secondary>resources for information on debugging</secondary></indexterm>There is more information on debugging printers in the Samba documentation (<filename>Printing.txt</filename>). In addition, the Unix print systems are covered in detail in AEleen Frisch's <emphasis>Essential Systems Administration</emphasis> (published by O'Reilly).</para>
342
343 </tip>
344 </sect2>
345
346
347
348
349
350 <sect2 role="" label="7.1.6" id="ch07-SECT-1.6">
351 <title>Setting Up and Testing a Windows Client</title>
352
353
354 <para>
355 <indexterm id="ch07-idx-956392-0"><primary>printing</primary><secondary>Windows client printers</secondary><tertiary>setting up and testing</tertiary></indexterm>
356 <indexterm id="ch07-idx-956392-1"><primary>Windows clients</primary><secondary>printers for, setting up and testing</secondary></indexterm>Now that Samba is offering a workable printer, you need to set it up on a Windows client. Look at the Samba server in the Network Neighborhood. It should now show each of the printers that are available. For example, in <link linkend="ch07-35075">Figure 7.1</link>, we saw a printer called <literal>lp</literal>.</para>
357
358
359 <para>Next, you need to have the Windows client recognize the printer. Double-click on the printer icon to get started. If you try to select an uninstalled printer (as you just did), Windows will ask you if it should help configure it for the Windows system. Respond "Yes," which will open the Printer Wizard.</para>
360
361
362 <para>The first thing the wizard will ask is whether you need to print from DOS.  Let's assume you don't, so choose No and press the Next button to get to the manufacturer/model window as shown in <link linkend="ch07-60084">Figure 7.2</link>.</para>
363
364
365 <figure label="7.2" id="ch07-60084">
366 <title>A printer in the Network Neighborhood</title>
367
368 <graphic width="502" depth="128" fileref="figs/sam.0702.gif"></graphic>
369 </figure>
370
371 <para>In this dialog box, you should see a large list of manufacturers and models for almost every printer imaginable. If you don't see your printer on the list, but you know it's a PostScript printer, select Apple as the manufacturer and Apple LaserWriter as the model. This will give you the most basic Postscript printer setup, and arguably one of the most reliable. If you already have any Postscript printers attached, you will be asked about replacing or reusing the existing driver. Be aware that if you replace it with a new one, you may make your other printers fail. Therefore, we recommend you keep using your existing printer drivers as long as they're working properly.</para>
372
373
374 <para>Following that, the Printer Wizard will ask you to name the printer. <link linkend="ch07-69466">Figure 7.3</link> shows this example, where the name has defaulted to our second laserwriter. Here, you rename it from Apple Laserwriter (Copy 2) to "ps on Samba server," so you know where to look for the printouts. In reality, you can name the printer anything you want.</para>
375
376
377 <figure label="7.3" id="ch07-69466">
378 <title>Printer manufacturers and models</title>
379
380 <graphic width="502" depth="296" fileref="figs/sam.0703.gif"></graphic>
381 </figure>
382
383 <para>Finally, the Printing Wizard asks if it should print a test page. Click on Yes, and you should be presented with the dialog in <link linkend="ch07-43374">Figure 7.4</link>.</para>
384
385
386 <figure label="7.4" id="ch07-43374">
387 <title>Printing successfully completed</title>
388
389 <graphic width="502" depth="232" fileref="figs/sam.0704.gif"></graphic>
390 </figure>
391
392 <para>If the test printing was unsuccessful, press the No button in <link linkend="ch07-43374">Figure 7.4</link> and the Printing Wizard will walk you through some debugging steps for the client side of the process. If the test printing does work, congratulations! The remote printer will now be available to all your PC applications through the File and Print menu items.</para>
393 </sect2>
394
395
396
397
398
399 <sect2 role="" label="7.1.7" id="ch07-30008">
400 <title>Automatically Setting Up Printer Drivers</title>
401
402
403 <para>
404 <indexterm id="ch07-idx-956393-0" class="startofrange"><primary>printing</primary><secondary>drivers for, setting up</secondary></indexterm>The previous section described how to manually configure a printer driver for your Windows system. As a system administrator, however, you can't always guarantee that users can perform such a process without making mistakes. Luckily, however, you can ask Samba to automatically set up the printer drivers for a specific printer.</para>
405
406
407 <para>Samba has three options that can be used to automatically set up printer drivers for clients who are connecting for the first time. These options are <literal>printer</literal> <literal>driver</literal>, <literal>printer</literal> <literal>driver</literal> <literal>file</literal>, and <literal>printer</literal> <literal>driver</literal> <literal>location</literal>. This section explains how to use these options to allow users to skip over the Manufacturer dialog in the Add Printer Wizard above.</para>
408
409
410 <tip role="ora">
411 <para>For more information on how to do this, see the <filename>PRINTER_DRIVER.TXT</filename> file in the Samba distribution documentation.</para>
412
413 </tip>
414
415 <para>There are four major steps:</para>
416
417
418 <orderedlist>
419 <listitem><para>Install the drivers for the printer on a Windows client (the printer need not be attached).</para></listitem>
420 <listitem><para>Create a printer definition file from the information on a Windows machine.</para></listitem>
421 <listitem><para>Create a <literal>PRINTER$</literal> share where the resulting driver files can be placed.</para></listitem>
422 <listitem><para>Modify the Samba configuration file accordingly.</para></listitem>
423 </orderedlist>
424
425 <para>Let's go over each of the four steps in greater detail.</para>
426
427
428 <sect3 role="" label="7.1.7.1" id="ch07-SECT-1.7.1">
429 <title>Install the drivers on a windows client</title>
430
431
432 <para>Use <indexterm id="ch07-idx-956517-0"><primary>Windows 95/98</primary><secondary>printer drivers, installing</secondary></indexterm>Windows 95/98 for this step. It doesn't matter which client you choose, as long as it has the ability to load the appropriate drivers for the printer. In fact, you don't even need to have the printer attached to the machine. All you're interested in here is getting the appropriate driver files into the Windows directory. First, go to the Printers window of My Computer and double-click on the Add Printer icon, as shown in <link linkend="ch07-52397">Figure 7.5</link>.</para>
433
434
435 <figure label="7.5" id="ch07-52397">
436 <title>The Printers window</title>
437
438 <graphic width="502" depth="223" fileref="figs/sam.0705.gif"></graphic>
439 </figure>
440
441 <para>At this point, you can follow the Add Printer Wizard dialogs through to select the manufacturer and model of the printer in question. If it asks you if you want to print from MS-DOS, answer No. Windows should load the appropriate driver resources from its CD-ROM and ask you if you want to print a test page. Again, respond No and close the Add Printer Wizard dialog.</para>
442 </sect3>
443
444
445
446 <sect3 role="" label="7.1.7.2" id="ch07-SECT-1.7.2">
447 <title>Create a printer definition file</title>
448
449
450 <para>You can create a <indexterm id="ch07-idx-956518-0"><primary>printing</primary><secondary>printer definition file</secondary></indexterm>printer definition file by using the <filename>make_ printerdef</filename> script in the <filename>/usr/local/samba/bin</filename> directory. In order to use this script, you need to copy over the following four files from a Windows client:<footnote label="1" id="ch07-pgfId-951615">
451
452
453 <para>Older Windows 95 clients may have only the first two files.</para>
454
455
456 </footnote></para>
457
458
459 <simplelist>
460
461 <member><emphasis>C:\WINDOWS\INF\MSPRINT.INF</emphasis></member>
462
463 <member><emphasis>C:\WINDOWS\INF\MSPRINT2.INF</emphasis></member>
464
465 <member><emphasis>C:\WINDOWS\INF\MSPRINT3.INF</emphasis></member>
466
467 <member><emphasis>C:\WINDOWS\INF\MSPRINT4.INF</emphasis></member>
468
469 </simplelist>
470
471
472 <para>Once you have the four files, you can create a printer definition file using the appropriate printer driver and its .INF file. If the printer driver starts with the letters A-K, use either the <emphasis>MSPRINT.INF</emphasis> file or the <emphasis>MSPRINT3.INF</emphasis> file. If it begins with the letters L-Z, use the <emphasis>MSPRINT2.INF</emphasis> file or the <emphasis>MSPRINT4.INF</emphasis> file. You may need to <emphasis>grep</emphasis> through each of the files to see where your specific driver is. For the following example, we have located our driver in <emphasis>MSPRINT3.INF</emphasis> and created a printer definition file for a HP DeskJet 560C printer:</para>
473
474
475 <programlisting>$grep "HP DeskJet 560C Printer" MSPRINT.INF MSPRINT3.INF
476 MSPRINT3.INF: "HP DeskJet 560C Printer"=DESKJETC.DRV,HP_DeskJet_ ...
477
478 $make_printerdef MSPRINT3.INF "HP DeskJet 560C Printer" &gt;printers.def
479 FOUND:DESKJETC.DRV
480 End of section found
481 CopyFiles: DESKJETC,COLOR_DESKJETC
482 Datasection: (null)
483 Datafile: DESKJETC.DRV
484 Driverfile: DESKJETC.DRV
485 Helpfile: HPVDJC.HLP
486 LanguageMonitor: (null)
487
488 Copy the following files to your printer$ share location:
489 DESKJETC.DRV
490 HPVCM.HPM
491 HPVIOL.DLL
492 HPVMON.DLL
493 HPVRES.DLL
494 HPCOLOR.DLL
495 HPVUI.DLL
496 HPVDJCC.HLP
497 color\HPDESK.ICM</programlisting>
498
499
500 <para>Note the files that the script asks you to copy. You'll need those for the next step.</para>
501 </sect3>
502
503
504
505 <sect3 role="" label="7.1.7.3" id="ch07-SECT-1.7.3">
506 <title>Create a PRINTER$ share</title>
507
508
509 <para>
510 <indexterm id="ch07-idx-956525-0"><primary>PRINTER$ share, creating</primary></indexterm>This part is relatively easy. Create a share called <literal>[PRINTER$]</literal> in your <filename>smb.conf</filename> that points to an empty directory on the Samba server. Once that is done, copy over the files that the <filename>make_ printerdef</filename> script requested of you into the location of the <literal>path</literal> configuration option for the <literal>[PRINTER$]</literal> share. For example, you can put the following in your configuration file:</para>
511
512
513 <programlisting>[PRINTER$]
514         path = /usr/local/samba/print
515         read only = yes
516         browsable = no
517         guest ok = yes</programlisting>
518
519
520 <para>The files requested by the <filename>make_ printerdef</filename> script are typically located in the <emphasis>C:\WINDOWS\SYSTEM</emphasis> directory, although you can use the following commands to find out exactly where they are:</para>
521
522
523 <programlisting>cd C:\WINDOWS
524 dir <replaceable>filename</replaceable> /s</programlisting>
525
526
527 <para>In this case, each of the files needs to be copied to the <filename>/usr/local/samba/print</filename> directory on the Samba server. In addition, copy the <filename>printers.def</filename> file that you created over to that share as well. Once you've done that, you're almost ready to go.</para>
528 </sect3>
529
530
531
532 <sect3 role="" label="7.1.7.4" id="ch07-SECT-1.7.4">
533 <title>Modify the Samba configuration file</title>
534
535
536 <para><filename></filename>
537 <indexterm id="ch07-idx-956532-0"><primary>smb.conf (Samba configuration) file</primary><secondary>modifying for printer drivers</secondary></indexterm>The last step is to modify the Samba configuration file by adding the following three options:</para>
538
539
540 <itemizedlist>
541 <listitem><para><literal>printer</literal> <literal>driver</literal></para></listitem>
542 <listitem><para><literal>printer</literal> <literal>driver</literal> <literal>file</literal></para></listitem>
543 <listitem><para><literal>printer</literal> <literal>driver</literal> <literal>location</literal></para></listitem>
544 </itemizedlist>
545
546 <para>The <literal>printer</literal> <literal>driver</literal> <literal>file</literal> is a global option that points to the <filename>printers.def</filename> file; place that option in your <literal>[global]</literal> section. The other options should be set in the printer share for which you wish to automatically configure the drivers. The value for <literal>printer</literal> <literal>driver</literal> should match the string that shows up in the Printer Wizard on the Windows system. The value of the <literal>printer</literal> <literal>driver</literal> <literal>location</literal> is the pathname of the PRINTER$ share you set up, not the Unix pathname on the server. Thus, you could use the following:</para>
547
548
549 <programlisting>[global]
550         printer driver file = /usr/local/samba/print/printers.def
551 [hpdeskjet]
552         path = /var/spool/samba/printers
553         printable = yes
554
555         printer driver = HP DeskJet 560C Printer
556         printer driver location = \\%L\PRINTER$</programlisting>
557
558
559 <para>Now you're ready to test it out. At this point, remove the Windows printer that you "set up" in the first step from the list of printers in the Printers window of My Computer. If Samba asks you to delete unneeded files, do so. These files will be replaced shortly on the client, as they now exist on the Samba server.</para>
560 </sect3>
561
562
563
564 <sect3 role="" label="7.1.7.5" id="ch07-SECT-1.7.5">
565 <title>Testing the configuration</title>
566
567
568 <para>Restart the Samba daemons and look for the <literal>[hpdeskjet]</literal> share under the machine name in the Network Neighborhood. At this point, if you click on the printer icon, you should begin the printer setup process and come to the dialog shown in <link linkend="ch07-60108">Figure 7.6</link>.</para>
569
570
571 <para>This is different from the dialog you saw earlier when setting up a printer. Essentially, the dialog is asking if you wish to accept the driver that is "already installed"&mdash;in other words, offered by Samba. Go ahead and keep the existing driver, and press the Next button. At this point, you can give the printer a name and print out a test page. If it works, the setup should be complete. You should be able to repeat the process now from any Windows<indexterm id="ch07-idx-956413-0" class="endofrange" startref="ch07-idx-956393-0"/> client. <indexterm id="ch07-idx-956407-0" class="endofrange" startref="ch07-idx-956360-0"/></para>
572
573
574 <figure label="7.6" id="ch07-60108">
575 <title>Automatically configuring the printer driver</title>
576
577 <graphic width="502" depth="296" fileref="figs/sam.0706.gif"></graphic>
578 </figure>
579 </sect3>
580 </sect2>
581 </sect1>
582
583
584
585
586
587
588
589
590
591 <sect1 role="" label="7.2" id="ch07-31526">
592 <title>Printing to Windows Client Printers</title>
593
594
595 <para>
596 <indexterm id="ch07-idx-956368-0" class="startofrange"><primary>printing</primary><secondary>Windows client printers</secondary><tertiary>printing to</tertiary></indexterm>If you have printers connected to clients running Windows 95/98 or NT 4.0, those printers can also be accessed from Samba. Samba comes equipped with a tool called <emphasis>smbprint</emphasis>
597 <indexterm id="ch07-idx-956539-0"><primary>smbprint tool, spooling print jobs</primary></indexterm>
598 <indexterm id="ch07-idx-956539-1"><primary>printing</primary><secondary>print jobs</secondary><tertiary>spooling with smbprint tool</tertiary></indexterm> that can be used to spool print jobs to Windows-based printers. In order to use this, however, you need to set up the printer as a shared resource on the client machine. If you haven't already done this, you can reset this from the Printers window, reached from the Start button, as shown in <link linkend="ch07-32814">Figure 7.7</link>.</para>
599
600
601 <figure label="7.7" id="ch07-32814">
602 <title>The Printers window</title>
603
604 <graphic width="502" depth="273" fileref="figs/sam.0707.gif"></graphic>
605 </figure>
606
607 <para>Select a printer that's locally connected (for example, ours is the Canon printer), press the right mouse button to bring up a menu, and select Sharing. This will give you the Sharing tab of the Printer Properties frame, as shown in <link linkend="ch07-92021">Figure 7.8</link>. If you want it available to everybody on your LAN as the Windows guest user, enter a blank password.</para>
608
609
610 <figure label="7.8" id="ch07-92021">
611 <title>The Sharing tab of the printer</title>
612
613 <graphic width="502" depth="273" fileref="figs/sam.0708.gif"></graphic>
614 </figure>
615
616 <para>Once you've got this working, you can add your printer to the list of standard printers and Samba can make it available to all the other PCs in the workgroup. To make installation on Unix easier, the Samba distribution provides two sample scripts: <filename>smbprint</filename> and <filename>smbprint.sysv</filename>. The first works with BSD-style printers; the second is designed for System V printers.</para>
617
618
619 <sect2 role="" label="7.2.1" id="ch07-SECT-2.0.1">
620 <title>BSD printers</title>
621
622
623 <para>
624 <indexterm id="ch07-idx-956540-0"><primary>printers</primary><secondary>BSD</secondary></indexterm>There are two steps you need to have a BSD Unix recognize a remote printer:</para>
625
626
627 <orderedlist>
628 <listitem><para>Place an entry for the printer in the <filename>/etc/printcap</filename> file (or equivalent).</para></listitem>
629 <listitem><para>Place a configuration file in the <filename>/var/spool</filename> directory for the printer.</para></listitem>
630 </orderedlist>
631
632 <para>First, edit your <filename>/etc/printcap</filename> file and add an entry for the remote printer. Note that the input filter (<literal>if</literal>) entry needs to point to the <emphasis>smbprint</emphasis> program if the machine is on Windows 95/98. The following set of lines will accomplish on a Linux machine, for example:</para>
633
634
635 <programlisting>laserjet:\
636   :sd=/var/spool/lpd/laser:\         <replaceable># spool directory</replaceable>
637   :mx#0:\                            <replaceable># maximum file size (none)</replaceable>
638   :sh:\                              <replaceable># surpress burst header (no)</replaceable>
639   :if=/usr/local/samba/bin/smbprint: <replaceable># text filter</replaceable></programlisting>
640
641
642 <para>After that, you need to create a configuration file in the spool directory that you specified with the <literal>sd</literal> parameter above. (You may need to create that directory.) The file must have the name <emphasis>.config</emphasis> and should contain the following information:</para>
643
644
645 <itemizedlist>
646 <listitem><para>The NetBIOS name of the Windows machine with the printer</para></listitem>
647 <listitem><para>The service name that represents the printer</para></listitem>
648 <listitem><para>The password used to access that service</para></listitem>
649 </itemizedlist>
650
651 <para>The last two parameters were set up in the Sharing dialog for the requested resource on the Windows machine. In this case, the <emphasis>.config</emphasis> file would have three lines:</para>
652
653
654 <programlisting>server = phoenix
655 service = CANON
656 password = ""</programlisting>
657
658
659 <para>After you've done that, reset the Samba server machine and try printing to it using any standard Unix program.</para>
660 </sect2>
661
662
663
664
665
666 <sect2 role="" label="7.2.2" id="ch07-SECT-2.0.2">
667 <title>System V printers</title>
668
669
670 <para>
671 <indexterm id="ch07-idx-956541-0"><primary>printers</primary><secondary>System V</secondary></indexterm>Sending print jobs from a System V Unix system is a little easier. Here, you need to get obtain the <filename>smbprint.sysv</filename> script in the <filename>/usr/local/samba/examples/printing</filename> directory and do the following:</para>
672
673
674 <orderedlist>
675 <listitem><para>Change the <literal>server</literal>, <literal>service</literal>, and <literal>password</literal> parameters in the script to match the NetBIOS machine, its shared printer service, and its password, respectively. For example, the following entries would be correct for the service in the previous example:</para>
676
677
678 <programlisting>server = phoenix
679 service = CANON
680 password = ""</programlisting></listitem>
681
682 <listitem><para>Run the following commands, which create a reference for the printer in the printer capabilities file. Note that the new Unix printer entry <literal>canon_  printer</literal> is named:</para>
683
684
685 <programlisting># lpadmin -p canon_printer -v /dev/null -i./smbprint.sysv
686 # enable canon_printer
687 # accept canon_printer</programlisting></listitem>
688 </orderedlist>
689
690 <para>After you've done that, restart the Samba daemons and try printing to it using any standard Unix program. You should now be able to send data to a printer on a Windows client across the network.</para>
691 </sect2>
692
693
694
695
696 <sect2 role="" label="7.2.3" id="ch07-SECT-2.1">
697 <title>Samba Printing Options</title>
698
699
700 <para>
701 <indexterm id="ch07-idx-956419-0" class="startofrange"><primary>printing</primary><secondary>options for</secondary></indexterm><link linkend="ch07-19361">Table 7.2</link> summarizes the Samba printing options.</para>
702
703
704 <table label="7.2" id="ch07-19361">
705 <title>Printing Configuration Options </title>
706
707 <tgroup cols="5">
708 <colspec colnum="1" colname="col1"/>
709 <colspec colnum="2" colname="col2"/>
710 <colspec colnum="3" colname="col3"/>
711 <colspec colnum="4" colname="col4"/>
712 <colspec colnum="5" colname="col5"/>
713 <thead>
714 <row>
715
716 <entry colname="col1"><para>Option</para></entry>
717
718 <entry colname="col2"><para>Parameters</para></entry>
719
720 <entry colname="col3"><para>Function</para></entry>
721
722 <entry colname="col4"><para>Default</para></entry>
723
724 <entry colname="col5"><para>Scope</para></entry>
725
726 </row>
727
728 </thead>
729
730 <tbody>
731 <row>
732
733 <entry colname="col1"><para><literal>printing</literal></para></entry>
734
735 <entry colname="col2"><para><literal>bsd</literal>, <literal>sysv</literal>, <literal>hpux</literal>, <literal>aix</literal>, <literal>qnx</literal>, <literal>plp</literal>, <literal>softq</literal>, or <literal>lprng</literal></para></entry>
736
737 <entry colname="col3"><para>Sets the print system type for your Unix system.</para></entry>
738
739 <entry colname="col4"><para>System dependent</para></entry>
740
741 <entry colname="col5"><para>Share</para></entry>
742
743 </row>
744
745 <row>
746
747 <entry colname="col1"><para><literal>printable (print ok)</literal></para></entry>
748
749 <entry colname="col2"><para>boolean</para></entry>
750
751 <entry colname="col3"><para>Marks a share as a printing share.</para></entry>
752
753 <entry colname="col4"><para><literal>no</literal></para></entry>
754
755 <entry colname="col5"><para>Share</para></entry>
756
757 </row>
758
759 <row>
760
761 <entry colname="col1"><para><literal>printer (printer name)</literal></para></entry>
762
763 <entry colname="col2"><para>string (Unix printer name)</para></entry>
764
765 <entry colname="col3"><para>Sets the name of the printer to be shown to clients.</para></entry>
766
767 <entry colname="col4"><para>System dependent</para></entry>
768
769 <entry colname="col5"><para>Share</para></entry>
770
771 </row>
772
773 <row>
774
775 <entry colname="col1"><para><literal>printer driver</literal></para></entry>
776
777 <entry colname="col2"><para>string (printer driver name)</para></entry>
778
779 <entry colname="col3"><para>Sets the driver name that should be used by the client to send data to the printer.</para></entry>
780
781 <entry colname="col4"><para>None</para></entry>
782
783 <entry colname="col5"><para>Share</para></entry>
784
785 </row>
786
787 <row>
788
789 <entry colname="col1"><para><literal>printer driver file</literal></para></entry>
790
791 <entry colname="col2"><para>string (fully-qualified pathname)</para></entry>
792
793 <entry colname="col3"><para>Sets the name of the printer driver file.</para></entry>
794
795 <entry colname="col4"><para>None</para></entry>
796
797 <entry colname="col5"><para>Global</para></entry>
798
799 </row>
800
801 <row>
802
803 <entry colname="col1"><para><literal>printer driver location</literal></para></entry>
804
805 <entry colname="col2"><para>string (network pathname)</para></entry>
806
807 <entry colname="col3"><para>Specifies the pathname of the share for the printer driver file.</para></entry>
808
809 <entry colname="col4"><para>None</para></entry>
810
811 <entry colname="col5"><para>Share</para></entry>
812
813 </row>
814
815 <row>
816
817 <entry colname="col1"><para><literal>lpq cache time</literal></para></entry>
818
819 <entry colname="col2"><para>numeric (time in seconds)</para></entry>
820
821 <entry colname="col3"><para>Sets the amount of time in seconds that Samba will cache the lpq status.</para></entry>
822
823 <entry colname="col4"><para><literal>10</literal></para></entry>
824
825 <entry colname="col5"><para>Global</para></entry>
826
827 </row>
828
829 <row>
830
831 <entry colname="col1"><para><literal>postscript</literal></para></entry>
832
833 <entry colname="col2"><para>boolean</para></entry>
834
835 <entry colname="col3"><para>Treats all print jobs sent as postscript by prepending <literal>%!</literal> at the beginning of each file.</para></entry>
836
837 <entry colname="col4"><para><literal>no</literal></para></entry>
838
839 <entry colname="col5"><para>Share</para></entry>
840
841 </row>
842
843 <row>
844
845 <entry colname="col1"><para><literal>load printers</literal></para></entry>
846
847 <entry colname="col2"><para>boolean</para></entry>
848
849 <entry colname="col3"><para>Automatically loads each of the printers in the <emphasis>printcap</emphasis> file as printing shares.</para></entry>
850
851 <entry colname="col4"><para><literal>no</literal></para></entry>
852
853 <entry colname="col5"><para>Global</para></entry>
854
855 </row>
856
857 <row>
858
859 <entry colname="col1"><para><literal>print command</literal></para></entry>
860
861 <entry colname="col2"><para>string (shell command)</para></entry>
862
863 <entry colname="col3"><para>Sets the Unix command to perform printing.</para></entry>
864
865 <entry colname="col4"><para>See below</para></entry>
866
867 <entry colname="col5"><para>Share</para></entry>
868
869 </row>
870
871 <row>
872
873 <entry colname="col1"><para><literal>lpq command</literal></para></entry>
874
875 <entry colname="col2"><para>string (shell command)</para></entry>
876
877 <entry colname="col3"><para>Sets the Unix command to return the status of the printing queue.</para></entry>
878
879 <entry colname="col4"><para>See below</para></entry>
880
881 <entry colname="col5"><para>Share</para></entry>
882
883 </row>
884
885 <row>
886
887 <entry colname="col1"><para><literal>lprm command</literal></para></entry>
888
889 <entry colname="col2"><para>string (shell command)</para></entry>
890
891 <entry colname="col3"><para>Sets the Unix command to remove a job from the printing queue.</para></entry>
892
893 <entry colname="col4"><para>See below</para></entry>
894
895 <entry colname="col5"><para>Share</para></entry>
896
897 </row>
898
899 <row>
900
901 <entry colname="col1"><para><literal>lppause command</literal></para></entry>
902
903 <entry colname="col2"><para>string (shell command)</para></entry>
904
905 <entry colname="col3"><para>Sets the Unix command to pause a job on the printing queue.</para></entry>
906
907 <entry colname="col4"><para>See below</para></entry>
908
909 <entry colname="col5"><para>Share</para></entry>
910
911 </row>
912
913 <row>
914
915 <entry colname="col1"><para><literal>lpresume command</literal></para></entry>
916
917 <entry colname="col2"><para>string (shell command)</para></entry>
918
919 <entry colname="col3"><para>Sets the Unix command to resume a paused job on the printing queue.</para></entry>
920
921 <entry colname="col4"><para>See below</para></entry>
922
923 <entry colname="col5"><para>Share</para></entry>
924
925 </row>
926
927 <row>
928
929 <entry colname="col1"><para><literal>printcap name</literal></para>
930
931 <para><literal>(printcap)</literal></para></entry>
932
933 <entry colname="col2"><para>string (fully-qualified pathname)</para></entry>
934
935 <entry colname="col3"><para>Specifies the location of the printer capabilities file.</para></entry>
936
937 <entry colname="col4"><para>System dependent</para></entry>
938
939 <entry colname="col5"><para>Global</para></entry>
940
941 </row>
942
943 <row>
944
945 <entry colname="col1"><para><literal>min print space</literal></para></entry>
946
947 <entry colname="col2"><para>numeric (size in kilobytes)</para></entry>
948
949 <entry colname="col3"><para>Sets the minimum amount of disk free space that must be present to print.</para></entry>
950
951 <entry colname="col4"><para><literal>0</literal></para></entry>
952
953 <entry colname="col5"><para>Share</para></entry>
954
955 </row>
956
957 <row>
958
959 <entry colname="col1"><para><literal>queuepause command</literal></para></entry>
960
961 <entry colname="col2"><para>string (shell command)</para></entry>
962
963 <entry colname="col3"><para>Sets the Unix command to pause a queue.</para></entry>
964
965 <entry colname="col4"><para>See below</para></entry>
966
967 <entry colname="col5"><para>Share</para></entry>
968
969 </row>
970
971 <row>
972
973 <entry colname="col1"><para><literal>queueresume command</literal></para></entry>
974
975 <entry colname="col2"><para>string (shell command)</para></entry>
976
977 <entry colname="col3"><para>Sets the Unix command to resume a queue.</para></entry>
978
979 <entry colname="col4"><para>See below</para></entry>
980
981 <entry colname="col5"><para>Share</para></entry>
982
983 </row>
984
985 </tbody>
986 </tgroup>
987 </table>
988
989
990 <sect3 role="" label="7.2.3.1" id="ch07-SECT-2.1.1">
991 <title>printing</title>
992
993
994 <para>The <literal>printing</literal>
995 <indexterm id="ch07-idx-958423-0"><primary>printing configuration option</primary></indexterm> configuration option tells Samba a little about your Unix printing system, in this case which printing parser to use. With Unix, there are several different families of commands to control printing and print statusing. Samba supports seven different types, as shown in <link linkend="ch07-28758">Table 7.3</link>.</para>
996
997
998 <table label="7.3" id="ch07-28758">
999 <title>Printing Types </title>
1000
1001 <tgroup cols="2">
1002 <colspec colnum="1" colname="col1"/>
1003 <colspec colnum="2" colname="col2"/>
1004 <thead>
1005 <row>
1006
1007 <entry colname="col1"><para>Variable</para></entry>
1008
1009 <entry colname="col2"><para>Definition</para></entry>
1010
1011 </row>
1012
1013 </thead>
1014
1015 <tbody>
1016 <row>
1017
1018 <entry colname="col1"><para>BSD</para></entry>
1019
1020 <entry colname="col2"><para>
1021 <indexterm id="ch07-idx-956545-0"><primary>printing</primary><secondary>types</secondary></indexterm>Berkeley Unix system</para></entry>
1022
1023 </row>
1024
1025 <row>
1026
1027 <entry colname="col1"><para>SYSV</para></entry>
1028
1029 <entry colname="col2"><para>System V</para></entry>
1030
1031 </row>
1032
1033 <row>
1034
1035 <entry colname="col1"><para>AIX</para></entry>
1036
1037 <entry colname="col2"><para>AIX Operating System (IBM)</para></entry>
1038
1039 </row>
1040
1041 <row>
1042
1043 <entry colname="col1"><para>HPUX</para></entry>
1044
1045 <entry colname="col2"><para>Hewlett-Packard Unix</para></entry>
1046
1047 </row>
1048
1049 <row>
1050
1051 <entry colname="col1"><para>QNX</para></entry>
1052
1053 <entry colname="col2"><para>QNX Realtime Operating System (QNX)</para></entry>
1054
1055 </row>
1056
1057 <row>
1058
1059 <entry colname="col1"><para>LPRNG</para></entry>
1060
1061 <entry colname="col2"><para>LPR Next Generation (Powell)</para></entry>
1062
1063 </row>
1064
1065 <row>
1066
1067 <entry colname="col1"><para>SOFTQ</para></entry>
1068
1069 <entry colname="col2"><para>SOFTQ system</para></entry>
1070
1071 </row>
1072
1073 <row>
1074
1075 <entry colname="col1"><para>PLP</para></entry>
1076
1077 <entry colname="col2"><para>Portable Line Printer (Powell)</para></entry>
1078
1079 </row>
1080
1081 </tbody>
1082 </tgroup>
1083 </table>
1084
1085
1086 <para>The value for this optio.n will be one of these seven options. For example:</para>
1087
1088
1089 <programlisting>printing = SYSV</programlisting>
1090
1091
1092 <para>The default value of this option is system dependent and is configured when Samba is first compiled. For most systems, the <filename>configure</filename> script will automatically detect the printing system to be used and configure it properly in the Samba makefile. However, if your system is a PLP, LPRNG, or QNX printing system, you will need to explicitly specify this in the makefile or the printing share.</para>
1093
1094
1095 <para>The most common system types are BSD and SYSV. Each of the printers on a BSD Unix server are described in the printer capabilities file&mdash;normally <filename>/etc/printcap</filename>.</para>
1096
1097
1098 <para>Setting the <literal>printing</literal> configuration option automatically sets at least three other printing options for the service in question: <literal>print</literal> <literal>command</literal>, <literal>lpq</literal> <literal>command</literal>, and <literal>lprm</literal> <literal>command</literal>. If you are running Samba on a system that doesn't support any of these printing styles, simply set the commands for each of these manually.</para>
1099 </sect3>
1100
1101
1102
1103 <sect3 role="" label="7.2.3.2" id="ch07-SECT-2.1.2">
1104 <title>printable</title>
1105
1106
1107 <para>The <indexterm id="ch07-idx-958426-0"><primary>printable option</primary></indexterm>printable option must be set to <literal>yes</literal> in order to flag a share as a printing service. If this option is not set, the share will be treated as a disk share instead. You can set the option as follows:</para>
1108
1109
1110 <programlisting>[printer1]
1111         printable = yes</programlisting>
1112 </sect3>
1113
1114
1115
1116 <sect3 role="" label="7.2.3.3" id="ch07-SECT-2.1.3">
1117 <title>printer</title>
1118
1119
1120 <para>
1121 <indexterm id="ch07-idx-957248-0" class="startofrange"><primary>printers</primary><secondary>option for</secondary></indexterm>The <indexterm id="ch07-idx-958427-0"><primary>printer option</primary></indexterm>option, sometimes called <literal>printer</literal> <literal>name</literal>, specifies the name of the printer on the server to which the share points. This option has no default and should be set explicitly in the configuration file, even though Unix systems themselves often recognize a default name such as <literal>lp</literal> for a printer. For example:</para>
1122
1123
1124 <programlisting>[deskjet]
1125         printer = hpdkjet1</programlisting>
1126 </sect3>
1127
1128
1129
1130 <sect3 role="" label="7.2.3.4" id="ch07-SECT-2.1.4">
1131 <title>printer driver</title>
1132
1133
1134 <para>The <literal>printer</literal>
1135 <indexterm id="ch07-idx-958428-0"><primary>printer driver option</primary></indexterm> <literal>driver</literal> option sets the string that Samba uses to tell Windows what the printer is. If this option is set correctly, the Windows Printer Wizard will already know what the printer is, making installation easier for end users by giving them one less dialog to worry about. The string given should match the string that shows up in the Printer Wizard, as shown in <link linkend="ch07-46183">Figure 7.9</link>. For example, an Apple LaserWriter typically uses <literal>Apple</literal> <literal>LaserWriter</literal>; a Hewlett Packard Deskjet 560C uses <literal>HP</literal> <literal>DeskJet</literal> <literal>560C</literal> <literal>Printer</literal>.</para>
1136
1137
1138 <figure label="7.9" id="ch07-46183">
1139 <title>The Add Printer Wizard dialog box in Windows 98</title>
1140
1141 <graphic width="502" depth="296" fileref="figs/sam.0709.gif"></graphic>
1142 </figure>
1143
1144 <para>Automatically configuring printer drivers with Samba is explained in greater detail in <link linkend="ch07-30008">Section 7.1.7</link> earlier in this chapter.</para>
1145 </sect3>
1146
1147
1148
1149 <sect3 role="" label="7.2.3.5" id="ch07-SECT-2.1.5">
1150 <indexterm id="ch07-idx-958429-0"><primary>printer driver file option</primary></indexterm>
1151 <title>
1152 printer driver file</title>
1153
1154
1155 <para>This global option gives the location of the Windows 95/98 printer driver definition file, which is needed to give printer drivers to clients using a Samba printer. The default value of this option is <filename>/usr/local/samba/lib/printers.def</filename>. You can override this default as shown below:</para>
1156
1157
1158 <programlisting>[deskjet]
1159         printer driver file = /var/printers/printers.def</programlisting>
1160
1161
1162 <para>This option is explained in greater detail in <link linkend="ch07-30008">Section 7.1.7</link> earlier in this chapter.</para>
1163 </sect3>
1164
1165
1166
1167 <sect3 role="" label="7.2.3.6" id="ch07-SECT-2.1.6">
1168 <indexterm id="ch07-idx-958432-0"><primary>printer driver location option</primary></indexterm>
1169 <title>
1170 printer driver location</title>
1171
1172
1173 <para>This option specifies a specific share that contains Windows 95 and 98 printer driver and definition files. There is no default parameter for this value. You can specify the location as a network pathname. A frequent approach is to use a share on your own machine, as shown here:</para>
1174
1175
1176 <programlisting>[deskjet]
1177         printer driver location = \\%L\PRINTER$</programlisting>
1178
1179
1180 <para>This option is also explained in greater detail in <link linkend="ch07-30008">Section 7.1.7</link> earlier in this chapter.</para>
1181 </sect3>
1182
1183
1184
1185 <sect3 role="" label="7.2.3.7" id="ch07-SECT-2.1.7">
1186 <indexterm id="ch07-idx-958433-0"><primary>lpq cache time option</primary></indexterm>
1187 <title>
1188 lpq cache time</title>
1189
1190
1191 <para>
1192 <indexterm id="ch07-idx-956564-0"><primary>cache time (printers), option for</primary></indexterm>The global <literal>lpq</literal> <literal>cache</literal> <literal>time</literal> option allows you to set the number of seconds that Samba will remember the current printer status. After this time elapses, Samba will issue an <emphasis>lpq</emphasis> command (or whatever command you specify with the <literal>lpq</literal> <literal>command</literal> option) to get a more up-to-date status. This defaults to 10 seconds, but can be increased if your <literal>lpq</literal> <literal>command</literal> takes an unusually long time to run or you have lots of clients. The following example resets the time to 30 seconds:</para>
1193
1194
1195 <programlisting>[deskjet]
1196         lpq cache time = 30</programlisting>
1197 </sect3>
1198
1199
1200
1201 <sect3 role="" label="7.2.3.8" id="ch07-SECT-2.1.8">
1202 <title>postscript</title>
1203
1204
1205 <para>The<indexterm id="ch07-idx-958438-0"><primary>postscript option</primary></indexterm> <literal>postscript</literal> option forces the printer to treat all data sent to it as Postscript. It does this by prepending the characters <literal>%!</literal> at the beginning of the first line of each job. It is normally used with PCs that insert a <literal>^D</literal> (control-D or "end-of-file mark) in front of the first line of a PostScript file. It will not, obviously, turn a non-PostScript printer into a PostScript one. The default value of this options is <literal>no</literal>. You can override it as follows:<indexterm id="ch07-idx-957258-0" class="endofrange" startref="ch07-idx-957248-0"/></para>
1206
1207
1208 <programlisting>[deskjet]
1209         postscript = yes</programlisting>
1210 </sect3>
1211
1212
1213
1214 <sect3 role="" label="7.2.3.9" id="ch07-SECT-2.1.9">
1215 <indexterm id="ch07-idx-958439-0"><primary>print command option</primary></indexterm>
1216 <indexterm id="ch07-idx-958439-1"><primary>lpq command option</primary></indexterm>
1217 <indexterm id="ch07-idx-958439-2"><primary>lprm command option</primary></indexterm>
1218 <indexterm id="ch07-idx-958439-3"><primary>lppause command option</primary></indexterm>
1219 <indexterm id="ch07-idx-958439-4"><primary>lpresume command option</primary></indexterm>
1220 <title>
1221
1222
1223
1224
1225 print command, lpq command, lprm command, lppause command, lpresume command</title>
1226
1227
1228 <para>
1229 <indexterm id="ch07-idx-956566-0"><primary>Unix</primary><secondary>options</secondary><tertiary sortas="print commands">for print commands</tertiary></indexterm>These options tell Samba which Unix commands used to control and send data to the printer. The Unix commands involved are: <emphasis>lpr</emphasis> (send to Line PRinter), <emphasis>lpq</emphasis> (List Printer Queue), <emphasis>lprm</emphasis> (Line printer ReMove), and optionally <emphasis>lppause</emphasis> and <emphasis>lpresume</emphasis>. Samba provides an option named after each of these commands, in case you need to override any of the system defaults. For example, consider:</para>
1230
1231
1232 <programlisting>lpq command = /usr/ucb/lpq %p</programlisting>
1233
1234
1235 <para>This would set the <literal>lpq command</literal> to use <filename>/usr/ucb/lpq</filename>. Similarly:</para>
1236
1237
1238 <programlisting>lprm command = /usr/local/lprm -P%p %j</programlisting>
1239
1240
1241 <para>would set the Samba printer remove command to <filename>/usr/local/lprm</filename>, and provide it the print job number using the <literal>%j</literal> variable.</para>
1242
1243
1244 <para>The default values for each of these options are dependent on the value of the <literal>printing</literal> option. <link linkend="ch07-82964">Table 7.4</link> shows the default commands for each of the printing options. The most popular printing system is BSD.</para>
1245
1246
1247 <table label="7.4" id="ch07-82964">
1248 <title>Default Commands for Various Printing Commands </title>
1249
1250 <tgroup cols="5">
1251 <colspec colnum="1" colname="col1"/>
1252 <colspec colnum="2" colname="col2"/>
1253 <colspec colnum="3" colname="col3"/>
1254 <colspec colnum="4" colname="col4"/>
1255 <colspec colnum="5" colname="col5"/>
1256 <thead>
1257 <row>
1258
1259 <entry colname="col1"><para>Option</para></entry>
1260
1261 <entry colname="col2"><para>BSD, AIX, PLP, LPRNG</para></entry>
1262
1263 <entry colname="col3"><para>SYSV, HPUX</para></entry>
1264
1265 <entry colname="col4"><para>QNX</para></entry>
1266
1267 <entry colname="col5"><para>SOFTQ</para></entry>
1268
1269 </row>
1270
1271 </thead>
1272
1273 <tbody>
1274 <row>
1275
1276 <entry colname="col1"><para><literal>print command</literal></para></entry>
1277
1278 <entry colname="col2"><para><literal>lpr -r -P%p %s</literal>
1279 <indexterm id="ch07-idx-958518-0"><primary>printing</primary><secondary>commands</secondary><tertiary>default commands for</tertiary></indexterm></para></entry>
1280
1281 <entry colname="col3"><para><literal>lp -c -d%p %s; rm %s</literal></para></entry>
1282
1283 <entry colname="col4"><para><literal>lp -r -P%p %s</literal></para></entry>
1284
1285 <entry colname="col5"><para><literal>lp -d%p -s %s; rm %s</literal></para></entry>
1286
1287 </row>
1288
1289 <row>
1290
1291 <entry colname="col1"><para><literal>lpq command</literal></para></entry>
1292
1293 <entry colname="col2"><para><literal>lpq -P%p</literal></para></entry>
1294
1295 <entry colname="col3"><para><literal>lpstat -o%p</literal></para></entry>
1296
1297 <entry colname="col4"><para><literal>lpq -P%p</literal></para></entry>
1298
1299 <entry colname="col5"><para><literal>lpstat -o%p</literal></para></entry>
1300
1301 </row>
1302
1303 <row>
1304
1305 <entry colname="col1"><para><literal>lprm command</literal></para></entry>
1306
1307 <entry colname="col2"><para><literal>lprm -P%p %j</literal></para></entry>
1308
1309 <entry colname="col3"><para><literal>cancel %p-%j</literal></para></entry>
1310
1311 <entry colname="col4"><para><literal>cancel %p-%j</literal></para></entry>
1312
1313 <entry colname="col5"><para><literal>cancel %p-%j</literal></para></entry>
1314
1315 </row>
1316
1317 <row>
1318
1319 <entry colname="col1"><para><literal>lppause command</literal></para></entry>
1320
1321 <entry colname="col2"><para><literal>lp -i %p-%j -H hold </literal></para>
1322
1323 <para>(SYSV only)</para></entry>
1324
1325 <entry colname="col3"><para>None</para></entry>
1326
1327 <entry colname="col4"><para>None</para></entry>
1328
1329 <entry colname="col5"><para>None</para></entry>
1330
1331 </row>
1332
1333 <row>
1334
1335 <entry colname="col1"><para><literal>lpresume command</literal></para></entry>
1336
1337 <entry colname="col2"><para><literal>lp -i %p-%j -H resume</literal></para>
1338
1339 <para>(SYSV only)</para></entry>
1340
1341 <entry colname="col3"><para>None</para></entry>
1342
1343 <entry colname="col4"><para>None</para></entry>
1344
1345 <entry colname="col5"><para><literal>qstat -s -j%j -r</literal></para></entry>
1346
1347 </row>
1348
1349 </tbody>
1350 </tgroup>
1351 </table>
1352
1353
1354 <para>It is typically not necessary to reset these options in Samba, with the possible exception of <literal>print</literal> <literal>command</literal>. This option may need to be explicitly set if your printing system doesn't have a <literal>-r</literal> (remove after printing) option on the printing command. For example:</para>
1355
1356
1357 <programlisting>/usr/local/lpr -P%p %s; /bin/rm %s</programlisting>
1358
1359
1360 <para>With a bit of judicious programming, these <filename>smb.conf</filename> options can also used for debugging:</para>
1361
1362
1363 <programlisting>print command = cat %s &gt;&gt;/tmp/printlog; lpr -r -P%p %s</programlisting>
1364
1365
1366 <para>For example, this configuration can verify that files are actually being delivered to the Samba server. If they are, their contents will show up in the <filename>/tmp/printlog</filename> file.</para>
1367
1368
1369 <para>After BSD, the next most popular kind of printing system is SYSV (or System V) printing, plus some SYSV variants for IBM's AIX and Hewlett-Packard's HP-UX. These system do not have an <filename>/etc/printcap</filename> file. Instead, the <literal>printcap</literal> <literal>file</literal> option can be set to an appropriate <emphasis>lpstat</emphasis> command for the system. This tells Samba to get a list of printers from the <emphasis>lpstat</emphasis> command. Alternatively, you can set the global configuration option <literal>printcap</literal> <literal>name</literal> to the name of a dummy <filename>printcap</filename> file you provide. In the latter case, the file must contain a series of lines such as:</para>
1370
1371
1372 <programlisting>lp|print1|My Printer 1
1373 print2|My Printer 2
1374 print3|My Printer 3</programlisting>
1375
1376
1377 <para>Each line names a printer, and provides aliases for it. In this example, the first printer is called <literal>lp</literal>, <literal>print1</literal>, or <literal>My</literal> <literal>Printer</literal> <literal>1</literal>, whichever the user prefers to use. The first name will be used in place of <literal>%p</literal> in any command Samba executes for that printer.</para>
1378
1379
1380 <para>Two additional printer types are also supported by Samba: LPRNG (LPR New Generation) and PLP (Public Line Printer). These are public domain and Open Source printing systems, and are used by many sites to overcome problems with vendor-supplied software. In addition, the SOFTQ and QNX realtime operating systems are supported by Samba.</para>
1381 </sect3>
1382
1383
1384
1385 <sect3 role="" label="7.2.3.10" id="ch07-SECT-2.1.10">
1386 <title>load printers</title>
1387
1388
1389 <para>
1390 <indexterm id="ch07-idx-956568-0"><primary>print shares</primary><secondary>options for</secondary></indexterm>The <literal>load</literal>
1391 <indexterm id="ch07-idx-958440-0"><primary>load printers option</primary></indexterm> <literal>printers</literal> option tells Samba to create shares for all known printer names and load those shares into the browse list. Samba will create and list a printer share for each printer name in <filename>/etc/printcap</filename> (or system equivalent). For example, if your <filename>printcap</filename> file looks like this:<footnote label="2" id="ch07-pgfId-950654">
1392
1393
1394 <para>We have placed annotated comments off to the side in case you've never dealt with this file before.</para>
1395
1396
1397 </footnote></para>
1398
1399
1400 <programlisting>lp:\
1401   :sd=/var/spool/lpd/lp:\            <replaceable># spool directory</replaceable>
1402   :mx#0:\                            <replaceable># maximum file size (none)</replaceable>
1403   :sh:\                              <replaceable># surpress burst header (no)</replaceable>
1404   :lp=/dev/lp1:\                     <replaceable># device name for output</replaceable>
1405   :if=/var/spool/lpd/lp/filter:      <replaceable># text filter</replaceable>
1406
1407 laser:\
1408   :sd=/var/spool/lpd/laser:\         <replaceable># spool directory</replaceable>
1409   :mx#0:\                            <replaceable># maximum file size (none)</replaceable>
1410   :sh:\                              <replaceable># surpress burst header (no)</replaceable>
1411   :lp=/dev/laser:\                   <replaceable># device name for output</replaceable>
1412   :if=/var/spool/lpd/lp/filter:      <replaceable># text filter</replaceable></programlisting>
1413
1414
1415 <para>and you specify:</para>
1416
1417
1418 <programlisting>load printers = yes</programlisting>
1419
1420
1421 <para>the shares <literal>[lp]</literal> and <literal>[laser]</literal> will automatically be created as valid print shares when Samba is started. Both shares will borrow the configuration options specified in the <literal>[printers]</literal> section to configure themselves, and will be available in the browse list for the Samba server.</para>
1422 </sect3>
1423
1424
1425
1426 <sect3 role="" label="7.2.3.11" id="ch07-SECT-2.1.11">
1427 <title>printcap name</title>
1428
1429
1430 <para>If the <literal>printcap</literal>
1431 <indexterm id="ch07-idx-958442-0"><primary>printcap name option</primary></indexterm> <literal>name</literal> option (also called <literal>printcap</literal>) appears in a printing share, Samba will use the file specified as the system printer capabilities file. This is normally <filename>/etc/printcap</filename>. However, you can reset it to a file consisting of only the printers you want to share over the network. The value must be a fully-qualified filename of a printer capabilities file on the server:</para>
1432
1433
1434 <programlisting>[deskjet]
1435         printcap name = /usr/local/printcap</programlisting>
1436 </sect3>
1437
1438
1439
1440 <sect3 role="" label="7.2.3.12" id="ch07-SECT-2.1.12">
1441 <title>min print space</title>
1442
1443
1444 <para>The <literal>min</literal>
1445 <indexterm id="ch07-idx-958443-0"><primary>min print space option</primary></indexterm> <literal>print</literal> <literal>space</literal> option sets the amount of <indexterm id="ch07-idx-956570-0"><primary>spool space, options for</primary></indexterm>spool space that must be available on the disk before printing is allowed. Setting it to zero (the default) turns the check off; setting it to any other number sets the amount of free space in kilobytes required. This option helps avoid having print jobs fill up the remaining disk space on the server, which may cause other processes to fail:</para>
1446
1447
1448 <programlisting>[deskjet]
1449         min print space = 4000</programlisting>
1450 </sect3>
1451
1452
1453
1454 <sect3 role="" label="7.2.3.13" id="ch07-SECT-2.1.13">
1455 <indexterm id="ch07-idx-958444-0"><primary>queuepause command option</primary></indexterm>
1456 <title>
1457 queuepause command</title>
1458
1459
1460 <para>This configuration option specifies a command that tells Samba how to pause a <indexterm id="ch07-idx-956571-0"><primary>print queue, options for</primary></indexterm>print queue entirely, as opposed to a single job on the queue. The default value depends on the printing type chosen. You should not need to alter this option.</para>
1461 </sect3>
1462
1463
1464
1465 <sect3 role="" label="7.2.3.14" id="ch07-SECT-2.1.14">
1466 <indexterm id="ch07-idx-958445-0"><primary>queueresume command option</primary></indexterm>
1467 <title>
1468 queueresume command</title>
1469
1470
1471 <para>This configuration option specifies a command that tells Samba how to resume a paused print queue, as opposed to resuming a single job on the print queue. The default value depends on the printing type chosen. You should not need to alter<indexterm id="ch07-idx-956423-0" class="endofrange" startref="ch07-idx-956419-0"/> this<indexterm id="ch07-idx-956372-0" class="endofrange" startref="ch07-idx-956368-0"/> option.<indexterm id="ch07-idx-956352-0" class="endofrange" startref="ch07-idx-956351-0"/></para>
1472 </sect3>
1473 </sect2>
1474 </sect1>
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484 <sect1 role="" label="7.3" id="ch07-12219">
1485 <title>Name Resolution with Samba</title>
1486
1487
1488 <para>
1489 <indexterm id="ch07-idx-956353-0" class="startofrange"><primary>name resolution</primary></indexterm>Before NetBIOS Name Servers (NBNS) came about, name resolution worked entirely by broadcast. If you needed a machine's address, you simply <indexterm id="ch07-idx-956574-0"><primary>broadcasting</primary><seealso>browsing; name resolution</seealso></indexterm>broadcast its name across the network and, in theory, the machine itself would reply. This approach is still possible: anyone looking for a machine named <literal>fred</literal> can still broadcast a query and find out if it exists and what its IP address is. (We use this capability to troubleshoot Samba name services with the <literal>nmblookup</literal> command in <link linkend="SAMBA-CH-9">Chapter 9</link>.)</para>
1490
1491
1492 <para>As you saw in the first chapter, however, broadcasting&mdash;whether it be browsing or name registration and resolution&mdash;does not pass easily across multiple subnets. In addition, many broadcasts tend to bog down networks. To solve this problem, Microsoft now provides the <indexterm id="ch07-idx-956577-0"><primary>WINS (Windows Internet Name Service)</primary><secondary>name resolution and</secondary></indexterm>Windows Internet Naming Service (WINS), a cross-subnet NBNS, which Samba supports. With it, an administrator can designate a single machine to act as a WINS server, and can then provide each client that requires name resolution the address of the WINS server. Consequently, name registration and resolution requests can be directed to a single machine from any point on the network, instead of broadcast.</para>
1493
1494
1495 <para>WINS and broadcasting are not the only means of name resolution, however. There are actually four mechanisms that can be used with Samba:</para>
1496
1497
1498 <itemizedlist>
1499 <listitem><para>WINS</para></listitem>
1500 <listitem><para>Broadcasting</para></listitem>
1501 <listitem><para>Unix <filename>/etc/hosts</filename> or NIS/NIS+ matches</para></listitem>
1502 <listitem><para><emphasis>LMHOSTS</emphasis> file</para></listitem>
1503 </itemizedlist>
1504
1505 <para>Samba can use any or all of these name resolution methods in the order that you specify in the Samba configuration file using the <literal>name</literal> <literal>resolve</literal> <literal>order</literal> parameter. However, before delving into configuration options, let's discuss the one that you've probably not encountered before: the <filename>LMHOSTS</filename> file.</para>
1506
1507
1508 <sect2 role="" label="7.3.1" id="ch07-SECT-3.1">
1509 <title>The LMHOSTS File</title>
1510
1511
1512 <para><filename>LMHOSTS</filename>
1513 <indexterm id="ch07-idx-956428-0"><primary>LMHOSTS file</primary></indexterm> is the standard LAN Manager <emphasis>hosts</emphasis> file used to resolve names into IP addresses on the system. It is the NBT equivalent of the <filename>/etc/hosts</filename> file that is standard on all Unix systems. By default, the file is usually stored as <filename>/usr/local/samba/lib/LMHOSTS</filename> and shares a format similar to <filename>/etc/hosts</filename>. For example:</para>
1514
1515
1516 <programlisting>192.168.220.100    hydra
1517 192.168.220.101    phoenix</programlisting>
1518
1519
1520 <para>The only difference is that the names on the right side of the entries are NetBIOS names instead of DNS names. Because they are NetBIOS names, you can assign resource types to them as well:</para>
1521
1522
1523 <programlisting>192.168.220.100    hydra#20
1524 192.168.220.100    simple#1b
1525 192.168.220.101    phoenix#20</programlisting>
1526
1527
1528 <para>Here, we've assigned the <literal>hydra</literal> machine to be the primary domain controller of the <literal>SIMPLE</literal> domain, as indicated by the resource type &lt;1B&gt; assigned to the name after <literal>hydra</literal>'s IP address in the second line. The other two are standard workstations.</para>
1529
1530
1531 <para>If you wish to place an <emphasis>LMHOSTS</emphasis> file somewhere other than the default location, you will need to notify the <emphasis>nmbd</emphasis> process upon start up, as follows:</para>
1532
1533
1534 <programlisting>nmbd -H /etc/samba/lmhosts -D</programlisting>
1535 </sect2>
1536
1537
1538
1539
1540
1541 <sect2 role="" label="7.3.2" id="ch07-SECT-3.2">
1542 <title>Setting Up Samba to Use Another WINS Server</title>
1543
1544
1545 <para>
1546 <indexterm id="ch07-idx-956595-0"><primary>Samba</primary><secondary>WINS server and</secondary></indexterm>
1547 <indexterm id="ch07-idx-956595-1"><primary>WINS (Windows Internet Name Service) server</primary><secondary>setting up Sambato use</secondary></indexterm>You can set up Samba to use a WINS server somewhere else on the network by simply pointing it to the IP address of the WINS server. This is done with the global <literal>wins</literal> <literal>server</literal> configuration option, as shown here:</para>
1548
1549
1550 <programlisting>[global]
1551         wins server = 192.168.200.122</programlisting>
1552
1553
1554 <para>With this option enabled, Samba will direct all WINS requests to the server at 192.168.200.122. Note that because the request is directed at a single machine, we don't have to worry about any of the problems inherent to broadcasting. However, though you have specified an IP address for a WINS server in the configuration file, Samba will not necessarily use the WINS server before other forms of name resolution. The order in which Samba attempts various name-resolution techniques is given with the <literal>name</literal> <literal>resolve</literal> <literal>order</literal> configuration option, which we will discuss shortly.</para>
1555
1556
1557 <para>If you have a Samba server on a subnet that still uses broadcasting and the Samba server knows the correct location of a WINS server on another subnet, you can configure the Samba server to forward any name resolution requests with the <literal>wins</literal> <literal>proxy</literal> option:</para>
1558
1559
1560 <programlisting>[global]
1561         wins server = 192.168.200.12
1562         wins proxy = yes</programlisting>
1563
1564
1565 <para>Use this only in situations where the WINS server resides on another subnet. Otherwise, the broadcast will reach the WINS server regardless of any proxying.</para>
1566 </sect2>
1567
1568
1569
1570
1571
1572 <sect2 role="" label="7.3.3" id="ch07-83429">
1573 <title>Setting Up Samba as a WINS Server</title>
1574
1575
1576 <para>
1577 <indexterm id="ch07-idx-956600-0"><primary>WINS (Windows Internet Name Service) server</primary><secondary>setting up Samba as</secondary></indexterm>You can set up Samba as a WINS server by setting two global options in the configuration file, as shown below:</para>
1578
1579
1580 <programlisting>[global]
1581         wins support = yes
1582         name resolve order = wins lmhosts hosts bcast</programlisting>
1583
1584
1585 <para>The <literal>wins</literal> <literal>support</literal> option turns Samba into a WINS server. Believe it or not, that's all you need to do! Samba handles the rest of the details behind the scenes, leaving you a relaxed administrator. The <literal>wins</literal> <literal>support=yes</literal> and the <literal>wins</literal> <literal>server</literal> option are mutually exclusive; you cannot simultaneously offer Samba as the WINS server and point to another system as the server.</para>
1586
1587
1588 <para>If Samba is acting as a WINS server, you should probably get familiar with the <literal>name</literal> <literal>resolve</literal> <literal>order</literal> option mentioned earlier. This option tells Samba the order of methods in which it tries to resolve a NetBIOS name. It can take up to four values:</para>
1589
1590
1591 <variablelist>
1592 <varlistentry><term>lmhosts</term>
1593 <listitem><para>Uses a LAN Manager <emphasis>LMHOSTS</emphasis> file</para></listitem>
1594 </varlistentry>
1595
1596
1597 <varlistentry><term>hosts</term>
1598 <listitem><para>Uses the standard name resolution methods of the Unix system, <emphasis>/etc/hosts</emphasis>, DNS, NIS, or a combination (as configured for the system)</para></listitem>
1599 </varlistentry>
1600
1601
1602 <varlistentry><term>wins</term>
1603 <listitem><para>Uses the WINS server</para></listitem>
1604 </varlistentry>
1605
1606
1607 <varlistentry><term>bcast</term>
1608 <listitem><para>Uses a broadcast method</para></listitem>
1609 </varlistentry>
1610 </variablelist>
1611
1612
1613 <para>The order in which you specify them in the value is the order in which Samba will attempt name resolution when acting as a WINS server. For example, let's look at the value specified previously:</para>
1614
1615
1616 <programlisting>name resolve order = wins lmhosts hosts bcast</programlisting>
1617
1618
1619 <para>This means that Samba will attempt to use its WINS entries first for name resolution, followed by the LAN Manager <emphasis>LMHOSTS</emphasis> file on its system. Next, the hosts value causes it to use Unix name resolution methods. The word <literal>hosts</literal> may be misleading; it covers not only the <filename>/etc/hosts</filename> file, but also the use of DNS or NIS (as configured on the Unix host). Finally, if those three do not work, it will use a broadcast to try to locate the correct machine.</para>
1620
1621
1622 <para>Finally, you can instruct a Samba server that is acting as a WINS server to check with the system's DNS server if a requested host cannot be found in its WINS database. With a typical Linux system, for example, you can find the IP address of the DNS server by searching the <filename>/etc/resolv.conf</filename> file. In it, you might see an entry such as the following:</para>
1623
1624
1625 <programlisting>nameserver 127.0.0.1
1626 nameserver 192.168.200.192</programlisting>
1627
1628
1629 <para>This tells us that a DNS server is located at 192.168.220.192. (The 127.0.0.1 is the localhost address and is never a valid DNS server address.)</para>
1630
1631
1632 <para>Use the global <literal>dns</literal> <literal>proxy</literal> option to alert Samba to use the configured DNS server:</para>
1633
1634
1635 <programlisting>[global]
1636         wins support = yes
1637         name resolve order = wins lmhosts hosts bcast
1638         dns proxy = yes</programlisting>
1639 </sect2>
1640
1641
1642
1643
1644
1645 <sect2 role="" label="7.3.4" id="ch07-SECT-3.4">
1646 <title>Name Resolution Configuration Options</title>
1647
1648
1649 <para>
1650 <indexterm id="ch07-idx-956430-0" class="startofrange"><primary>name resolution</primary><secondary>options for</secondary></indexterm>Samba's WINS options are shown in <link linkend="ch07-82331">Table 7.5</link>.</para>
1651
1652
1653 <table label="7.5" id="ch07-82331">
1654 <title>WINS Options </title>
1655
1656 <tgroup cols="5">
1657 <colspec colnum="1" colname="col1"/>
1658 <colspec colnum="2" colname="col2"/>
1659 <colspec colnum="3" colname="col3"/>
1660 <colspec colnum="4" colname="col4"/>
1661 <colspec colnum="5" colname="col5"/>
1662 <thead>
1663 <row>
1664
1665 <entry colname="col1"><para>Option</para></entry>
1666
1667 <entry colname="col2"><para>Parameters</para></entry>
1668
1669 <entry colname="col3"><para>Function</para></entry>
1670
1671 <entry colname="col4"><para>Default</para></entry>
1672
1673 <entry colname="col5"><para>Scope</para></entry>
1674
1675 </row>
1676
1677 </thead>
1678
1679 <tbody>
1680 <row>
1681
1682 <entry colname="col1"><para><literal>wins support</literal></para></entry>
1683
1684 <entry colname="col2"><para>boolean</para></entry>
1685
1686 <entry colname="col3"><para>If set to <literal>yes</literal>, Samba will act as a WINS server.</para></entry>
1687
1688 <entry colname="col4"><para><literal>no</literal></para></entry>
1689
1690 <entry colname="col5"><para>Global</para></entry>
1691
1692 </row>
1693
1694 <row>
1695
1696 <entry colname="col1"><para><literal>wins server</literal></para></entry>
1697
1698 <entry colname="col2"><para>string (IP address or DNS name)</para></entry>
1699
1700 <entry colname="col3"><para>Identifies a WINS server for Samba to use for name registration and resolution.</para></entry>
1701
1702 <entry colname="col4"><para>None</para></entry>
1703
1704 <entry colname="col5"><para>Global</para></entry>
1705
1706 </row>
1707
1708 <row>
1709
1710 <entry colname="col1"><para><literal>wins proxy</literal></para></entry>
1711
1712 <entry colname="col2"><para>boolean</para></entry>
1713
1714 <entry colname="col3"><para>Allows Samba to act as a proxy to a WINS server on another subnet.</para></entry>
1715
1716 <entry colname="col4"><para><literal>no</literal></para></entry>
1717
1718 <entry colname="col5"><para>Global</para></entry>
1719
1720 </row>
1721
1722 <row>
1723
1724 <entry colname="col1"><para><literal>dns proxy</literal></para></entry>
1725
1726 <entry colname="col2"><para>boolean</para></entry>
1727
1728 <entry colname="col3"><para>If set to <literal>yes</literal>, a Samba WINS server will search DNS if it cannot find a name in WINS.</para></entry>
1729
1730 <entry colname="col4"><para><literal>no</literal></para></entry>
1731
1732 <entry colname="col5"><para>Global</para></entry>
1733
1734 </row>
1735
1736 <row>
1737
1738 <entry colname="col1"><para><literal>name resolve order</literal></para></entry>
1739
1740 <entry colname="col2"><para><literal>lmhosts</literal>, <literal>hosts</literal>, <literal>wins</literal>, or <literal>bcast</literal></para></entry>
1741
1742 <entry colname="col3"><para>Specifies an order of the methods used to resolve NetBIOS names.</para></entry>
1743
1744 <entry colname="col4"><para><literal>lmhosts hosts wins bcast</literal></para></entry>
1745
1746 <entry colname="col5"><para>Global</para></entry>
1747
1748 </row>
1749
1750 <row>
1751
1752 <entry colname="col1"><para><literal>max ttl</literal></para></entry>
1753
1754 <entry colname="col2"><para>numerical</para></entry>
1755
1756 <entry colname="col3"><para>Specifies the maximum time-to-live in seconds for a requested NetBIOS names.</para></entry>
1757
1758 <entry colname="col4"><para><literal>259200</literal>( 3 days)</para></entry>
1759
1760 <entry colname="col5"><para>Global</para></entry>
1761
1762 </row>
1763
1764 <row>
1765
1766 <entry colname="col1"><para><literal>max wins ttl</literal></para></entry>
1767
1768 <entry colname="col2"><para>numerical</para></entry>
1769
1770 <entry colname="col3"><para>Specifies the maximum time-to-live in seconds for NetBIOS names given out by Samba as a WINS server.</para></entry>
1771
1772 <entry colname="col4"><para><literal>518400</literal>(6 days)</para></entry>
1773
1774 <entry colname="col5"><para>Global</para></entry>
1775
1776 </row>
1777
1778 <row>
1779
1780 <entry colname="col1"><para><literal>min wins ttl</literal></para></entry>
1781
1782 <entry colname="col2"><para>numerical</para></entry>
1783
1784 <entry colname="col3"><para>Specifies the minimum time-to-live in seconds for NetBIOS names given out by Samba as a WINS server.</para></entry>
1785
1786 <entry colname="col4"><para><literal>21600</literal>(6 hours)</para></entry>
1787
1788 <entry colname="col5"><para>Global</para></entry>
1789
1790 </row>
1791
1792 </tbody>
1793 </tgroup>
1794 </table>
1795
1796
1797 <sect3 role="" label="7.3.4.1" id="ch07-SECT-3.4.1">
1798 <indexterm id="ch07-idx-958447-0"><primary>wins support option</primary></indexterm>
1799 <title>
1800 wins support</title>
1801
1802
1803 <para>Samba will provide <indexterm id="ch07-idx-956607-0"><primary>WINS (Windows Internet Name Service)</primary><secondary>options for</secondary></indexterm>WINS name service to all machines in the network if you set the following in the <literal>[global]</literal> section of the <filename>smb.conf</filename> file:</para>
1804
1805
1806 <programlisting>[global]
1807     wins support = yes</programlisting>
1808
1809
1810 <para>The default value is <literal>no</literal>, which is typically used to allow another Windows NT server to become a WINS server. If you do enable this option, remember that a Samba WINS server currently cannot exchange data with any backup WINS servers. If activated, this option is mutually exclusive with the <literal>wins</literal> <literal>server</literal> parameter; you cannot set both to <literal>yes</literal> at the same time or Samba will flag an error.</para>
1811 </sect3>
1812
1813
1814
1815 <sect3 role="" label="7.3.4.2" id="ch07-SECT-3.4.2">
1816 <indexterm id="ch07-idx-958448-0"><primary>wins server option</primary></indexterm>
1817 <title>
1818 wins server</title>
1819
1820
1821 <para>Samba will use an existing WINS server on the network if you specify the <literal>wins</literal> <literal>server</literal> global option in your configuration file. The value of this option is either the IP address or DNS name (not NetBIOS name) of the WINS server. For example:</para>
1822
1823
1824 <programlisting>[global]
1825     wins server = 192.168.220.110</programlisting>
1826
1827
1828 <para>or:</para>
1829
1830
1831 <programlisting>[global]
1832     wins server = wins.example.com</programlisting>
1833
1834
1835 <para>In order for this option to work, the <literal>wins</literal> <literal>support</literal> option must be set to <literal>no</literal> (the default). Otherwise, Samba will report an error. You can specify only one WINS server using this option.</para>
1836 </sect3>
1837
1838
1839
1840 <sect3 role="" label="7.3.4.3" id="ch07-SECT-3.4.3">
1841 <indexterm id="ch07-idx-958449-0"><primary>wins proxy option</primary></indexterm>
1842 <title>
1843 wins proxy</title>
1844
1845
1846 <para>This option allows Samba to act as a proxy to another WINS server, and thus relay name registration and resolution requests from itself to the real WINS server, often outside the current subnet. The WINS server can be indicated through the <literal>wins</literal> <literal>server</literal> option. The proxy will then return the WINS response back to the client. You can enable this option by specifying the following in the <literal>[global]</literal> section:</para>
1847
1848
1849 <programlisting>[global]
1850     wins proxy = yes</programlisting>
1851 </sect3>
1852
1853
1854
1855 <sect3 role="" label="7.3.4.4" id="ch07-SECT-3.4.4">
1856 <indexterm id="ch07-idx-958450-0"><primary>dns proxy option</primary></indexterm>
1857 <title>
1858 dns proxy</title>
1859
1860
1861 <para>If you want the <indexterm id="ch07-idx-956608-0"><primary>DNS (Domain Name System)</primary><secondary>option for</secondary></indexterm>domain name service (DNS) to be used if a name isn't found in WINS, you can set the following option:</para>
1862
1863
1864 <programlisting>[global]
1865     dns proxy = yes</programlisting>
1866
1867
1868 <para>This will cause <filename>nmbd</filename> to query for machine names using the server's standard domain name service. You may wish to deactivate this option if you do not have a permanent connection to your DNS server. Despite this option, we recommend using a WINS server. If you don't already have any WINS servers on your network, make one Samba machine a WINS server. Do not, however, make two Samba machines WINS servers (one primary and one backup) as they currently cannot exchange WINS databases.</para>
1869 </sect3>
1870
1871
1872
1873 <sect3 role="" label="7.3.4.5" id="ch07-SECT-3.4.5">
1874 <indexterm id="ch07-idx-958451-0"><primary>name resolve order option</primary></indexterm>
1875 <title>
1876 name resolve order</title>
1877
1878
1879 <para>The global <literal>name</literal> <literal>resolve</literal> <literal>order</literal> option specifies the order of services that Samba will use in attempting name resolution. The default order is to use the <emphasis>LMHOSTS</emphasis> file, followed by standard Unix name resolution methods (some combination of    <filename>/etc/hosts</filename>, DNS, and NIS), then query a WINS server, and finally use broadcasting to determine the address of a NetBIOS name. You can override this option by specifying something like the following:</para>
1880
1881
1882 <programlisting>[global]
1883     name resolve order = lmhosts wins hosts bcast</programlisting>
1884
1885
1886 <para>This causes resolution to use the <emphasis>LMHOSTS</emphasis> file first, followed by a query to a WINS server, the system password file, and finally broadcasting. You need not use all four options if you don't want to. This option is covered in more detail in <link linkend="ch07-83429">Section 7.3.3</link> earlier in this chapter.</para>
1887 </sect3>
1888
1889
1890
1891 <sect3 role="" label="7.3.4.6" id="ch07-SECT-3.4.6">
1892 <indexterm id="ch07-idx-958452-0"><primary>max ttl option</primary></indexterm>
1893 <title>
1894 max ttl</title>
1895
1896
1897 <para>This option gives the maximum t<indexterm id="ch07-idx-956610-0"><primary>TTL (time to live), options for</primary></indexterm>
1898 <indexterm id="ch07-idx-956610-1"><primary>time to live (TTL), options for</primary></indexterm>ime to live (T T L) during which a NetBIOS name registered with the Samba server will remain active. You should never need to alter this value.</para>
1899 </sect3>
1900
1901
1902
1903 <sect3 role="" label="7.3.4.7" id="ch07-SECT-3.4.7">
1904 <indexterm id="ch07-idx-958453-0"><primary>max wins ttl option</primary></indexterm>
1905 <title>
1906 max wins ttl</title>
1907
1908
1909 <para>This option give the maximum time to live (T T L) during which a NetBIOS name resolved from a WINS server will remain active. You should never need to change this value from its default.</para>
1910 </sect3>
1911
1912
1913
1914 <sect3 role="" label="7.3.4.8" id="ch07-SECT-3.4.8">
1915 <indexterm id="ch07-idx-958454-0"><primary>min wins ttl option</primary></indexterm>
1916 <title>
1917 min wins ttl</title>
1918
1919
1920 <para>This option give the minimum time to live (T T L) during which a NetBIOS name resolved from a WINS server will remain active. You should never need to alter this value from its<indexterm id="ch07-idx-956431-0" class="endofrange" startref="ch07-idx-956430-0"/> default.<indexterm id="ch07-idx-956354-0" class="endofrange" startref="ch07-idx-956353-0"/></para>
1921 </sect3>
1922 </sect2>
1923 </sect1>
1924 </chapter>