In this article we are going to create a multiple virtual samba server on single server. We will create department wise virtual samba server
1) Installing Samba Server
Install the following packages on the server.
~]# yum update && yum install samba samba-common samba-client
Samba provides file/print sharing services to SMB and CIFS clients due to which clients see the server as it is windows server.
After installing above packages on the server. Lets create users on the server.
~]# useradd sagar ~]# useradd mayur
Now create department wise groups on the server. For example for HR department HR group.
~]# groupadd hr ~]# groupadd finance ~]# usermod -a -G hr sagar ~]# usermod -a -G finance mayur ~]# mkdir /data/hr ~]# mkdir /data/finance
2) Configuring Selinux and firewall for samba share
In preparation to configure hr and finance directories as samba share we need to configure selinux context, otherwise it will block from accessing samba share.
~]# setsebool -P samba_export_ro=1 samba_export_all_rw=1 ~]# getsebool -a | grep samba_export ~]# semanage fcontext -at samba_share_t "/finance(/.*)?" ~]# restorecon /data/finance ~]# semanage fcontext -at samba_share_t "/hr(/.*)?" ~]# restorecon /data/hr
Add samba service in firewalld
~]# firewall-cmd --permanent --add-service=samba ~]# firewall-cmd --reload
3) Configuring Samba Share
Go into configuration file of samba i.e. /etc/samba/smb.conf and add the bellow settings for configuring samba server.
========================== Global Settings ============================== workgroup = WORKGROUP server string = Samba Server Version %v netbios aliases = finance hr include = /etc/samba/smb.conf.%L ========================= Share Definitions ============================= [data] comment =virtual samba path = /data browseable = yes writable = yes publice = no valid users = sagar
In the golbal settings section we have added line
include = /etc/samba/smb.conf.%L
Above line will look for netbios aliases which we have specified as finance and hr department.
Lets create to files /etc/samba/smb.conf.hr and /etc/samba/smb.conf.finance with bellow details in it.
vi /etc/samba/smb.conf.hr [global] Workgroup = HR host allow = 192.168. [hr] comment = virtual server for HR Team path = /data/hr browseable = yes writable = yes publice = no valid users = @hr write list = @hr create mask = 0770 force group = hr force create mode = 0770
vi /etc/samba/smb.conf.finance [global] Workgroup = Finance host allow = 192.168. [Finance] comment = virtual server for Finance Team path = /data/finance browseable = yes writable = yes public = no valid users = @finance write list = @finance create mask = 0770 force group = finance force create mode = 0770
Above two files will create two virtual shares on the server.
~]# systemctl start smb nmb ~]# systemctl enable smb nmb ~]# testparm
To check the configuration run bellow command
~]# smbclient -L localhost -U Sagar
4) Accessing from windows client
When you try to access samba share you will get bellow details
Select samba share from workgroup and you done.
As shown in bellow screen user will assume that there will be separate server for there team.
Comments
Post a Comment