The /etc/smb.conf file is the main configuration file for the Samba server, in which you can specify which directory you want to access from Windows machines, which IP addresses are authorized,
and so on. The first few lines of the file under the line contain global configuration directives, which are common to all shares, unless they are over-ridden on a
per-share basis, followed by share sections. A lot of options exist, and it's important to read the documentation that comes with Samba for more information on each of the different settings and parameters.
[global]
The following configuration example is a minimal working configuration file for Samba with encrypted password support. Also, it's important to note that we comment in this Samba configuration only parameters that relate to security and optimization, and left other possibilities for you to explore.
In our example we have created just one directory, and have allowed only class C machine IP address ranges to connect on the
Samba server. Also, we don't use print-sharing capability between Samba and Windows on this server.
Edit the [tmp]smb.conf file, vi /etc/smb.conf and add/change the following parameters:
[global]
workgroup = OPENNA
server string = R&D of Open Network Architecture Samba Server
encrypt passwords = True
security = user
smb passwd file = /etc/smbpasswd
log file = /var/log/samba/log.%m
socket options = IPTOS_LOWDELAY TCP_NODELAY
domain master = Yes
local master = Yes
preferred master = Yes
os level = 65
dns proxy = No
name resolve order = lmhosts host bcast
bind interfaces only = True
interfaces = eth0 192.168.1.1
hosts deny = ALL
hosts allow = 192.168.1.4 127.0.0.1
debug level = 1
create mask = 0644
directory mask = 0755
level2 oplocks = True
read raw = no
write cache size = 262144
[homes]
comment = Home Directories
browseable = no
read only = no
invalid users = root bin daemon nobody named sys tty disk mem kmem users
[tmp]
comment = Temporary File Space
path = /tmp
read only = No
valid users = admin
invalid users = root bin daemon nobody named sys tty disk mem kmem users
This tells the smb.conf file to set itself up for this particular configuration setup with:
.
[global]
workgroup = OPENNAThe option
workgroupspecifies the workgroup your server will appear to be in when queried by clients. It's important to have the same workgroup name on both clients and servers.server string = R&D of Open Network Architecture Samba ServerThe option
server stringspecifies the string that you wish to show to your users in the printer comment box in print manager, or to the IPC connection in thenet viewcommand under Windows machines.encrypt passwords = TrueThe option
encrypt passwordsif set toTrueinstructs Samba to use encrypted passwords instead of plain text password when negotiating with the client. Sniffer program will not be able to detect your password when it is encrypted. This option always must be set toTruefor security reasons.security = userThe option
security, if set touser, specifies that a client must firstlog-onwith a valid username and password, or the connection will be refused. This means that a valid username and password for the client must exit in your/etc/passwdfile on the Linux server and in the/etc/smbpasswdfile of the Samba server, or the connection from the client will fail. See Securing samba in this chapter for more information about thesmbpasswdfile.smb passwd file = /etc/smbpasswdThe option
smb passwd filespecifies the path to the encryptedsmbpasswdfile. Thesmbpasswdfile is a copy of the/etc/passwdfile of the Linux system containing valid usernames and passwords of clients allowed to connect to the Samba server. The Samba software reads this file,smbpasswdwhen a connection is requested.log file = /var/log/samba/log.%mThe option
log filespecifies the locations and names of Samba log files. With the name extension%m, it allows you to have separate log files for each user or machine that logs on your Samba server i.e.log.machine1.socket options = IPTOS_LOWDELAY TCP_NODELAYThe option
socket optionsspecifies parameters that you can include in your Samba configuration to tune and improve your samba server for optimal performance. By default we chose to tune the connection for a local network, and improve the performance of the Samba server for transferring files.domain master = YesThe option
domain masterspecifies to setnmbd, the Samba server daemon, as a domain master browser for its given workgroup. This option usually must be set toYesonly on one Samba server for all other Samba servers on the same network and workgroup.local master = YesThe option
local masterallowsnmbd, the Samba server daemon, to try to become a local master browser on a subnet. Like the above, usually this option must be set toYesonly on one Samba server that acts as a local master on a subnet for all the other Samba servers on your network.preferred master = YesThe option
preferred masterspecifies and controls ifnmbdthe Samba server daemon, is a preferred master browser for its workgroup. Once again, this must usually be set toYeson one server for all the others on your network.os level = 65The option
os levelspecifies by its value whethernmbd, the Samba server daemon, has a chance of becoming a local master browser for the Workgroup in the local broadcast area. The number 65 will win against any NT Server. If you have an NT Server on your network, and want to set your Linux Samba server to be a local master browser for the Workgroup in the local broadcast area then you must set theos leveloption to 65. Also, this option must be set only on one Linux Samba server, and must be disabled on all other Linux Samba servers you may have on your network.dns proxy = NoThe option
dns proxyif set toYesspecifies thatnmbd, the Samba server daemon, when acting as a WINS server and finding that a Net BIOS name has not been registered, should treat the Net BIOS name word-for-word as a DNS name and do a lookup with the DNS server for that name on behalf of the name-querying client. Since we have not configured the Samba server to act as a WINS server, we don't need to set this option toYes. Also, setting this option toYeswill degrade your Samba performance.name resolve order = lmhosts host bcastThe option
name resolve orderspecifies what naming services to use in order to resolve host names to IP addresses, and in what order. The parameters we chose cause the locallmhostsfile of samba to be examined first, followed by the rest.bind interfaces only = TrueThe option
bind interfaces onlyif set toTrue, allows you to limit what interfaces will servesmbrequests. This is a security feature. The configuration optioninterfaces = eth0 192.168.1.1below completes this option.interfaces = eth0 192.168.1.1The option
interfacesallows you to override the default network interface list that Samba will use for browsing, name registration and other NBT traffic. By default, Samba will query the kernel for the list of all active interfaces and use any interface, except127.0.0.1, that is broadcast capable. With this option, Samba will only listen on interfaceeth0on the IP address192.168.1.1. This is a security feature, and completes the above configuration optionbind interfaces only = True.hosts deny = ALLThe option
hosts denyspecifies the list of hosts that are not permitted access to Samba services unless the specific services have their own lists to override this one. For simplicity, we deny access to all hosts by default, and allow specific hosts in thehosts allow =option below.hosts allow = 192.168.1.4 127.0.0.1The option
hosts allowspecifies which hosts are permitted to access a Samba service. By default, we allow hosts from IP class C192.168.1.4and our localhost127.0.0.1to access the Samba server. Note that the localhost must always be set or you will receive some error messages.debug level = 1The option
debug levelallows the logging level to be specified in thesmb.conffile. If you set the debug level higher than 2 then you may suffer a large drop in performance. This is because the server flushes the log file after each operation, which can be very expensive.create mask = 0644The option
create maskspecifies and sets the necessary permissions according to the mapping from DOS modes to UNIX permissions. With this option set to0644, all file copying or creating from a Windows system to the Unix system will have a permission of0644by default.directory mask = 0755The option
directory maskspecifies and set the octal modes, which are used when converting DOS modes to UNIX modes when creating UNIX directories. With this option set to0755, all directory copying or creating from a Windows system to the Unix system will have a permission of0755by default.level2 oplocks = TrueThe option
level2 oplocks, if set toTrue, will increase the performance for many accesses of files that are not commonly written, such as .EXE application files.read raw = noThe option
read rawcontrols whether or not the server will support the raw read SMB requests when transferring data to clients. Note that memory mapping is not used by theread rawoperation. Thus, you may find memory mapping is more effective if you disableread rawusingread raw = no, like we do.write cache size = 262144The option
write cache sizeallows Samba to improve performance on systems where the disk subsystem is a bottleneck. The value of this option is specified in bytes, and a size of 262,144 represent a 256k cache size per file.
.
[tmp]
comment = Temporary File SpaceThe option
commentallows you to specify a comment that will appear next to a share when a client does queries to the server.path = /tmpThe option
pathspecifies a directory to which the user of the service is to be given access. In our example this is thetmpdirectory of the Linux server.read only = NoThe option
read onlyspecifies if users should be allowed to only read files or not. In our example, since this is a configuration for thetmpdirectory of the Linux server, users can do more than just read files.valid users = adminThe option
valid usersspecifies a list of users that should be allowed to login to this service. In our example only the useradminis allowed to access the service.invalid users = root bin daemon nobody named sys tty disk mem kmem usersThe option
invalid usersspecifies a list of users that should not be allowed to login to this service. This is really aparanoidcheck to absolutely ensure an improper setting does not breach your security. It is recommended that you include all default users that run daemons on the server.