How to Configure Virtual Samba Server in CentOS
To Configure Virtual Samba Server in CentOS
Virtual samba server is similar to samba server that runs on two or more instances in a single hardware. It allows the users to configure multiple virtual server’ s for samba. Here multiple dedicated server hardware is not required to set two or more samba servers. This article explains the configuration of Virtual Samba Server in CentOS.
Configuration of Virtual Samba Server
Create virtual instances of samba to configure multiple samba server in a single hardware. Utilize the following command to install samba on server.
[root@server ~]# yum install samba -y
Loaded plugins: fastestmirror, langpacks
base | 3.6 kB 00:00:00
extras | 3.4 kB 00:00:00
updates | 3.4 kB 00:00:00
(1/4): extras/7/x86_64/primary_db | 166 kB 00:00:02
(2/4): base/7/x86_64/group_gz | 155 kB 00:00:03
(3/4): base/7/x86_64/primary_db | 5.3 MB 00:00:35
(4/4): updates/7/x86_64/primary_db | 9.1 MB 00:00:59
Determining fastest mirrors
* base: mirror.fibergrid.in
* extras: mirror.fibergrid.in
* updates: mirror.fibergrid.in
.
.
.
Running transaction
Installing : samba-4.2.10-7.el7_2.x86_64 1/1
Verifying : samba-4.2.10-7.el7_2.x86_64 1/1
Installed:
samba.x86_64 0:4.2.10-7.el7_2
Complete!
Here we setup two samba servers for two different teams named as Redhat and Ubuntu.
Create two different directories with ' mkdir' command.
[root@server ~]# mkdir /redhat
[root@server ~]# mkdir /ubuntu
Then create two users for the samba shares as shown below,
[root@server ~]# useradd redhat
[root@server ~]# useradd ubuntu
Now its time to set the ownership for those directories.
[root@server ~]# chown -R redhat /redhat/
[root@server ~]# chown -R ubuntu /ubuntu/
Once the above process is completed, set the selinux context.
[root@server ~]# chcon -Rt samba_share_t /redhat
[root@server ~]# chcon -Rt samba_share_t /ubuntu/
Both directories are ready for sharing. Let’ s create the virtual samba share by editing samba’ s main configuration and add the below lines as follows,
Add the below lines under the [global] section of that configuration.
[root@server ~]# vim /etc/samba/smb.conf
Entry:
Netbios aliases = redhat Ubuntu
Include = /etc/samba/smb.conf.%L
It includes two configuration file for samba (smb.conf.redhat and smb.conf.ubuntu).
Now create those two configuration file on the samba configuration.
[root@server ~]# vim /etc/samba/smb.conf.redhat Entry: [global] workgroup = redhat hosts allow = 192.168.5. [redhat] path = /redhat write list = redhat [root@server ~]# vim /etc/samba/smb.conf.ubuntu [global] workgroup = ubuntu hosts allow = 192.168.5. [ubuntu] path = /ubuntu write list = Ubuntu
Setup the user credentials as shown below,
[root@server ~]# smbpasswd -a redhat New SMB password: Retype new SMB password: Added user redhat. [root@server ~]# smbpasswd -a ubuntu New SMB password: Retype new SMB password: Added user ubuntu.
Now its time to enable the added credentials with the following command.
[root@server ~]# smbpasswd -e redhat
Enabled user redhat.
[root@server ~]# smbpasswd -e ubuntu
Enabled user ubuntu.
Allow the port for samba service on the firewall
[root@server ~]# firewall-cmd --permanent --add-service=samba success [root@server ~]# firewall-cmd --reload Success
Utilize the following command to start and enable the services for samba.
[root@server ~]# systemctl start smb nmb [root@server ~]# systemctl enable smb nmb Created symlink from /etc/systemd/system/multi-user.target.wants/smb.service to /usr/lib/systemd/system/smb.service. Created symlink from /etc/systemd/system/multi-user.target.wants/nmb.service to /usr/lib/systemd/system/nmb.service.
Once the above process is completed, use the following command to verify this configuration from the client side.
[root@client ~]# yum install cifs-utils samba-client -y
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: centos.excellmedia.net
* extras: centos.excellmedia.net
* updates: centos.excellmedia.net
Resolving Dependencies
--> Running transaction check
---> Package cifs-utils.x86_64 0:6.2-7.el7 will be installed
---> Package samba-client.x86_64 0:4.2.10-7.el7_2 will be installed
--> Finished Dependency Resolution
.
.
.
running transaction
Installing : samba-client-4.2.10-7.el7_2.x86_64 1/2
Installing : cifs-utils-6.2-7.el7.x86_64 2/2
Verifying : cifs-utils-6.2-7.el7.x86_64 1/2
Verifying : samba-client-4.2.10-7.el7_2.x86_64 2/2
Installed:
cifs-utils.x86_64 0:6.2-7.el7 samba-client.x86_64 0:4.2.10-7.el7_2
Complete!
Finally, run the ' smbclient' command to view the configured samba server and shares from the client machine.
[root@client ~]# smbclient -L //192.168.5.157
Enter root' s password:
Domain=[MYGROUP] OS=[Windows 6.1] Server=[Samba 4.2.10]
Sharename Type Comment
--------- ---- -------
IPC$ IPC IPC Service (Samba Server Version 4.2.10)
root Disk Home Directories
Microsoft_XPS_Document_Writer:1 Printer Microsoft XPS Document Writer
Fax:2 Printer Fax
Send_To_OneNote_2010:1 Printer Send To OneNote 2010
Fax:3 Printer Fax
Microsoft_XPS_Document_Writer:2 Printer Microsoft XPS Document Writer
Domain=[MYGROUP] OS=[Windows 6.1] Server=[Samba 4.2.10]
Server Comment
--------- -------
REDHAT Samba Server Version 4.2.10
SERVER Samba Server Version 4.2.10
UBUNTU Samba Server Version 4.2.10
Workgroup Master
--------- -------
MYGROUP
Comments ( 0 )
No comments available