Thursday, May 19, 2011

NFS Installation & configuration

NFS Installation & configuration in fedora & RHEL-5

Server Side-
set repository ( if you are using RHEL-5)

# yum install nfs*
# yum install nfslock
# yum install portmap*

now restart all services
# /etc/init.d/nfs restart
# /etc/init.d/portmap restart
# /etc/init.d/nfslock restart

# chkconfig nfs on
# chkconfig portmap on

Make directory for share in network.
# mkdir /data
give permission as per your user management.
# chmod -R 777 /data (full permission)
Open /etc/exportfs file & edit this file.

# vim /etc/exportfs
/data *. 192.168.10.0/24(rw,sync)


file save in exit.

ro: The directory is shared read only; the client machine will not be able to write it. This is the default.
rw: The client machine will have read and write access to the directory.
sync: By default, all but the most recent version (version 1.11) of the exportfs command will use async behaviour.

# /etc/init.d/iptables start
open vim /etc/sysconfig/nfs & add following line for set port for nfs in iptables running mode.
MOUNTD_PORT="4002"
STATD_PORT="4003"
LOCKD_TCPPORT="4004"
LOCKD_UDPPORT="4004"

save & exit file.
# iptables -I INPUT -s 192.168.10.0/24 -p tcp --dport 111 -j ACCEPT
# iptables -I INPUT -s 192.168.10.0/24 -p tcp --dport 2049 -j ACCEPT
# iptables -I INPUT -s 192.168.10.0/24 -p tcp --dport 4002 -j ACCEPT
# iptables -I INPUT -s 192.168.10.0/24 -p tcp --dport 4003 -j ACCEPT
# iptables -I INPUT -s 192.168.10.0/24 -p tcp --dport 4004-j ACCEPT
# iptables -I INPUT -s 192.168.10.0/24 -p udp --dport 111 -j ACCEPT
# iptables -I INPUT -s 192.168.10.0/24 -p udp --dport 4002 -j ACCEPT
# iptables -I INPUT -s 192.168.10.0/24 -p udp --dport 4003 -j ACCEPT
# iptables -I INPUT -s 192.168.10.0/24 -p udp --dport 4004 -j ACCEPT
# iptables -I INPUT -s 192.168.10.0/24 -p udp --dport 2049 -j ACCEPT

# /etc/init.d/iptables save
# /etc/init.d/iptables restart
# /etc/init.d/nfs/restart
# showmount -e 192.168.10.10
It will be display share directory.
(note 192.168.100.10 - nfs configuration server ip )

Client Side-:
start portmap or nfs services.
/etc/init.d/nfs/restart
/etc/init.d/portmap restart

Mount nfs share directory temparly
mount -t nfs 192.168.10.10:/data /mnt

if you want to mount permanatly then open file vim /etc/fstab file & add this line.

# vim /etc/fstab

192.168.10.10:/data /mnt nfs defaults 0 0

Then file save & exit

# umount -a
# mount -a
# df -kh
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 73G 5.9G 63G 9% /
tmpfs 248M 124K 248M 1% /dev/shm
gvfs-fuse-daemon 73G 5.9G 63G 9% /root/.gvfs
192.168.10.10:/data
97G 77G 21G 80% /mnt

NIS Configuration

Nis Server Configuration for RHEL-5

Server side-: Install following package.
# yum install Ypserv
# yum install Ypbind
# yum install tools
# chkconfig ypserv on
# chkconfig yppasswdd on
# chkconfig ypxfrd on
# /etc/init.d /portmap restart
# chkconfig portmap on
Open file vim /etc/sysconfig/network
make this entry in file.

NISDOMAIN= ABC    "abc is a domian name"
save & exit file.
# service ypserv restart
# service yppasswd start
Make new user
adduser "username"
passwd "enter password"
enter new password “typpe new password”
retype new password “retype new password”
*remote home directory-:
# mkdir /abc
#chmod 777 /abc

#creaton of the user #
useradd -d /abc/test1 test1
passwd test1
useradd -d /abc/test2 test2
passwd test2
* type following command-:
# /usr/lib/yp/ypinit -m
 It will ask u next host to add#
Press CTR+D#
you will get below message #
The current list of NIS servers looks like this:
linux1.abc.com
Is this correct? [y/n: y]
#
#Press Y#

#Set nfs services to automatic#
chkconfig nfs on
chkconfig portmap on
chkconfig nfslock on


vim /etc/exports
 make the following entry to share abc folder

/abc    *.192.168.10.0/24(rw,sync)

vim /etc/sysconfig/nfs
#make following entries in this file#
MOUNTD_PORT="4002"
STATD_PORT="4003"
LOCKD_TCPORT="4004"
LOCKD_UDPPORT="4004"
/etc/init.d/nfs restart
/etc/init.d/nfslock restart
/etc/init.d/portmap restart
exportfs -avf
show the exported folder
Client Side-:
now configure auto.misc and auto.master on client machine
make following entry in auto.misc
* -rw,soft,intr serveripaddress:/abc/&
make following entry in auto.master
/testhome etc/auto.misc
/etc/init.d/autofs restart
now run authconfig-tui
select nis domain
put ABC in domain fiels
server's ipaddress in server field
now login with user test1 from client machine in cmd prompt

Samba Configuration

Basic Samba Configuration step by step

We are trying to share knowledge about a samba by example.

we are going to create a directory path /home/data/sales.set the ownership and permission on the drectory such that people in the sales group can add/delete file but other can not.
first create a directory & set group & permission.
$ mkdir -p /home/data/sales
$ chgrp sales /home/data/sales
$ chmod 770 /home/data/sales
$ chmod g+s /home/data/sales note-: we have set special permission for group can add/delete file other can not.

# yum install samba*

open smb.conf file & add some line.

[sales]
comment = sales 's file
path = /home/data/sales
public = no
write list = @sales
: writable = yes

save & exit file.
$ /etc/init.d/smb restart

make a samba users & set smbpasswd-
$ smbpasswd -a user1

Selinux- if your selinux is inforce mode then you will need to allow selinux policy
$ getsebool -a | grep sam
$ setsebool -P samba_enable_home_dirs on

Iptables- if your pc firewall is enable then you will need set rules for allow.
$ iptables -I INPUT -s 192.168.10.0/24 -p tcp --dport 137:139 -J ACCEPT
$ iptables -I INPUT -s 192.168.10.0/24 -p tcp --dport 445 -J ACCEPT
$ iptables -I INPUT -s 192.168.10.0/24 -p udp --dport 137:139 -J ACCEPT
$ iptables -I INPUT -s 192.168.10.0/24 -p udp --dport 445 -J ACCEPT
$ /etc/init.d/iptables save
$ /etc/init.d/iptables restart
$ /etc/init.d/smb restart

Client side-
$ smbclient //servername/sales -U user1

if you want to permantly mount when system boot. you should be make fstab entry
add some line in fstab file.

$ vim /etc/fstab
//192.168.100.10/sales /mnt cifs username=user1,passwd=matix 0 0
save this file
$ umount -a
$ mount -a
$ df -kh (for check mount enrty)