noscript

Samba is an open-source tool through which files can be shared between Linux and Windows systems. It’s an SMB (Server Message Block)/CIFS (Common Internet File System) protocol with open-source implementation.

It is a client-server communication protocol that uses (SMB) Server Message Block Protocol. Samba is used for sharing folders, and printers over the network.

Samba was developed for sharing of files and folders between Linux and Windows/Linux. With the help of Samba, we can set up file sharing between Linux to Windows systems and Linux to Linux systems.

  [Will use samba server as ‘samba server’ and two client machines ‘win_client’ and ‘linux_client’ for smb configuration]

Features of Samba

  • Microsoft Windows (CIFS) protocol for networking.
  • Samba is an open-source tool.
  • Samba uses TCP/IP protocol.
  • Samba allows interoperability between Windows and Linux.
  • Samba provides file and print-sharing services between Windows and Linux systems.

Samba Configuration Files

/etc/samba/smb.conf
 

 

Network configuration

Need to configure network settings. Will assign a Name and ip address.

Samba Server: –   samba_server.demo.local  with     IP- 172.16.20.1/24

Samba Clients: –   win_client.demo.local with            IP- 172.16.20.101/24

                              Linux_client.demo.local with         IP-172.16.20.102/24

 

 

/etc/hosts file       à Edit on all server and client machines   [ Linux machines]

172.16.20.1        samba_server.demo.local   samba_server

172.16.20.101    win_client.demo.local          win_client

172.16.20.102   linux_client.demo.local        linux_client

 

c:\Windows\System32\Drivers\etc\hosts file   — > Edit on Windows machine

172.16.20.1        samba_server.demo.local   samba_server

172.16.20.101    win_client.demo.local          win_client

172.16.20.102   linux_client.demo.local        linux_client

 Samba Server Configuration

#dnf install samba

#dnf install samba-client

#dnf install samba-common

 

Will create a share as /sales and will give access to owner & groupowner sales as rw.

# groupadd sales

# useradd salesuser

# usermod -G sales salesuser

# mkdir /sales

# chmod 770 /sales

# chgrp sales /sales

 

 

Configure SELinux

# chcon  -R  -t samba_share_t   /sales

# semanage fcontext –a  -t samba_share_t  “/sales(/.*)?”

# restorecon /sales

# setsebool  -P  samba_enable_home_dirs    on

 

Configure Firewall

 

# firewall-cmd –permanent –add-service=samba

# firewall-cmd –reload

 

Add Workgroup/Domain in /etc/samba/smb.conf

Name of Workgroup should match with windows machine

[global]

workgroup = WORKGROUP

 

Create entry for shared directory in /etc/samba/smb.conf file

[sales]

comment=Shared director for the sales team

browsable=yes

path=/sales

public=no

valid users=@sales, salesuser

writeable=yes

create mask=0760

 

Export the shared data

#exportfs –r

 

Test samba configuration

#testparm

 

 

Add Samba user

# smbpasswd -a salesuser

 

Finally, restart Samba, and check its availability to network clients:

 # systemctl start smb

# systemctl enable smb

# smbclient -L localhost –U sales user

Windows as Samba client:-   Check how to access samba share on Windows machine

  • Open run dialog box

\\172.16.20.1

  • Use authentication for sales user

 

Linux as Samba client: – Check how to access Samba share on Linux machine

  • # smbclient  -L   \\172.16.20.1  -U  sales user
 What we can do with Samba:
  • Share directories and printers to UNIX, Linux, and Windows clients.
  • Network browsing (with or without NetBIOS)
  • Authenticate Windows domain logins.
  • Act as a Primary Domain Controller (PDC).

For Information & classes Call:  7370000325
Registration Link: Click Here!

 

Author:-

Amol Shende
AWS Trainer

IT Education Centre Placement & Training Institute

© Copyright 2023 | IT Education Centre.