NFS (NETWORK FILE SYSTEM)-
Note- first set the ip add.
# vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROT=static
HWADDR=00:30:48:56:A6:2E
IPADDR=192.168.1.1
NETMASK=255.255.255.0
ONBOOT=yes
# /etc/init.d/NetworkManager restart
# ifconfig eth0
create the dir for sharing .
# mkdir /ashu-1
# vim /etc/exports
/ashu-1 192.168.1.0/24(rw,sync,no_root_squash,no_all_squash)
:wq
Where,
/ashu-1 – shared directory
192.168.1.0/24 – IP address range of clients
rw – Writable permission to shared folder
sync – Synchronize shared directory
no_root_squash – Enable root privilege
no_all_squash – Enable user’s authority
# /etc/init.d/nfs restart (Restart service)
# showmount -e 192.168.1.1 ( it will show the share dir)
# showmount -e 192.168.1.1 ( on client system to check share dir on server)
# getsebool -a | grep nfs
# setsebool -P nfs_export_all_rw 1 ( you have to run commond if selinux is enable)
ADD PORT IN NFS-
# vim /etc/sysconfig/nfs
MOUNTED-PORT= "4002"
STAID-PORT= "4003"
LOCKD-TCPPORT= "4004"
LOCKD-UDPPORT = "4004"
ROUOTAD-PORT = "4005"
STID-OUTGOING-PORT= "4006"
:wq
# /etc/init.d/portmap restart;chkconfig portmap on
# /etc/init.d/nfs restart;chkconfig nfs on
# /etc/init.d/nfslock restart;chkconfig nfslock on
# netstat -tulnp | grep 4004 ( we can check all port)
NOW WE HAVE TO ADD ALL PORT IN FIREWALL-
# vim /etc/sysconfig/iptables
_____________________________________________________________________________________________
#Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 5353 -d 224.0.0.251 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 631 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 631 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 631 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 4002 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 4002 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 4003 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 4003 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 4004 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 4004 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 4005 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 4005 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 4006 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 4006 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 111 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 111 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 2049 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 2049 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMT
_____________________________________________________________________________________________
NOTE- we have to add all port udp and tcp.
# /etc/init.d/iptables restart
# /etc/init.d/iptables save
# /etc/init.d/portmap restart;chkconfig nfs on
# /etc/init.d/nfs restart;chkconfig nfs on
# /etc/init.d/nfslock restart;chkconfig nfslock on
MOUNT POINT-
# mount 192.168.0.254:/ashu-1 /mnt (temp mount)
# vim etc/fstab (pemanently mount)
192.168.0.254:/ashu-1 /mnt nfs defaults 0 0
:wq
# mount -a
# cd /net
# cd 192.168.0.1 {it will show your share}
_____________________________________________________________________________________________
Network File
System, is a server-client protocol used for sharing files between
linux/unix to unix/linux systems. NFS enables you to mount a remote
share locally. You can then directly access any of the files on that
remote share. Network File System developed by Sun Microsystems.
Port NO - 2049 (for nfs) - 111 port map
Package- nfs-utils
Daemon- rpc.nfsd , rpc.mounted, rpc.lockd, rpc.statd, rpc.rquotad
Port NO - 2049 (for nfs) - 111 port map
Package- nfs-utils
Daemon- rpc.nfsd , rpc.mounted, rpc.lockd, rpc.statd, rpc.rquotad
Note- first set the ip add.
# vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROT=static
HWADDR=00:30:48:56:A6:2E
IPADDR=192.168.1.1
NETMASK=255.255.255.0
ONBOOT=yes
# /etc/init.d/NetworkManager restart
# ifconfig eth0
create the dir for sharing .
# mkdir /ashu-1
# vim /etc/exports
/ashu-1 192.168.1.0/24(rw,sync,no_root_squash,no_all_squash)
:wq
Where,
/ashu-1 – shared directory
192.168.1.0/24 – IP address range of clients
rw – Writable permission to shared folder
sync – Synchronize shared directory
no_root_squash – Enable root privilege
no_all_squash – Enable user’s authority
# /etc/init.d/nfs restart (Restart service)
# showmount -e 192.168.1.1 ( it will show the share dir)
# showmount -e 192.168.1.1 ( on client system to check share dir on server)
# getsebool -a | grep nfs
# setsebool -P nfs_export_all_rw 1 ( you have to run commond if selinux is enable)
ADD PORT IN NFS-
# vim /etc/sysconfig/nfs
MOUNTED-PORT= "4002"
STAID-PORT= "4003"
LOCKD-TCPPORT= "4004"
LOCKD-UDPPORT = "4004"
ROUOTAD-PORT = "4005"
STID-OUTGOING-PORT= "4006"
:wq
# /etc/init.d/portmap restart;chkconfig portmap on
# /etc/init.d/nfs restart;chkconfig nfs on
# /etc/init.d/nfslock restart;chkconfig nfslock on
# netstat -tulnp | grep 4004 ( we can check all port)
NOW WE HAVE TO ADD ALL PORT IN FIREWALL-
Probably
it will show a connection timed out error which means that the firewall
is blocking NFS server. To allow NFS server to access from outbound,
goto NFS server system and add the as shown below in the
‘etc/sysconfig/iptables’ file.
port: 4002/4003/4004/4005/4006/111/2049# vim /etc/sysconfig/iptables
_____________________________________________________________________________________________
#Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 5353 -d 224.0.0.251 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 631 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 631 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 631 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 4002 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 4002 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 4003 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 4003 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 4004 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 4004 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 4005 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 4005 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 4006 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 4006 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 111 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 111 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 2049 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 2049 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMT
_____________________________________________________________________________________________
# /etc/init.d/iptables restart
# /etc/init.d/iptables save
# /etc/init.d/portmap restart;chkconfig nfs on
# /etc/init.d/nfs restart;chkconfig nfs on
# /etc/init.d/nfslock restart;chkconfig nfslock on
MOUNT POINT-
# mount 192.168.0.254:/ashu-1 /mnt (temp mount)
# vim etc/fstab (pemanently mount)
192.168.0.254:/ashu-1 /mnt nfs defaults 0 0
:wq
# mount -a
# cd /net
# cd 192.168.0.1 {it will show your share}
_____________________________________________________________________________________________