← Back to blogs

Networking Services : NFS & Samba

February 26, 2021

NFS is a service used to share files between UNIX servers and UNIX clients.

Samba is a service used to share files between UNIX and MS Windows Computers

Blog Image

Prerequisite for Networking: Configure hostname & tcp/ipv4

Steps to Configure and Setup any Service in Linux

  1. Install packages required for that service
  2. Start the service
  3. Do the configurations
  4. Restart the service
  5. Start the service on boot
  6. Allow the service in the firewall

NFS

Exercise:

Configure a rhel6.5 server with server name srv1.test.com and IP Address 10.0.0.3/8 . Configure a rhel6.5 Desktop with name pc1.test.com and IP Address 10.0.0.101/8 . On the server create a folder called Development and share it using NFS to all client PCs.

Note: NFS package is installed by default

Steps on Server

$ vi /etc/sysconfig/network
	HOSTNAME=srv1.test.com   # reboot after this
$ vi /etc/sysconfig/network-scripts/ifcfg-eth0
	ONBOOT=yes
	IPADDR=10.0.0.3
	NETMASK=255.0.0.0
	BOOTPROTO=dhcp         # remove this line
$ service network restart
$ ifconfig -a
$ service nfs status
$ service nfs start
$ mkdir /Development
$ vi /etc/exports
	/Developemnt *(rw,sync,no_root_squash)
$ exportfs -rv                 # share /Development folder
$ service nfs restart          # restart the service
$ chkconfig nfs on             # enable start on bootup
$ service iptables stop ; setenforce 0     # stop firewall temporarily

Steps on Client

$ vi /etc/sysconfig/network
	HOSTNAME=pc1.test.com
$ vi /etc/sysconfig/network-scripts/ifcfg-eth0
	ONBOOT=yes
	IPADDR=10.0.0.101
	NETMASK=255.0.0.0
	BOOTPROTO=dhcp         # remove this line
$ service network restart
$ ifconfig -a
$ ping 10.0.0.3
$ mkdir /Development
$ vi /etc/fstab
	10.0.0.3:/Development   /Development   nfs   defaults  0 0
$ mount -a
$ df -h | grep Dev
$ cd /Development
$ touch file1
$ mkdir sample1
# Check server to see if files are created or not

To Permanently Disable Firewall

$ chkconfig iptables off
$ vi /etc/selinux/config
	SELINUX=permissive

Samba

Steps to Install and Configure Samba

  1. Ensure that server and windows client can ping each other

  2. On the server, mount the DVD to packages folder

    $ mkdir /packages
    $ mount -t iso9660 -o ro /dev/cdrom /packages
    $ df -h
    
  3. Install Samba using RPM not YUM

    $ cd /packages/Packages
    $ rpm -ivh samba-3-....
    
  4. Start the samba service

    service smb start

  5. Share a folder called /Devops for a user called newuser

    $ mkdir /Devops
    $ useradd newuser -p 123
    $ chown newuser /Devops
    $ chmod 700 /Devops
    
  6. Do the samba configuration:

    $ smbpasswd newuser -a     # create same user in samba database
    $ vi /etc/samba/smb.conf
    	[Devops]
    	path = /Devops
    	valid users = newuser
    	writable = yes
    $ testparm
    $ service smb restart
    
  7. Steps on the client:

    1. Configure IP Address on the Windows PC
    2. Make sure you can ping the server
    3. Run \\10.0.0.3
      • Two folders are available. One is the /Desktop folder
      • The other is the home directory of user newuser