How to install and configure samba server in CentOS 6.3

How to install and configure samba server in CentOS 6.3

Introduction: Samba is a free software re-implementation of the SMB/CIFS networking protocol, originally developed by Andrew Tridgell. As of version 3, Samba provides file and print services for various Microsoft Windows clients and can integrate with a Windows Server domain, either as a Primary Domain Controller (PDC) or as a domain member. It can also be part of an Active Directory domain.

Samba runs on most Unix and Unix-like systems, such as Linux, Solaris, AIX and the BSD variants, including Apple’s Mac OS X Server (which was added to the Mac OS X client in version 10.2). Samba is standard on nearly all distributions of Linux and is commonly included as a basic system service on other Unix-based operating systems as well. Samba is released under the GNU General Public License. The name Samba comes from SMB (Server Message Block), the name of the standard protocol used by the Microsoft Windows network file system.
Reference from : http://en.wikipedia.org/wiki/Samba_%28software%29

Scenario: We will shared directory where permitted user/group can access the shared directory and read write the files or dir.

Practical Applied on:

Operating System: CentOS release 6.3 (Final)
Packages: On Samba Version 3.5
samba-winbind-clients-3.5.10-125.el6.i686
samba-3.5.10-125.el6.i686
samba-common-3.5.10-125.el6.i686
Kernel information: Linux 2.6.32-279.el6.i686 #1 SMP / i686 i686 i386 GNU/Linux

Samba Server uses the following port no. :

137/tcp
137/udp
138/tcp
138/udp
139/udp
139/udp
445/tcp
445/udp

Daemon name : smb and nmb
Samba services are implemented as two daemons:
smbd, which provides the file and printer sharing services, and
nmbd, which provides the NetBIOS-to-IP-address name service. NetBIOS over TCP/IP requires some method for mapping NetBIOS computer names to the IP addresses of a TCP/IP network.

How to install and configure samba server:

Step 1: Install through yum command. cups-libs is for printer.

Step 2: create a directory which you would like to share

Step 3: Add a new group or you can use existing group to provide access on shared directory,Here I am adding new group called staff.

Step 4: Change the group and permission of sharing folder

Step 5: Change the selinux security context on sharing directory and set the selinux boolean value for samba .
You can skip this step if selinux has permissive or disabled status. (use sestatus command to check selinux status)

Step 6: create user and add them in group called staff. And set the samba password for this user.

Step 7: Take backup of /etc/samba/smb.conf file then edit the smb.conf file. And add the given parameter in last line of /etc/samba/smb.conf file

Step 8: Edit these lines in /etc/samba/smb.conf . To allow network to reach samba server.
Change the value of 192.168.56.0/24 with your subnet. And change the ethernet value which is in used by your system and which you want to allow for traffic.
In second line ,192.168.56. is for subnet .Same rule applied to 127. which is for loopback.

Note: Mainly for windows users,if your all PC in your network are using different WORKGROUP name edit the given below line in smb.conf with your workgroup name. Windows system bydefault uses the WORKGROUP as WORKGROUP. Try first without changing the WORKGROUP name,if required do the change.

Step 9 : Add services in /etc/services files

Step 10: Add iptables rule in samba server for port no. 137,138.139 and 445. Edit /etc/sysconfig/iptables file
Note: If in your network iptables service is stopped or there is no rule set up.Kindly skip this step.
Change the 192.168.56.0/24 value with you network subnet.

Step 11: Now start the smb and nmb services.

To smb and nmb services should be started at the time of boot or reboot.Use chkconfig command

Step 12: Now we will test samba from linux and windows machine

Windows User:

Linux Users: smbclient must be installed in system .

To check the list of shared objects in samba server.Use the command
smbclient -L \\ipaddress-samba-server -U username (press enter, and give samba password of the user)

To access through smb console : Use the command

After getting console you can use get and put command to get the data and put the data in shared dir.
Like the given below eg,

To mount the samba shared directory in machine your system must support cifs file system.

In ubuntu:
From Dash home write the command smb://ipaddr-samba-server/shared-directory

Or take reference from https://help.ubuntu.com/community/Samba/SambaClientGuide

About sharad chhetri

Sharad Chhetri is a experienced Linux System Engineer. He loves Linux,Open Source Technology,Wordpress and comedy movies. If you like any of our posts or blog, sincerely recommend you to donate to any charity/open source organisation/needful . We love to hear about your donation at [email protected] . We have already received donations feedback from awesome people. Will you be the next !!

Comments

  1. CReed says

    Very good article for anyone with minimal linux experience to get a samba server up with minimal fuss. Bookmarked. Thanks for posting it.

  2. Francis Trujillo says

    Don’t forget to have your service at reboot. By the way, GREAT job! :-)

    $ sudo chkconfig smb on
    $ sudo chkconfig nmb on

    $ sudo chkconfig | egrep “smb|nmb”
    nmb 0:off 1:off 2:on 3:on 4:on 5:on 6:off
    smb 0:off 1:off 2:on 3:on 4:on 5:on 6:off

  3. gigirock says

    mmmh, lost some minutes to understand that in iptables you must accpet also UDP for each port….don’t forget it !

Leave a Reply