Samba Server

Configuring Samba server Step by step.

Operating system : CentOS 6.3
Hostname : server1.example.com
IP Address : 172.19.192.50/24
Samba client:
Operating system : Windows 7 Professional
Hostname : client
IP Address : 172.19.192.51/24
Install Samba package
Check and remove any previously installed samba package
[root@server1 ~]# rpm -qa | grep samba
[root@server1 ~]# yum list installed | grep samba
If it installed, remove it using the below command
[root@server1 ~]# yum remove samba*
Now install samba
[root@server1 ~]# yum install samba* -y
Configure a fully accessed anonymous share
Create a directory called ‘/samba/share1′ and set full permission
[root@server1 ~]# mkdir -p /samba/share1
[root@server1 ~]# chmod -R 0777 /samba/share1/

Edit and add the following lines in samba config file as shown below
[root@server1 ~]# vi /etc/samba/smb.conf
## Line no 58 – Add the following lines below line 58 ##
unix charset = UTF-8
dos charset = CP932

## Line no 75 – Change the to windows default workgroup ##
workgroup = WORKGROUP
## Line no 81 – Uncomment and set the IP Range ##
hosts allow = 127. 172.19.192.
## Line 102 – set no authentication ##
security = share
## Add the following lines at the bottom ##
[myshare]
path = /samba/share1
writable = yes
browsable = yes
guest ok = yes
guest only = yes
create mode = 0777
directory mode = 0777
Start samba server
[root@server1 ~]# vi /etc/samba/smb.conf
[root@server1 ~]# /etc/init.d/smb start

Starting SMB services: [ OK ]
[root@server1 ~]# /etc/init.d/nmb start
Starting NMB services: [ OK ]
[root@server1 ~]# chkconfig smb on
[root@server1 ~]# chkconfig nmb on

Test the Samba server
We can test the Samba server configuration using the command ‘testparm’.
[root@server1 ~]# testparm
Load smb config files from /etc/samba/smb.conf
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
Processing section “[homes]”
Processing section “[printers]”
Processing section “[myshare]”
Loaded services file OK.
Server role: ROLE_STANDALONE
Press enter to see a dump of your service definitions
[global]
dos charset = CP932
server string = Samba Server Version %v
security = SHARE
log file = /var/log/samba/log.%m
max log size = 50
hosts allow = 127., 172.19.192.
cups options = raw

[homes]
comment = Home Directories
read only = No
browseable = No
[printers]
comment = All Printers
path = /var/spool/samba
printable = Yes
browseable = No

[myshare]
path = /samba/share1
read only = No
create mask = 0777
directory mask = 0777
guest only = Yes
guest ok = Yes
Allow Samba server through firewall
[root@server1 ~]# vi /etc/sysconfig/iptables
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -s 172.19.192.0/24 -m state –state NEW -p udp –dport 137 -j ACCEPT
-A INPUT -s 172.19.192.0/24 -m state –state NEW -p udp –dport 138 -j ACCEPT
-A INPUT -s 172.19.192.0/24 -m state –state NEW -p tcp –dport 139 -j ACCEPT
-A INPUT -s 172.19.192.0/24 -m state –state NEW -p tcp –dport 445 -j ACCEPT
-A INPUT -s 172.19.192.0/24 -m state –state NEW -p tcp –dport 901 -j ACCEPT
-A INPUT -m state –state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state –state NEW -m tcp -p tcp –dport 22 -j ACCEPT
-A INPUT -j REJECT –reject-with icmp-host-prohibited
-A FORWARD -j REJECT –reject-with icmp-host-prohibited
COMMIT
Restart iptables to save the changes
[root@server1 ~]# service iptables restart
iptables: Flushing firewall rules: [ OK ]
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Unloading modules: [ OK ]
iptables: Applying firewall rules: [ OK ]
Disable SELINUX
[root@server1 ~]# vi /etc/sysconfig/selinux
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing – SELinux security policy is enforced.
# permissive – SELinux prints warnings instead of enforcing.
# disabled – No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these two values:
# targeted – Targeted processes are protected,
# mls – Multi Level Security protection.
SELINUXTYPE=targeted
Restart the server and goto windows client system
Click Start -> Run. Enter the samba Server IP as shown below.

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s