Close
Social profiles

Samba_Server


Linux Samba Server. Samba is a strong network service for file and print sharing that works on the majority of operating systems available today.

First you need to configure the IP address of the Samba Server.

Operating system : CentOS
Hostname : storage.tecexpertz.com
IP Address : 192.168.1.2/24


Install Samba package

First you need to remove existing samba server running on the PC, and then need to install the samba server again.

Check Previous Installations :

[root@storage ~]# rpm -qa | grep samba
[root@storage ~]# yum list installed | grep samba

Remove Existing Samba Server:

[root@storage ~]# yum remove samba*

Install Samba Server:

[root@storage  ~]# yum install samba* -y

Configure a fully accessed anonymous share

Create a directory called ‘/samba/TestShare1′ and set full permission

[root@storage  ~]# mkdir -p /samba/TestShare1
[root@storage  ~]# chmod -R 0777 /samba/TestShare1/

Edit and add the following lines in samba config file

[root@storage ~]# vi /etc/samba/smb.conf
unix charset = UTF-8
dos charset = CP932
workgroup = WORKGROUP
hosts allow = 127. 192.168.1.
security = share
[ Add the following lines at the bottom ]
[myshare]
path = /samba/TestShare1
writable = yes
browsable = yes
guest ok = yes
guest only = yes
create mode = 0777
directory mode = 0777

Start samba server

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

Test the Samba server

[root@storage  ~]# testparm

Allow Samba server through firewall

here are ports you need to open for two-way samba communication with Windows and Linux desktop systems.

  • Port 445 (TCP) – NetBIOS was moved to 445 after 2000 and beyond, (CIFS)
  • Port 901 (TCP) – for SWAT service (not related to client communication)
  • Port 137 (TCP) – NETBIOS Name Service
  • Port 138 (TCP) – NETBIOS Datagram Service
  • Port 139 (TCP) – NETBIOS session service
[root@sambaserver ~]# 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 192.168.1.0/24 -m state --state NEW -p udp --dport 137 -j ACCEPT 
-A INPUT -s 192.168.1.0/24 -m state --state NEW -p udp --dport 138 -j ACCEPT 
-A INPUT -s 192.168.1.0/24 -m state --state NEW -p tcp --dport 139 -j ACCEPT 
-A INPUT -s 192.168.1.0/24 -m state --state NEW -p tcp --dport 445 -j ACCEPT 
-A INPUT -s 192.168.1.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@sambaserver ~]# 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@sambaserver ~]# 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. Now you can see the Shared Folders in the Window.

Leave a Reply

Your email address will not be published. Required fields are marked *

Close