We are going to learn how to configure SAMBA Server in RHEL7 / Cent OS 7. Its used to share file and printer sharing over the network.
Now a days its used as Domain controller like Windows Active Directory.
Will integrate SAMBA Server with Windows Domain as a Primary domain controller or as a domain member.
Operating System: RHEL7
Host Name: server
IP Address: 192.168.43.226 / 255.255.255.0
137/udp
138/tcp
138/udp
139/tcp
139/udp
445/tcp
445/udp
- smbd: This is for file and printer sharing services
- nmbd: This is for NetBIOS to IP Address service and Mapping NetBIOS Compluter Name to the TCP/IP IP Addresses.
[[email protected] ~]# yum install -y samba
[[email protected] ~]# mkdir /sharedir
[[email protected] ~]# groupadd samba
change the group and permission for the directory which we are going to share using samba
[[email protected] ~]# chgrp -R samba /sharedir [[email protected] ~]# chmod -R 777 /sharedir
check for the existing group and permission details for the directory.
[[email protected] ~]# ll / | grep sharedir drwxrwxrwx. 2 root samba 6 Nov 11 08:59 sharedir
Now again check for the group and permission for the directory and it’s changed.
Create a new user called test and add it to our newly created group which is called samba. Then set the samba password for the user.
[[email protected] ~]# useradd smbuser [[email protected] ~]# usermod -G samba smbuser [[email protected] ~]# smbpasswd -a smbuser New SMB password: Retype new SMB password: Added user smbuser.
We are going to edit this configuration file. Before that its advisable to take backup of configuration file.
#cp -p /etc/samba/smb.conf /etc/samba/smb.conf.bkp
now we will edit the smb.conf file
[[email protected] ~]# vi /etc/samba/smb.conf
[sharedir] comment = shared-directory path = /sharedir valid users = smbuser, @samba writeable = yes browseable = yes read only = no inherit acls = Yes
In the same smb.conf file we should add our interface name and IP Address to allow the network in samba server.
And one more entry is very important that we need to mention our windows machines workgroup name. First we will use default one. If the windows machines are falling under different workgroup name. Then we have to change the workgroup name in this configuration file.
WORKGROUP = MYGROUP
We can add the services in /etc/services file.
[[email protected] ~]# vi /etc/services netbios-ns 137/tcp # netbios name service netbios-ns 137/udp # netbios name service netbios-dgm 138/tcp # netbios datagram service netbios-dgm 138/udp # netbios datagram service netbios-ssn 139/tcp # netbios session service netbios-ssn 139/udp # netbios session service
Now start the samba service and enable the service permanently on this run level.
[[email protected] ~]# systemctl start smb.service [[email protected] ~]# systemctl enable smb.service Created symlink from /etc/systemd/system/multi-user.target.wants/smb.service to /usr/lib/systemd/system/smb.service.
Same like that start and enable nmb service.
#systemctl start nmb.service
#systemctl enable nmb.service
Add the firewall rule to allow the samba service via firewall.
In RHEL 7 firewall has been shipped from iptables to firewalld.
[[email protected] ~]# systemctl start firewalld [[email protected] ~]# firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="192.168.56.0/24" service name="samba" log prefix="samba" level="info" limit value="1/m" accept' success [[email protected] ~]# systemctl enable firewalld Created symlink from /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service to /usr/lib/systemd/system/firewalld.service. Created symlink from /etc/systemd/system/basic.target.wants/firewalld.service to /usr/lib/systemd/system/firewalld.service.
Then reload the firewall configuration using below command
[[email protected] ~]# firewall-cmd --reload success
Now all the configuration has been completed and will check in windows machine whether the samba is working well or not.
Connecting SAMBA server from linux client machine.
samba client should be installed in linux client machine.
Package: samba-client-4.4.4-9.el7.x86_64
#yum install samba-client*
[[email protected] ~]# smbclient -L 192.168.43.126 -U test
-L : This option will list the shared directories
192.168.43.226 : IP Address of samba server
-U : Option to mention the user name next to this which has access to this shared directory.
Output should be like below
Accessing via samba console:
#smbclient //192.168.43.226/sharedir -U test
above command will help you to show the content of shared directory and to do operations over their.
We successfully configure SAMBA server. Thanks for the support.