Comments on CentOS 6.4 Samba Standalone Server With tdbsam Backend

This tutorial explains the installation of a Samba fileserver on CentOS 6.4 and how to configure it to share files over the SMB protocol as well as how to add users. Samba is configured as a standalone server, not as a domain controller. In the resulting setup, every user has his own home directory accessible via the SMB protocol and all users have a shared directory with read-/write access.

3 Comment(s)

Add comment

Please register in our forum first to comment.

Comments

By: domaniqs

A very good article. It is lacking one important detail though. I would suggest to add following iptables rules in order to enable samba packets via firewall:

# iptables -A INPUT -s 192.168.0.0/24 -m state --state NEW -m udp -p udp --dport 137 -j ACCEPT
# iptables -A INPUT -s 192.168.0.0/24 -m state --state NEW -m udp -p udp --dport 138 -j ACCEPT
# iptables -A INPUT -s 192.168.0.0/24 -m state --state NEW -m tcp -p tcp --dport 139 -j ACCEPT

Otherwise samba would not be able to communicate with other PCs. Please replace IP addressing to comply with yours.

Also for SELinux, instead of disabling it, you can just follow instructions from original smb.conf file supplied with Centos 6.4, remember to change everything accordingly to your configuration:

#---------------
# SELINUX NOTES:
#
# If you want to use the useradd/groupadd family of binaries please run:
# setsebool -P samba_domain_controller on
#
# If you want to share home directories via samba please run:
# setsebool -P samba_enable_home_dirs on
#
# If you create a new directory you want to share you should mark it as
# "samba_share_t" so that selinux will let you write into it.
# Make sure not to do that on system directories as they may already have
# been marked with othe SELinux labels.
#
# Use ls -ldZ /path to see which context a directory has
#
# Set labels only on directories you created!
# To set a label use the following: chcon -t samba_share_t /path
#
# If you need to share a system created directory you can use one of the
# following (read-only/read-write):
# setsebool -P samba_export_all_ro on
# or
# setsebool -P samba_export_all_rw on
#
# If you want to run scripts (preexec/root prexec/print command/...) please
# put them into the /var/lib/samba/scripts directory so that smbd will be
# allowed to run them.
# Make sure you COPY them and not MOVE them so that the right SELinux context
# is applied, to check all is ok use restorecon -R -v /var/lib/samba/scripts
#
#--------------

By: Anonymous

 I believe this is a correction to the above;

# iptables -I INPUT -s 192.168.0.0/24 -m state --state NEW -m udp -p udp --dport 137 -j ACCEPT
# iptables -I INPUT -s 192.168.0.0/24 -m state --state NEW -m udp -p udp --dport 138 -j ACCEPT
# iptables -I INPUT -s 192.168.0.0/24 -m state --state NEW -m tcp -p tcp --dport 139 -j ACCEPT

My experience (as a complete linux noob) was that using the iptables -A added it to the end of the rules list. In my scenario (CentOS 6.5) this added it after a deny everything rule (which I believe is default behaviour) which meant that it was effectively denied anyway.

By: bakila

In centOs 6.4 if you are using samba you should allow samba protocol through firewall otherwise it won't allow you to connect to the samba server.

system-config-firewall-tui is the command.