Fileserver with Samba and Printserver with CUPS Howto
Home File and Print Server howto.
This howto shows one how to setup a basic file server for a home network using Samba, and a print server using CUPS. This howto has been tested with SUSE Linux 9.3 and Gentoo 2005.1 and everything works out fine. This howto will try not to be distro-specific, rather I will try to make it possible to work with all distros.
This is not a support thread, if you have any problems, please start a new topic in the relevant forum detailing what exactly the problem is. Any posts to this one should be about suggestions on how to improve this howto or for any updates. Support questions will be ignored in this thread.
Note, I will not be using GUI tools to setup the file and print servers, so if you want to use webmin or SWAT to setup your samba server, feel free, but this guide doesn't cover it.
1. I assume you the reader will have some linux knowledge and are capable of using the CLI and editing various system files with root permission.
2. I assume you know how to install various packages either from source i.e. ./configure && make && make install or by using various package managers for available with your distro e.g. YaST for SUSE, apt for Debian, YUM for Fedora, URPMI for Mandriva, Portage for Gentoo etc..
3. I assume your client computers are running either some version of Linux or Windows 2000 or above. Samba will work with Macs and versions of Windows prior to 2K. However since I don't have a Mac or a "Copy" of 98 lying around, I can't test out to see if this howto works.
4. I assume your network works, i.e. you can ping each and every single computer at any given time. For more information on how to ping, read the ping man page i.e. man ping
5. I assume your server will have a static ip, trust me, you will always want your server to have the same IP so that you don't always have to change settings when its dhcp lease expires etc..
6. I assume you are setting this up for a home network, and hence won't require Samba to act as a PDC. (Primary Domain COntroller)
7. I assume the printer will be directly connected to the server by a usb cable or parallel port cable.
I suggest you read through this guide and understand the steps before attempting to perform it on your systems.
Note: anything placed inside // is a comment and not a command
Ch 1. Setting up Samba
Using your distro's package manager install the latest version of samba available for it. As of 30/01/2006 the latest version of samba is 3.0.21. You can get binary i.e. precompiled packages of Samba from here for varios linux distros.
Install samba on your system before continuing.
Once samba has installed successfully, it is now time to edit the main samba configuration file. So in the terminal, become root and using your favourite editor, edit the /etc/samba/smb.conf file.
You may already see some things in this file, but for the purpose of this tutorial I am going to start from a clean smb.conf file. If you feel the need, backup your present smb.conf file with:
# nano -w /etc/samba/smb.conf
Now the smb.conf file is divided into 2 sections, the global section and the shares section. Firstly we will create the global section. As you may have guessed, the global section contains settings which will define the server.
# cp /etc/samba/smb.conf /etc/samba/smb.conf.old
Ch 1.1 Creating the global section
These fields will be explained below:
netbios name = The_Server
server string = Samba Server
workgroup = My_Windows_Work_group
security = user
encrypt passwords = yes
smb passwd file = /var/lib/samba/private/smbpasswd
log file = /var/log/samba/%m.log
socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192
wins support = yes
hostname lookups = yes
hosts equiv = /etc/hosts
hosts allow = 192.168.0.0/255.255.255.0 localhost
hosts deny = All
interfaces = lo eth0
bind interfaces only = yes
guest ok = yes
browse list = yes
printcap name = cups
printing = cups
load printers = yes
netbios name: This field should be filled in with the name of your server, this is what your windows computer will refer to the server as.
server string: This field is not really required, but it is handy incase you don't remember what you called your computer e.g. like me :P
workgroup: This field tells the server which Workgroup it belongs to. This field is absolutely essential.
security: This field refers to the level of security which should be present. There are two levels of security which I feel is within the scope of this howto to explain:
1. Share level security: Anyone can access any share without entering a username and password, i.e. no security.
2. User level security. If someone wants to access a share on the server, they need to enter a valid username and password. A valid username is any user who has an account on your server. To add a user, use the useradd command. A valid user needs a valid password, but to be able to use the share, they need a valid samba password. To add a samba password for a user, just execute this command:
Personally I recommend you use user level security. However, if you feel the need to use share level security, by all means do so, but for making sure everything works, set it to user level security. This is because the command which tests whether the Smaba server works requires user level security to work. Once the server is up and running, you can set it back to share level security.
# smbpasswd -a user_name
encrypt passwords: Sounds pretty obvious doesn't it, I don't want other people knowing my passwords easily, so they should be encrypted.
smb passwd file: The file where the samba passwords should be stored. You can use a whereis or a find to find the proper location of your smbpasswd file.
log file: The file where the server should create the logs for each machine the %m you see there will actually be replaced with the name of the machine.
socket options: These are supposed to improve the sending and recieving of data.
wins support: One of my W2K box refuses to see the Samba server without this option enabled. This option just causes the Samba server to act as a WINS server. Because this option is enabled, you should set the WINS server option in your Windows clients to the IP address of the Samba server.
hostname lookups: This field just asks whether the server should perform lookups based on the hostname of the client computers. If you set this field, you beed a hosts equiv field to tell the server the equivalent ip's of the other computers.
hosts equiv: This field just tells the server the loacation of the file which translates a IP address to a hostname.
hosts allow / hosts deny: These fields set which hosts can access the server based on their IP address or hostnames. In the example hosts allow field, I have told it to allow any computer with an IP address in the range 192.168.0.1 to 192.168.0.255 on the subnet 255.255.255.0 to have access to the server, localhost should also be included so that we can test to see wether the server works.
The hosts deny entry is set to All as I don't want anyone else accessing the shares.
interfaces: This field is only required if you have multiple network cards/connections. (Yes the Internet is a type of connection). This field should be set with the names of the interface/s that the Samba server should listen to for requests. Valid interface names on your system can be found by using the /sbin/ifconfig command.
bind interfaces only: This field tells the server only to listen to the interfaces listed in the "interfaces" field.
guest ok: allow guests to see the server, and some limited browsing. Usually should be set to no.
printcap name / printing: The type of printing system we are going to use.
load printers: Well we do want the system to load the printers automatically so that clients can use it, don't we?
Now the rest will come in the 2nd post due to a 10,000 character limit for posts on this forum.