NFS application is based on UDP / IP protocol, which is mainly used to realize a remote procedure call RPC mechanism, RPC provides a group of access remote file operations not related to the machine, the operating system and the low-level transport protocol. RPC uses the XDR support. XDR is a machine-independent data protocol description coding, the format he independently with any machine architecture for internet data transmission encoding and decoding, to support transfer of data between heterogeneous systems.
1. Set the host server
(1) Installation NFS server
root@ubuntu:~# apt-get update
root@ubuntu:~# apt install nfs-kernel-server
(2) create the export directory
Shared with the client system directory as export directory.
You can determine the path to the export directory and named according to their choice.
root@ubuntu:~# mkdir -p /home/rabbit/NFS_SHARE
Restrict the right to delete folders
root@ubuntu:~# chown nobody:nogroup /home/rabbit/NFS_SHARE
root@ubuntu:~# chmod 777 /home/rabbit/NFS_SHARE
Now, all users of all groups on the client system can access the export directory.
(3) assigned to the client access to the server via NFS exported file
After you create the export directory, the need to provide access to the host server to the client.
This permission is defined by the / etc / exports file is in the system.
root@ubuntu:~# vim /etc/exports
- A single client /home/rabbit/NFS_SHARE clientIP(rw,sync,no_subtree_check)
- Multiple clients (by IP) /home/rabbit/NFS_SHARE clientIP_1(rw,sync,no_subtree_check)
-
/home/rabbit/NFS_SHARE clientIP_2(rw,sync,no_subtree_check)
- Multiple clients (entire subnet) /home/rabbit/NFS_SHARE 192.168.8.0/24(rw,sync,no_subtree_check)
-
rw: read and write operations
-
sync:
-
no_subtree_check: stop subtree checking
(4) Export shared directory
After the above configuration in the host system, shared directory may be derived by the following command:
root@ubuntu:~# exportfs -a
In order to make all configurations take effect, restart the NFS server:
root@ubuntu:~# systemctl restart nfs-kernel-server
(5) to open the firewall client
ufw allow from [clientIP or clientSubnetIP] to any port nfs
Use the following command to access the entire subnet the client computer:
root@ubuntu:~# ufw allow from 192.168.8.0/24 to any port nfs
root@ubuntu:~# ufw status
2, set the client computer
(1) Installation NFS Common
Internet repository index and the index update system:
root@ubuntu:~# apt-get update
root@ubuntu:~# apt-get install nfs-common
Share files (2) Create a folder to host NFS mount points
root@ubuntu:~# mkdir -p /home/rabbit/NFS_CLIENT
(3) mount the shared directory on the client
mount serverIP:/shareFolder_server /home/rabbit/mountFolder_client
root@ubuntu:~# mount 192.168.8.245:/home/rabbit/NFS_SHARE /home/rabbit/NFS_CLIENT
(4) test connection
Create or save files in the export directory NFS host server.
Now, open NFS_CLIENT file folder on the client computer, you can view and share the same file access in this folder.
3, summary
Set up an NFS server on Ubuntu systems - client environment is complete.
Learn smooth access to the case file folder how to configure NFS servers and clients, so that you can share a folder, then there is no firewall or rights associated applause.
Now, using the NFS protocol to easily share content from a Ubuntu system to another.