Samba provides a stable and highly compatible file and print sharing service that allows a Linux node to act as a client, a member server, or even a Primary Domain Controller (PDC) or a member of an Active Directory (AD) service on Microsoft-based networks. Samba interacts with Microsoft's CIFS built on the Server Message Block (SMB) protocol.
Samba is installed through the samba rpms :
[CODE]
Samba Server
Samba is build on two daemons (smbd, nmbd) and one service (smb) which control the daemons.
smbd
The smbd server daemon provides file sharing and printing services to Windows/Linux clients. It is also responsible for user authentication, resource locking, and data sharing through the SMB protocol. The ports on which the server listens for SMB traffic are TCP ports 139 and 445. It is controlled by the smb service.
nmbd
The nmbd server daemon understands and replies to NetBIOS name service requests such as those produced by SMB/CIFS in Windows systems. It also participates in the browsing protocols that make up the Windows Network Neighbourhood view. The port that the server listens to for NMB traffic is UDP port 137. The nmbd daemon is controlled by the smb service.
This is the main configuration file and is plenty of comments that explain every option. The following is a basic samba server configuration that just exports the printers and /home dir to all Windows/Linux neighbours.
There is a tool that can be used to verify the smb.conf configuration : 'testparam'.
Load smb config files from /etc/samba/smb.conf
.
Samba Client
The following is a list of the samba client utility than can be used. For this section consider the node rhel6 (192.168.1.10) configured as the samba server defined on 'Samba Server' section and the samba client utilities are launched from node01 (192.168.1.101) against samba server on rhel6.
smbclient
It displays the samba shares exported from a Samba server.
Enter john's password:
Domain=[RHEL6-WG] OS=[Unix] Server=[Samba 3.5.4-68.el6]
Sharename Type Comment
--------- ---- -------
IPC$ IPC IPC Service (Samba Server Version 3.5.4-68.el6)
john Disk Home Directories
Domain=[RHEL6-WG] OS=[Unix] Server=[Samba 3.5.4-68.el6]
Server Comment
--------- -------
Workgroup Master
--------- -------
[/CODE]
The samba server account 'john' generated before with the command 'smbpasswd -a john' has been used to list the samba shares. For 'john' user the share 'john' that corresponds to /home/john on rhel6 server is available.
mount
Standard mount command can be used in order to mount remote samba shares on a client using the option '-t cifs'.
Windows client
Of course a Windows node connected to the same LAN as the samba server can access to the samba server as it was a Windows node ...
Samba is installed through the samba rpms :
[CODE]
Code:
# yum install samba*
Samba is build on two daemons (smbd, nmbd) and one service (smb) which control the daemons.
smbd
The smbd server daemon provides file sharing and printing services to Windows/Linux clients. It is also responsible for user authentication, resource locking, and data sharing through the SMB protocol. The ports on which the server listens for SMB traffic are TCP ports 139 and 445. It is controlled by the smb service.
nmbd
The nmbd server daemon understands and replies to NetBIOS name service requests such as those produced by SMB/CIFS in Windows systems. It also participates in the browsing protocols that make up the Windows Network Neighbourhood view. The port that the server listens to for NMB traffic is UDP port 137. The nmbd daemon is controlled by the smb service.
Code:
/etc/samba/smb.conf
Code:
# cat /etc/samba/smb.conf
Code:
[global] # Set the workgroup name (samba domain) to RHEL6-WG. workgroup = RHEL6-WG server string = Samba Server Version %v # Samba name for this server, is the name controlled by nmbd daemon netbios name = rhel6 ; interfaces = lo eth0 192.168.12.2/24 192.168.13.2/24 ; hosts allow = 127. 192.168.12. 192.168.13. # --------------------------- Logging Options ----------------------------- # logs split per machine log file = /var/log/samba/log.%m # max 50KB per log file, then rotate max log size = 50 # ----------------------- Standalone Server Options ------------------------ # Use local system accounts for authentication. To create the samba user 'john' # use the command 'smbpasswd -a john' an set the same password as on the system. # To remove john account on samba server 'smbpasswd -x john' security = user passdb backend = tdbsam # --------------------------- Printing Options ----------------------------- # Use CUPs for printing load printers = yes cups options = raw ; printcap name = /etc/printcap #obtain list of printers automatically on SystemV ; printcap name = lpstat ; printing = cups #============================ Share Definitions ============================== # Export /home and printers [homes] comment = Home Directories browseable = no writable = yes ; valid users = %S ; valid users = MYDOMAIN\%S [printers] comment = All Printers path = /var/spool/samba browseable = no guest ok = no writable = no printable = yes
Code:
# testparm /etc/samba/smb.conf
Code:
rlimit_max: rlimit_max (1024) below minimum Windows limit (16384) Processing section "[homes]" Processing section "[printers]" Loaded services file OK. Server role: ROLE_STANDALONE Press enter to see a dump of your service definitions [global] workgroup = RHEL6-WG server string = Samba Server Version %v log file = /var/log/samba/log.%m max log size = 50 cups options = raw [homes] comment = Home Directories read only = No browseable = No [printers] comment = All Printers path = /var/spool/samba printable = Yes browseable = No Now samba is ready to be started. # /etc/init.d/smb restart # chkconfig smb on
Samba Client
The following is a list of the samba client utility than can be used. For this section consider the node rhel6 (192.168.1.10) configured as the samba server defined on 'Samba Server' section and the samba client utilities are launched from node01 (192.168.1.101) against samba server on rhel6.
smbclient
It displays the samba shares exported from a Samba server.
Code:
[CODE] node01> smbclient -L 192.168.1.10 -U john
Domain=[RHEL6-WG] OS=[Unix] Server=[Samba 3.5.4-68.el6]
Sharename Type Comment
--------- ---- -------
IPC$ IPC IPC Service (Samba Server Version 3.5.4-68.el6)
john Disk Home Directories
Domain=[RHEL6-WG] OS=[Unix] Server=[Samba 3.5.4-68.el6]
Server Comment
--------- -------
Workgroup Master
--------- -------
[/CODE]
The samba server account 'john' generated before with the command 'smbpasswd -a john' has been used to list the samba shares. For 'john' user the share 'john' that corresponds to /home/john on rhel6 server is available.
mount
Standard mount command can be used in order to mount remote samba shares on a client using the option '-t cifs'.
Code:
node01> mount -t cifs //192.168.1.10/john /mnt -o username=john Password: node01> ls -lrt /mnt total 10024 -rw-r--r--. 1 john john 10240000 Feb 22 23:08 file -rw-r--r--. 1 john john 21820 Feb 26 13:47 install.log
Of course a Windows node connected to the same LAN as the samba server can access to the samba server as it was a Windows node ...