NFS is a common file sharing protocol. In some systems, the configuration of this protocol is also relatively complex. So today we will explain how to configure Debian NFS. Hope to help you. First, let's take a look at how to install the NFS server In Debian.
Install the Debian NFS server: # aptitude install nfs-common nfs-kernel-server portmap
Install nfs-common portmap on the client: # aptitude install
Start the service: #/etc/init. d/nfs-kernel-server start
Stop Service: #/etc/init. d/nfs-kernel-server stop
Restart the service: #/etc/init. d/nfs-kernel-server restart
Debian NFS Server Configuration:
1. Create a shared directory:
# Mkdir/home/share
# Chown nobody. nogroup/home/share
2. Create or modify the/etc/exports configuration file
If you share the same directory with multiple clients but have different permissions for each client, you can:
[Shared directory] [host name 1 or IP1 (parameter 1, parameter 2)] [host name 2 or IP2 (parameter 3, parameter 4)]
Common Parameters for Debian NFS server sharing:
Ro read-only access
Rw read/write access
Sync all data written for sharing upon request
Async NFS can request data before writing data
Secure NFS is sent through the secure TCP/IP ports below 1024
Insecure NFS is sent over port 1024
Wdelay if multiple users want to write data to the NFS Directory, write data to the group by default)
No_wdelay if multiple users want to write data to the NFS Directory, write the data immediately. This setting is not required when async is used.
Hide does not share its subdirectories in the NFS shared directory.
No_hide shares the subdirectory of the NFS Directory
Subtree_check if sub-directories such as/usr/bin are shared, force NFS to check the permission of the parent directory by default)
No_subtree_check is opposite to the above. The parent directory permission is not checked.
All_squash: The UID and GID of the shared file are mapped to the anonymous user anonymous, which is suitable for public directories.
No_all_squash retains the UID and GID of the shared file by default)
Root_squash all requests of the root user are mapped to the same permissions as those of the anonymous user by default)
The no_root_squas root user has full management access permissions to the root directory.
Anonuid = xxx specifies the UID of an anonymous user in the NFS server/etc/passwd file
Anongid = xxx specifies the GID of anonymous users in the NFS server/etc/passwd file
The Debian NFS server configuration file/etc/exports is as follows:
$ Cat/etc/exports
/Home/share 192.168.102.15 (rw, sync) * (ro)
Configuration Description: grant the read and write permissions to 192.168.102.15. Other machines only have the read-only permission.
Restart the server: #/etc/init. d/nfs-kernel-server restart
3. View NFS server resource sharing on the client: # showmount-e 192.168.102.47
4. Run the mount command on the client to mount the shared directory: # mount 192.168.102.47:/home/share/mnt
Do we need to restart the Debian NFS server service every time we modify the configuration file? At this time, we can use the exportfs command to re-scan the/etc/exports file to make the change take effect immediately.
For example:
# Exportfs-au Uninstall all shared directories
# Exportfs-rv share all directories again and output details
The exportfs command is provided by the software package nfs-kernel-server. For more information about the exportfs command, see:
# Man exportfs