1 TITLE: Samba File and Print Server Hint
3 AUTHOR: Patrick Kirk < patrick@kirks.net >
9 Samba allows your Linux box to perform a number of functions that are
10 typically the preserve of Windows 2000 Server Edition, for example
11 acting as a Primary Domain Controller for a Win2k Domain, acting as a
12 Backup Domain controller or simply as a file server to share disk space
13 with Windows PCs in a safe and secure manner. In all these capacities,
14 Samba can be expected to save a lot of license fees and be far more
15 secure than any alternative.
17 This hint is for setting up samba as a file and print server on machine
18 where security is important. The emphasis is on security for the server
19 and ease of use for the users. For example, I use these settings on the
20 machine that shares my ADSL connection.
26 Samba can be downloaded from www.samba.org. Its default installation
27 created a directory called samba in /usr/local and tidily puts all its
28 bits in there. If like me you like to ne able to backup your system
29 configuration just by backing up /etc this needs to be changes. Also,
30 to save messing around with editing your path, it is worth specifying
31 the executables go in /usr/local/bin and sbin as appropriate.
33 As root execute these commands:
36 tar xzvf samba*.tar.gz &&
37 mkdir -p /etc/samba &&
38 mkdir -p /var/lock/samba &&
39 cd samba-2.2.1a/source &&
40 /configure --prefix=/usr/local --bindir=/usr/local/bin \
41 --sbindir=/usr/local/sbin --libdir=/etc/samba --sysconfdir=/etc/samba \
42 --with-smbmount && make && make install
46 In /etc/samba create a file called smb.conf and paste the following in:
49 workgroup = KIRKS.NET # Put your own in here.
50 netbios name = ENTERPRISE # The hostname for your machine
51 server string = %h server (Samba %v)
52 encrypt passwords = Yes
53 smb passwd file = /etc/samba/sambapasswd #Easier backups
54 syslog = 0 #Level of logging to syslog. Keep this low
56 log file = /var/log/samba/samba.log.%m # where to keep records
57 log level = 2 #Log interesting stuff only
58 # Performance tuning - this works. RTFM before tweaking
59 socket options = IPTOS_LOWDELAY \
60 TCP_NODELAY SO_SNDBUF=4096 SO_RCVBUF=4096
61 dns proxy = No #One tool for one job. Use bind for DNS.
63 #These entries are essential.
65 #Otherwise someone could attack the shares just by browsing
66 # from your workstation
68 # Specify the IP range of your LAN and the ethernet card used to
70 # Leave the 127.0.0.1 entry there for diagnostics
71 interfaces = eth0 192.168.0.0/255.255.255.0 127.0.0.1/24
72 # Even if a remote attacker decodes a password, he is still
74 bind interfaces only = yes
78 # Allows users to store their data on the server
79 comment = Home Directories
85 # Create a folder for publicly shared resources like
86 # databases, telephone lists, etc.
87 comment = Data Files and Backups
88 # You need to set his path. Mine is...
96 # Copy the i386 folder from the Win2k CD here.
97 # Saves lots of time installing new drivers!
98 # Any other other CDs you use a lot.
100 comment = System and Installation Files
101 # You need to set his path. Mine is...
105 directory mask = 0775
109 comment = All Printers
120 smbpasswd -a john adds john and prompts you for john's password. Unless
121 you have lots of users, repeat this for each. If you have too many for
122 this to be practical, configure SWAT which allows you to manage users
123 and groups from a remote web-browser. SWAT is very easy to use but if
124 you need to use it there is detailed documentation including an O'Reilly
125 book in html format on http://sunsite.dk/samba/docs
127 4. Setting up client machines
128 Windows 2000 machines will now just work if the username on the machine
129 is the same as the account name you set up on the samba server. If not
130 the same, then map network drives and take the option use the drive
131 under the name and password you set up on the server.
133 You might consider creating a batch file called login.bat in the startup
134 group of client boxes that goes as follows:
136 net use h: \\192.168.0.1\homes /persistent:no
138 net use i: \\192.168.0.1\data /persistent:no
140 net use j: \\192.168.0.1\system /persistent:no
143 Create a file in /etc/init.d called samba and paste the following in:
146 # Begin /etc/init.d/samba
149 # Include the functions declared in the /etc/init.d/functions file
152 source /etc/init.d/functions
156 echo -n "Starting Samba daemon..."
157 loadproc /usr/local/sbin/nmbd
159 echo -n "...Samba daemon started!"
160 loadproc /usr/local/sbin/smbd
164 echo -n "Stopping Samba daemon!"
167 echo -n "...Samba daemon stopped."
172 echo -n "Reloading Samba daemon configuration file..."
184 statusproc /usr/local/sbin/nmbd
185 statusproc /usr/local/sbin/smbd
189 echo "Usage: $0 {start|stop|reload|restart|status}"
195 # End /etc/init.d/samba
197 To start samba, simply enter /etc/init.d/samba start
199 To have samba start every time your machine starts, run the following
202 chmod 754 /etc/init.d/samba &&
204 ln -s ../init.d/samba /etc/rc0.d/K400samba &&
206 ln -s ../init.d/samba /etc/rc1.d/K400samba &&
208 ln -s ../init.d/samba /etc/rc2.d/K400samba &&
210 ln -s ../init.d/samba /etc/rc3.d/S600samba &&
212 ln -s ../init.d/samba /etc/rc4.d/S600samba &&
214 ln -s ../init.d/samba /etc/rc5.d/S600samba &&
216 ln -s ../init.d/samba /etc/rc6.d/K400samba
220 Congratulations. You now have a fileserver set up that is safe, stable