Some update and Fixes for typos.
[kai/samba.git] / docs / htmldocs / securing-samba.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2 <HTML
3 ><HEAD
4 ><TITLE
5 >Securing Samba</TITLE
6 ><META
7 NAME="GENERATOR"
8 CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
9 REL="HOME"
10 TITLE="SAMBA Project Documentation"
11 HREF="samba-howto-collection.html"><LINK
12 REL="UP"
13 TITLE="Advanced Configuration"
14 HREF="optional.html"><LINK
15 REL="PREVIOUS"
16 TITLE="Stackable VFS modules"
17 HREF="vfs.html"><LINK
18 REL="NEXT"
19 TITLE="Unicode/Charsets"
20 HREF="unicode.html"></HEAD
21 ><BODY
22 CLASS="CHAPTER"
23 BGCOLOR="#FFFFFF"
24 TEXT="#000000"
25 LINK="#0000FF"
26 VLINK="#840084"
27 ALINK="#0000FF"
28 ><DIV
29 CLASS="NAVHEADER"
30 ><TABLE
31 SUMMARY="Header navigation table"
32 WIDTH="100%"
33 BORDER="0"
34 CELLPADDING="0"
35 CELLSPACING="0"
36 ><TR
37 ><TH
38 COLSPAN="3"
39 ALIGN="center"
40 >SAMBA Project Documentation</TH
41 ></TR
42 ><TR
43 ><TD
44 WIDTH="10%"
45 ALIGN="left"
46 VALIGN="bottom"
47 ><A
48 HREF="vfs.html"
49 ACCESSKEY="P"
50 >Prev</A
51 ></TD
52 ><TD
53 WIDTH="80%"
54 ALIGN="center"
55 VALIGN="bottom"
56 ></TD
57 ><TD
58 WIDTH="10%"
59 ALIGN="right"
60 VALIGN="bottom"
61 ><A
62 HREF="unicode.html"
63 ACCESSKEY="N"
64 >Next</A
65 ></TD
66 ></TR
67 ></TABLE
68 ><HR
69 ALIGN="LEFT"
70 WIDTH="100%"></DIV
71 ><DIV
72 CLASS="CHAPTER"
73 ><H1
74 ><A
75 NAME="SECURING-SAMBA"
76 ></A
77 >Chapter 21. Securing Samba</H1
78 ><DIV
79 CLASS="SECT1"
80 ><H1
81 CLASS="SECT1"
82 ><A
83 NAME="AEN3348"
84 >21.1. Introduction</A
85 ></H1
86 ><P
87 >This note was attached to the Samba 2.2.8 release notes as it contained an
88 important security fix.  The information contained here applies to Samba
89 installations in general.</P
90 ></DIV
91 ><DIV
92 CLASS="SECT1"
93 ><H1
94 CLASS="SECT1"
95 ><A
96 NAME="AEN3351"
97 >21.2. Using host based protection</A
98 ></H1
99 ><P
100 >In many installations of Samba the greatest threat comes for outside
101 your immediate network. By default Samba will accept connections from
102 any host, which means that if you run an insecure version of Samba on
103 a host that is directly connected to the Internet you can be
104 especially vulnerable.</P
105 ><P
106 >One of the simplest fixes in this case is to use the 'hosts allow' and
107 'hosts deny' options in the Samba smb.conf configuration file to only
108 allow access to your server from a specific range of hosts. An example
109 might be:</P
110 ><P
111 ><PRE
112 CLASS="PROGRAMLISTING"
113 >  hosts allow = 127.0.0.1 192.168.2.0/24 192.168.3.0/24
114   hosts deny = 0.0.0.0/0</PRE
115 ></P
116 ><P
117 >The above will only allow SMB connections from 'localhost' (your own
118 computer) and from the two private networks 192.168.2 and
119 192.168.3. All other connections will be refused connections as soon
120 as the client sends its first packet. The refusal will be marked as a
121 'not listening on called name' error.</P
122 ></DIV
123 ><DIV
124 CLASS="SECT1"
125 ><H1
126 CLASS="SECT1"
127 ><A
128 NAME="AEN3358"
129 >21.3. Using interface protection</A
130 ></H1
131 ><P
132 >By default Samba will accept connections on any network interface that
133 it finds on your system. That means if you have a ISDN line or a PPP
134 connection to the Internet then Samba will accept connections on those
135 links. This may not be what you want.</P
136 ><P
137 >You can change this behaviour using options like the following:</P
138 ><P
139 ><PRE
140 CLASS="PROGRAMLISTING"
141 >  interfaces = eth* lo
142   bind interfaces only = yes</PRE
143 ></P
144 ><P
145 ></P
146 ><P
147 >This tells Samba to only listen for connections on interfaces with a
148 name starting with 'eth' such as eth0, eth1, plus on the loopback
149 interface called 'lo'. The name you will need to use depends on what
150 OS you are using, in the above I used the common name for Ethernet
151 adapters on Linux.</P
152 ><P
153 >If you use the above and someone tries to make a SMB connection to
154 your host over a PPP interface called 'ppp0' then they will get a TCP
155 connection refused reply. In that case no Samba code is run at all as
156 the operating system has been told not to pass connections from that
157 interface to any process.</P
158 ></DIV
159 ><DIV
160 CLASS="SECT1"
161 ><H1
162 CLASS="SECT1"
163 ><A
164 NAME="AEN3367"
165 >21.4. Using a firewall</A
166 ></H1
167 ><P
168 >Many people use a firewall to deny access to services that they don't
169 want exposed outside their network. This can be a very good idea,
170 although I would recommend using it in conjunction with the above
171 methods so that you are protected even if your firewall is not active
172 for some reason.</P
173 ><P
174 >If you are setting up a firewall then you need to know what TCP and
175 UDP ports to allow and block. Samba uses the following:</P
176 ><P
177 ><PRE
178 CLASS="PROGRAMLISTING"
179 >UDP/137    - used by nmbd
180 UDP/138    - used by nmbd
181 TCP/139    - used by smbd
182 TCP/445    - used by smbd</PRE
183 ></P
184 ><P
185 >The last one is important as many older firewall setups may not be
186 aware of it, given that this port was only added to the protocol in
187 recent years. </P
188 ></DIV
189 ><DIV
190 CLASS="SECT1"
191 ><H1
192 CLASS="SECT1"
193 ><A
194 NAME="AEN3374"
195 >21.5. Using a IPC$ share deny</A
196 ></H1
197 ><P
198 >If the above methods are not suitable, then you could also place a
199 more specific deny on the IPC$ share that is used in the recently
200 discovered security hole. This allows you to offer access to other
201 shares while denying access to IPC$ from potentially untrustworthy
202 hosts.</P
203 ><P
204 >To do that you could use:</P
205 ><P
206 ><PRE
207 CLASS="PROGRAMLISTING"
208 >  [ipc$]
209      hosts allow = 192.168.115.0/24 127.0.0.1
210      hosts deny = 0.0.0.0/0</PRE
211 ></P
212 ><P
213 >this would tell Samba that IPC$ connections are not allowed from
214 anywhere but the two listed places (localhost and a local
215 subnet). Connections to other shares would still be allowed. As the
216 IPC$ share is the only share that is always accessible anonymously
217 this provides some level of protection against attackers that do not
218 know a username/password for your host.</P
219 ><P
220 >If you use this method then clients will be given a 'access denied'
221 reply when they try to access the IPC$ share. That means that those
222 clients will not be able to browse shares, and may also be unable to
223 access some other resources. </P
224 ><P
225 >This is not recommended unless you cannot use one of the other
226 methods listed above for some reason.</P
227 ></DIV
228 ><DIV
229 CLASS="SECT1"
230 ><H1
231 CLASS="SECT1"
232 ><A
233 NAME="AEN3383"
234 >21.6. Upgrading Samba</A
235 ></H1
236 ><P
237 >Please check regularly on http://www.samba.org/ for updates and
238 important announcements.  Occasionally security releases are made and 
239 it is highly recommended to upgrade Samba when a security vulnerability
240 is discovered.</P
241 ></DIV
242 ></DIV
243 ><DIV
244 CLASS="NAVFOOTER"
245 ><HR
246 ALIGN="LEFT"
247 WIDTH="100%"><TABLE
248 SUMMARY="Footer navigation table"
249 WIDTH="100%"
250 BORDER="0"
251 CELLPADDING="0"
252 CELLSPACING="0"
253 ><TR
254 ><TD
255 WIDTH="33%"
256 ALIGN="left"
257 VALIGN="top"
258 ><A
259 HREF="vfs.html"
260 ACCESSKEY="P"
261 >Prev</A
262 ></TD
263 ><TD
264 WIDTH="34%"
265 ALIGN="center"
266 VALIGN="top"
267 ><A
268 HREF="samba-howto-collection.html"
269 ACCESSKEY="H"
270 >Home</A
271 ></TD
272 ><TD
273 WIDTH="33%"
274 ALIGN="right"
275 VALIGN="top"
276 ><A
277 HREF="unicode.html"
278 ACCESSKEY="N"
279 >Next</A
280 ></TD
281 ></TR
282 ><TR
283 ><TD
284 WIDTH="33%"
285 ALIGN="left"
286 VALIGN="top"
287 >Stackable VFS modules</TD
288 ><TD
289 WIDTH="34%"
290 ALIGN="center"
291 VALIGN="top"
292 ><A
293 HREF="optional.html"
294 ACCESSKEY="U"
295 >Up</A
296 ></TD
297 ><TD
298 WIDTH="33%"
299 ALIGN="right"
300 VALIGN="top"
301 >Unicode/Charsets</TD
302 ></TR
303 ></TABLE
304 ></DIV
305 ></BODY
306 ></HTML
307 >