Final Addition. Copy layout is next.
[Samba/gebeck_regimport.git] / docs / Samba3-HOWTO / TOSHARG-ConfigSmarts.xml
blob7c9cfcbc04879995d5d86cad53713a9903a03c56
1 <?xml version="1.0" encoding="iso-8859-1"?>
2 <!DOCTYPE chapter PUBLIC "-//Samba-Team//DTD DocBook V4.2-Based Variant V1.0//EN" "http://www.samba.org/samba/DTD/samba-doc">
3 <chapter id="cfgsmarts">
4 <chapterinfo>
5         &author.jht;
6         <pubdate>June 30, 2005</pubdate>
7 </chapterinfo>
8 <title>Advanced Configuration Techniques</title>
10 <para>
11 Since the release of the first edition of this book there have been repeated requests to better document
12 configuration techniques that may help a network administrator to get more out of Samba. Some users have asked
13 for documentation regarding the use of the <smbconfoption name="include">file-name</smbconfoption> parameter.
14 </para>
16 <para>
17 Commencing around mid-2004 there has been increasing interest in the ability to host multiple Samba servers on
18 one machine. There has also been an interest in the hosting of multiple Samba server personalities on one
19 server.
20 </para>
22 <para>
23 Feedback from technical reviewers made the inclusion of this chapter a necessity. So finally, here is an attempt
24 to answer the questions that have to date not been adequately addressed. Additional user input is welcome as
25 it will help this chapter to mature. What is presented here is just a small beginning.
26 </para>
28 <para>
29 There are a number of ways in which multiple servers can be hosted on a single Samba server. Multiple server
30 hosting makes it possible to host multiple domain controllers on one machine. Each such machine is
31 independent, and each can be stopped or started without affecting another.
32 </para>
34 <para>
35 Sometimes it is desirable to host multiple servers, each with its own security mode. For example, a single
36 UNIX/Linux host may be a domain member server (DMS) as well as a generic anonymous print server. In this case,
37 only domain member machines and domain users can access the DMS, but even guest users can access the generic
38 print server. Another example of a situation where it may be beneficial to host a generic (anonymous) server
39 is to host a CDROM server.
40 </para>
42 <para>
43 Some environments dictate the need to have separate servers, each with their own resources, each of which are
44 accessible only by certain users or groups. This is one of the simple, but highly effective, capabilities
45 </para>
47 <sect1>
48 <title>Implementation</title>
50 <para>
51 </para>
53 <sect2>
54 <title>Multiple Server Hosting</title>
56 <para>
57 The use of multiple server hosting involves running multiple separate instances of Samba, each with it's own
58 configuration file. This method is complicated by the fact that each instance of &nmbd;, &smbd; and &winbindd;
59 must have write access to entirely separate TDB files. The ability to keep separate the TDB files used by
60 &nmbd;, &smbd; and &winbindd; can be enabled either by recompiling Samba for each server hosted so each has its
61 own default TDB directories, or by configuring these in the &smb.conf; file, in which case each instance of
62 &nmbd;, &smbd; and &winbindd; must be told to start up with its own &smb.conf; configuration file.
63 </para>
65 <para>
66 Each instance should operate on its own IP address (that independent IP address can be an IP Alias).
67 Each instance of &nmbd;, &smbd; and &winbindd; should listen only on its own IP socket. This can be secured
68 using the <smbconfoption name="socket address"/> parameter. Each instance of the Samba server will have its
69 own SID also, this means that the servers are discrete and independent of each other.
70 </para>
72 <para>
73 The user of multiple server hosting is non-trivial, and requires careful configuration of each aspect of
74 process management and start up. The &smb.conf; parameters that must be carefully configured includes:
75 <smbconfoption name="private dir"/>, <smbconfoption name="pid directory"/>,<smbconfoption name="lock
76 directory"/>, <smbconfoption name="interfaces"/>, <smbconfoption name="bind interfaces only"/>, <smbconfoption
77 name="netbios name"/>, <smbconfoption name="workgroup"/>, <smbconfoption name="socket address"/>.
78 </para>
80 <para>
81 Those who elect to use this method of creating multiple Samba servers must have the ability to read and follow
82 the Samba source code, and to modify it as needed. This mode of deployment is considered beyond the scope of
83 this book. However, if someone will contribute more comprehensive documentation we will gladly review it, and
84 if it is suitable extend this section of this chapter. Until such documentation becomes available the hosting
85 of multiple samba servers on a single host is considered not supported for Samba-3 by the Samba Team.
86 </para>
88 </sect2>
90 <sect2>
91 <title>Multiple Virtual Server Personalities</title>
93 <para>
94 Samba has the ability to host multiple virtual servers, each of which have their own personality.  This is
95 achieved by configuring an &smb.conf; file that is common to all personalities hosted.  Each server
96 personality is hosted using its own <smbconfoption name="netbios alias"/> name, and each has its own distinct
97 <smbconfoption name="[global]"/> section. Each server may have its own stanzas for services and meta-services.
98 </para>
100 <para>
101 When hosting multiple virtual servers, each with their own personality, each can be in a different workgroup.
102 Only the primary server can be a domain member or a domain controller. The personality is defined by the
103 combination of the <smbconfoption name="security"/> mode it is operating in, the <smbconfoption name="netbios
104 alias"/> it has, and the <smbconfoption name="workgroup"/> that is defined for it.
105 </para>
107 <para>
108 This configuration style can be used either with NetBIOS names, or using NetBIOS-less SMB over TCP services.
109 If run using NetBIOS mode (the most common method) it is important that the parameter <smbconfoption name="smb
110 ports">139</smbconfoption> should be specified in the primary &smb.conf; file. Failure to do this will result
111 in Samba operating over TCP port 445 and problematic operation at best, and at worst only being able to obtain
112 the functionality that is specified in the primary &smb.conf; file. The use of NetBIOS over TCP/IP using only
113 TCP port 139 means that the use of the <literal>%L</literal> macro is fully enabled. If the <smbconfoption
114 name="smb ports">139</smbconfoption> is not specified (the default is <parameter>445 139</parameter>, or if
115 the value of this parameter is set at <parameter>139 445</parameter> then the <literal>%L</literal> parameter
116 is not serviceable.
117 </para>
119 <para>
120 It is possible to host multiple servers, each with their own personality, using port 445 (the NetBIOS-less SMB
121 port), in which case the <literal>%i</literal> parameter can be used to provide separate server identities (by
122 IP Address). Each can have its own <smbconfoption name="security"/> mode. It will be necessary to use the
123 <smbconfoption name="interfaces"/>, <smbconfoption name="bind interfaces only"/> and IP aliases in addition to
124 the <smbconfoption name="netbios name"/> parameters to create the virtual servers. This method is considerably
125 more complex than that using NetBIOS names only using TCP port 139.
126 </para>
128 <para>
129 Consider an example environment that consists of a standalone, user-mode security Samba server and a read-only
130 Windows 95 file server that has to be replaced. Instead of replacing the Windows 95 machine with a new PC, it
131 is possible to add this server as a read-only anonymous file server that is hosted on the Samba server. Here
132 are some parameters:
133 </para>
135 <para>
136 The Samba server is called <literal>ELASTIC</literal>, its workgroup name is <literal>ROBINSNEST</literal>.
137 The CDROM server is called <literal>CDSERVER</literal> and its workgroup is <literal>ARTSDEPT</literal>. A
138 possible implementation is shown here:
139 </para>
141 <para>
142 The &smb.conf; file for the master server is shown in <link linkend="elastic">Elastic smb.conf File</link>.
143 This file is placed in the <filename>/etc/samba</filename> directory. Only the &nmbd; and the &smbd; daemons
144 are needed. When started the server will appear in Windows Network Neighborhood as the machine
145 <literal>ELASTIC</literal> under the workgroup <literal>ROBINSNEST</literal>. It is helpful if the Windows
146 clients that must access this server are also in the workgroup <literal>ROBINSNEST</literal> as this will make
147 browsing much more reliable.
148 </para>
150 <example id="elastic">
151 <title>Elastic smb.conf File</title>
152 <smbconfblock>
153 <smbconfcomment>Global parameters</smbconfcomment>
154 <smbconfsection name="[global]"/>
155 <smbconfoption name="workgroup">ROBINSNEST</smbconfoption>
156 <smbconfoption name="netbios name">ELASTIC</smbconfoption>
157 <smbconfoption name="netbios aliases">CDSERVER</smbconfoption>
158 <smbconfoption name="smb ports">139</smbconfoption>
159 <smbconfoption name="printcap name">cups</smbconfoption>
160 <smbconfoption name="disable spoolss">Yes</smbconfoption>
161 <smbconfoption name="show add printer wizard">No</smbconfoption>
162 <smbconfoption name="printing">cups</smbconfoption>
163 <smbconfoption name="include">/etc/samba/smb-%L.conf</smbconfoption>
165 <smbconfsection name="[homes]"/>
166 <smbconfoption name="comment">Home Directories</smbconfoption>
167 <smbconfoption name="valid users">%S</smbconfoption>
168 <smbconfoption name="read only">No</smbconfoption>
169 <smbconfoption name="browseable">No</smbconfoption>
171 <smbconfsection name="[office]"/>
172 <smbconfoption name="comment">Data</smbconfoption>
173 <smbconfoption name="path">/data</smbconfoption>
174 <smbconfoption name="read only">No</smbconfoption>
176 <smbconfsection name="[printers]"/>
177 <smbconfoption name="comment">All Printers</smbconfoption>
178 <smbconfoption name="path">/var/spool/samba</smbconfoption>
179 <smbconfoption name="create mask">0600</smbconfoption>
180 <smbconfoption name="guest ok">Yes</smbconfoption>
181 <smbconfoption name="printable">Yes</smbconfoption>
182 <smbconfoption name="use client driver">Yes</smbconfoption>
183 <smbconfoption name="browseable">No</smbconfoption>
184 </smbconfblock>
185 </example>
187 <para>
188 The configuration file for the CDROM server is listed in <link linkend="cdserver">CDROM Server
189 smb-cdserver.conf file</link>. This file is called <filename>smb-cdserver.conf</filename> and it should be
190 located in the <filename>/etc/samba</filename> directory. Machines that are in the workgroup
191 <literal>ARTSDEPT</literal> will be able to browse this server freely.
192 </para>
194 <example id="cdserver">
195 <title>CDROM Server smb-cdserver.conf file</title>
196 <smbconfblock>
197 <smbconfcomment>Global parameters</smbconfcomment>
198 <smbconfsection name="[global]"/>
199 <smbconfoption name="workgroup">ARTSDEPT</smbconfoption>
200 <smbconfoption name="netbios name">CDSERVER</smbconfoption>
201 <smbconfoption name="map to guest">Bad User</smbconfoption>
202 <smbconfoption name="guest ok">Yes</smbconfoption>
204 <smbconfsection name="[carousel]"/>
205 <smbconfoption name="comment">CDROM Share</smbconfoption>
206 <smbconfoption name="path">/export/cddata</smbconfoption>
207 <smbconfoption name="read only">Yes</smbconfoption>
208 <smbconfoption name="guest ok">Yes</smbconfoption>
209 </smbconfblock>
210 </example>
212 <para>
213 The two servers have different resources and are in separate workgroups. The server <literal>ELASTIC</literal>
214 can only be accessed by uses who have an appropriate account on the host server. All users will be able to
215 access the CDROM data that is stored in the <filename>/export/cddata</filename> directory. File system
216 permissions should set so that the <literal>others</literal> user has read-only access to the directory and its
217 contents. The files can be owned by root (any user other than the nobody account).
218 </para>
220 </sect2>
222 <sect2>
223 <title>Multiple Virtual Server Hosting</title>
225 <para>
226 In this example, the requirement is for a primary domain controller for the domain called
227 <literal>MIDEARTH</literal>. The PDC will be called <literal>MERLIN</literal>. An extra machine called
228 <literal>SAURON</literal> is required. Each machine will have only its own shares. Both machines belong to the
229 same domain/workgroup.
230 </para>
232 <para>
233 The master &smb.conf; file is shown in <link linkend="mastersmbc">the Master smb.conf File Global Section</link>.
234 The two files that specify the share information for each server are shown in <link linkend="merlinsmbc">the
235 smb-merlin.conf File Share Section</link>, and <link linkend="sauronsmbc">the smb-sauron.conf File Share
236 Section</link>. All three files are locate in the <filename>/etc/samba</filename> directory.
237 </para>
239 <example id="mastersmbc">
240 <title>Master smb.conf File Global Section</title>
241 <smbconfblock>
242 <smbconfcomment>Global parameters</smbconfcomment>
243 <smbconfsection name="[global]"/>
244 <smbconfoption name="workgroup">MIDEARTH</smbconfoption>
245 <smbconfoption name="netbios name">MERLIN</smbconfoption>
246 <smbconfoption name="netbios aliases">SAURON</smbconfoption>
247 <smbconfoption name="passdb backend">tdbsam</smbconfoption>
248 <smbconfoption name="smb ports">139</smbconfoption>
249 <smbconfoption name="syslog">0</smbconfoption>
250 <smbconfoption name="printcap name">CUPS</smbconfoption>
251 <smbconfoption name="show add printer wizard">No</smbconfoption>
252 <smbconfoption name="add user script">/usr/sbin/useradd -m '%u'</smbconfoption>
253 <smbconfoption name="delete user script">/usr/sbin/userdel -r '%u'</smbconfoption>
254 <smbconfoption name="add group script">/usr/sbin/groupadd '%g'</smbconfoption>
255 <smbconfoption name="delete group script">/usr/sbin/groupdel '%g'</smbconfoption>
256 <smbconfoption name="add user to group script">/usr/sbin/usermod -G '%g' '%u'</smbconfoption>
257 <smbconfoption name="add machine script">/usr/sbin/useradd -s /bin/false -d /var/lib/nobody '%u'</smbconfoption>
258 <smbconfoption name="logon script">scripts\login.bat</smbconfoption>
259 <smbconfoption name="logon path"> </smbconfoption>
260 <smbconfoption name="logon drive">X:</smbconfoption>
261 <smbconfoption name="domain logons">Yes</smbconfoption>
262 <smbconfoption name="preferred master">Yes</smbconfoption>
263 <smbconfoption name="wins support">Yes</smbconfoption>
264 <smbconfoption name="printing">CUPS</smbconfoption>
265 <smbconfoption name="include">/etc/samba/smb-%L.conf</smbconfoption>
266 </smbconfblock>
267 </example>
269 <example id="merlinsmbc">
270 <title>MERLIN smb-merlin.conf File Share Section</title>
271 <smbconfblock>
272 <smbconfcomment>Global parameters</smbconfcomment>
273 <smbconfsection name="[global]"/>
274 <smbconfoption name="workgroup">MIDEARTH</smbconfoption>
275 <smbconfoption name="netbios name">MERLIN</smbconfoption>
277 <smbconfsection name="[homes]"/>
278 <smbconfoption name="comment">Home Directories</smbconfoption>
279 <smbconfoption name="valid users">%S</smbconfoption>
280 <smbconfoption name="read only">No</smbconfoption>
281 <smbconfoption name="browseable">No</smbconfoption>
283 <smbconfsection name="[office]"/>
284 <smbconfoption name="comment">Data</smbconfoption>
285 <smbconfoption name="path">/data</smbconfoption>
286 <smbconfoption name="read only">No</smbconfoption>
288 <smbconfsection name="[netlogon]"/>
289 <smbconfoption name="comment">NETLOGON</smbconfoption>
290 <smbconfoption name="path">/var/lib/samba/netlogon</smbconfoption>
291 <smbconfoption name="read only">Yes</smbconfoption>
292 <smbconfoption name="browseable">No</smbconfoption>
294 <smbconfsection name="[printers]"/>
295 <smbconfoption name="comment">All Printers</smbconfoption>
296 <smbconfoption name="path">/var/spool/samba</smbconfoption>
297 <smbconfoption name="printable">Yes</smbconfoption>
298 <smbconfoption name="use client driver">Yes</smbconfoption>
299 <smbconfoption name="browseable">No</smbconfoption>
300 </smbconfblock>
301 </example>
303 <example id="sauronsmbc">
304 <title>SAURON smb-sauron.conf File Share Section</title>
305 <smbconfblock>
306 <smbconfcomment>Global parameters</smbconfcomment>
307 <smbconfsection name="[global]"/>
308 <smbconfoption name="workgroup">MIDEARTH</smbconfoption>
309 <smbconfoption name="netbios name">SAURON</smbconfoption>
311 <smbconfsection name="[www]"/>
312 <smbconfoption name="comment">Web Pages</smbconfoption>
313 <smbconfoption name="path">/srv/www/htdocs</smbconfoption>
314 <smbconfoption name="read only">No</smbconfoption>
315 </smbconfblock>
316 </example>
318 </sect2>
320 </sect1>
322 </chapter>