![]() |
| Sei qui: Homepage INFN Bari> Servizio calcolo e reti> Documenti> Setting up an NFS server |
Disclaimer: The information contained herein is NOT official information of any kind and there are NO warranties to the accuracy of the data. Use at your own risk.
fdisk /dev/hdgFollow the instructions and create one big partition /dev/hdg1.
mkfs -t ext3 -c /dev/hdg1The "-c" options searchs for invalid disk sectors.
mkdir /nfsdir chmod 777 /nfsdir mount -t ext3 /dev/hdg1 /nfsdir
/dev/hdg1 /nfsdir ext3 defaults 1 2Now the new device will be mounted on boot on the selected directory.
rpm -qa | grep packet_name
/nfsdir ip.pc.client1(rw) ip.pc.client2(rw)Note that the list of authorized client provides a first security step: only the IP addresses listed here are allowed to access a share point. However this is not terribly secure: if someone is capable of spoofing or taking over a trusted address then they can access your mount point.
daemon_name: ALLfor each of the five daemons portmap, lockd, statd, mountd, rquotad. In the file /etc/hosts.allow the line should look like this:
daemon_name: ip.pc.client1 , ip.pc.client2
/etc/init.d/portmap start /etc/init.d/nfs start /etc/init.d/nfslock startand add them to the start configuration with:
chkconfig --level 35 portmap on chkconfig --level 35 nfs on chkconfig --level 35 nfslock onIf the services are not present in the level management add them with "--add" chkconfig option.
rpcinfo -pYou should see something like this:
programma vers proto porta
100000 2 tcp 111 portmapper
100000 2 udp 111 portmapper
100024 1 udp 32768 status
100024 1 tcp 32768 status
391002 2 tcp 32769 sgi_fam
100011 1 udp 690 rquotad
100011 2 udp 690 rquotad
100011 1 tcp 693 rquotad
100011 2 tcp 693 rquotad
100005 1 udp 32769 mountd
100005 1 tcp 32770 mountd
100005 2 udp 32769 mountd
100005 2 tcp 32770 mountd
100005 3 udp 32769 mountd
100005 3 tcp 32770 mountd
100003 2 udp 2049 nfs
100003 3 udp 2049 nfs
100021 1 udp 32770 nlockmgr
100021 3 udp 32770 nlockmgr
100021 4 udp 32770 nlockmgr
daemon_name: ALLfor each of the five daemons portmap, lockd, statd, mountd, rquotad. In the file /etc/hosts.allow the line should look like this:
daemon_name: ip.pc.server
rpcinfo -pyou should get something like this:
programma vers proto porta
100000 2 tcp 111 portmapper
100000 2 udp 111 portmapper
100024 1 udp 32768 status
100024 1 tcp 32768 status
391002 2 tcp 32769 sgi_fam
100021 1 udp 32811 nlockmgr
100021 3 udp 32811 nlockmgr
100021 4 udp 32811 nlockmgr
mkdir /mntdir mount -t nfs ip.pc.server:/nfsdir /mntdir
ip.pc.server:/nfsdir /mntdir nfs bg,hard,intr,nosuid,rw 0 0The meanings of the options are:
daemon rpc.statd -p 4000
options lockd nlm_udpport=4001 nlm_tcpport=4001
MOUNTD_PORT=4002
tar zxvf quota-3.08.tar.gz cd quota-tools ./configure make make install cp rpc.rquotad /usr/sbin/Now edit the file /etc/rpc and check that the following line is present:
rquotad 100011 rquotaprog quota rquotaIt should be there, but if isnt, then add it yourself. Finally edit the file /etc/services and add the following lines:
rquotad 4003/tcp rquotad 4003/tcpNote that you can happily use NFS without quotas, and in such case you can skip this point.
iptables -A INPUT -f -j ACCEPT -s ip.pc.client iptables -A INPUT -s ip.pc.client -d 0/0 4000:4003 -p 6 -j ACCEPT iptables -A INPUT -s ip.pc.client -d 0/0 4000:4003 -p 17 -j ACCEPT iptables -A INPUT -s ip.pc.client -d 0/0 2049 -p 17 -j ACCEPT iptables -A INPUT -s ip.pc.client -d 0/0 2049 -p 6 -j ACCEPT iptables -A INPUT -s ip.pc.client -d 0/0 111 -p 6 -j ACCEPT iptables -A INPUT -s ip.pc.client -d 0/0 111 -p 17 -j ACCEPT iptables -A INPUT -s 0/0 -d 0/0 -p 6 -j DENY --syn --log-level 5 iptables -A INPUT -s 0/0 -d 0/0 -p 17 -j DENY --log-level 5With IPCHAINS the equivalent commands are:
ipchains -A input -f -j ACCEPT -s ip.pc.client ipchains -A input -s ip.pc.client -d 0/0 4000:4003 -p 6 -j ACCEPT ipchains -A input -s ip.pc.client -d 0/0 4000:4003 -p 17 -j ACCEPT ipchains -A input -s ip.pc.client -d 0/0 2049 -p 17 -j ACCEPT ipchains -A input -s ip.pc.client -d 0/0 2049 -p 6 -j ACCEPT ipchains -A input -s ip.pc.client -d 0/0 111 -p 6 -j ACCEPT ipchains -A input -s ip.pc.client -d 0/0 111 -p 17 -j ACCEPT ipchains -A input -s 0/0 -d 0/0 -p 6 -j DENY -y -l ipchains -A input -s 0/0 -d 0/0 -p 17 -j DENY -lIt is worth mentioning that NFS is not an encrypted protocol, and anyone on the same physical network could sniff the traffic and reassemble the information being passed back and forth.