March 24, 2007, 3:04 a.m.
posted by whitehat
Configuring NFS on the ClientNFS configuration on the client requires you to start the NFS application; create a directory on which to mount the NFS server's directories that you exported via the /etc/exports file, and finally to mount the NFS server's directory on your local directory, or mount point. Here's how to do it all. Starting NFS on the ClientThree more steps easily configure NFS on the client: NFS and DNSThe NFS client must have a matching pair of forward and reverse DNS entries on the DNS server used by the NFS server. In other words, a DNS lookup on the NFS server for the IP address of the NFS client must return a server name that will map back to the original IP address when a DNS lookup is done on that same server name.
[root@bigboy tmp]# host 192.168.1.102
201.1.168.192.in-addr.arpa domain name pointer 192-168-1-102.my-web-
site.org.
[root@bigboy tmp]# host 192-168-1-102.my-web-site.org
192-168-1-102.my-web-site.org has address 192.168.1.102
[root@bigboy tmp]#
This is a security precaution added into the nfs package that lessens the likelihood of unauthorized servers from gaining access to files on the NFS server. Failure to correctly register your server IPs in DNS can result in "fake hostname" errors:
Nov 7 19:14:40 bigboy rpc.mountd: Fake hostname smallfry.my-web-
site.org for 192.168.1.1 - forward lookup doesn't exist
Making NFS Mounting PermanentIn most cases, users want their NFS directories to be permanently mounted. This requires an entry in the /etc/fstab file in addition to the creation of the mount point directory. The /etc/fstab FileThe /etc/fstab file lists all the partitions that need to be auto-mounted when the system boots. Therefore, you need to edit the /etc/fstab file if you need the NFS directory to be made permanently available to users on the NFS. For the example, mount the /data/files directory on server Bigboy (IP address 192.16801.100) as an NFS-type filesystem using the local /mnt/nfs mount point directory:
#/etc/fstab
#Directory Mount Point Type Options Dump
FSCK
192.168.1.100:/data/files /mnt/nfs nfs soft,nfsvers=2 0
0
This example used the soft and nfsvers options; Figure outlines these and other useful NFS mounting options you may want to use. See the NFS man pages for more details.
The steps to mount the directory are fairly simple, as you'll see. Permanently Mounting the NFS DirectoryYou'll now create a mount point directory, /mnt/nfs, on which to mount the remote NFS directory and then use the mount -a command to activate the mount. Notice how before mounting there were no files visible in the /mnt/nfs directory, this changes after the mounting is completed:
[root@smallfry tmp]# mkdir /mnt/nfs
[root@smallfry tmp]# ls /mnt/nfs
[root@smallfry tmp]# mount -a
[root@smallfry tmp]# ls /mnt/nfs
ISO ISO-RedHat kickstart RedHat
[root@smallfry tmp]#
Each time your system boots, it reads the /etc/fstab file and executes the mount -a command, thereby making this a permanent NFS mount.
Manually Mounting NFS File SystemsIf you don't want a permanent NFS mount, then you can use the mount command without the /etc/fstab entry to gain access only when necessary. This is a manual process; for an automated process, see the section "The NFS automounter." In this case, you're mounting the /data/files directory as an NFS-type filesystem on the /mnt/nfs mount point. The NFS server is Bigboy whose IP address is 192.168.1.100. Notice how before mounting there were no files visible in the /mnt/nfs directory, this changes after the mounting is complete:
[root@smallfry tmp]# mkdir /mnt/nfs
[root@smallfry tmp]# ls /mnt/nfs
[root@smallfry tmp]# mount -t nfs 192.168.1.100:/data/files /mnt/nfs
[root@smallfry tmp]# ls /mnt/nfs
ISO ISO-RedHat kickstart RedHat
[root@smallfry tmp]#
Congratulations! You've made your first steps towards being an NFS administrator. |
- Comment