Get the App
SLTechnology News&Howtos  ›  Network Security  › 

NFS service deployment

Shulou Source: shulou.com Published: 2022-06-01 04:57:17 09月13日 Update

NFS:Network File System, network file system, is mainly used to achieve network file sharing.

-server

1. Create a shared directory

[root@server /] # mkdir / home/TestNFS

2. Create a file

[root@server /] # cd / home/TestNFS/

[root@server TestNFS] # touch test.txt

3. Modify exports and configure the file sharing directory provided by nsf.

[root@server home] # vim / etc/exports

[root@server home] # cat / etc/exports

/ home/TestNFS/ 192.168.0.104 (rw,async,no_root_squash)

[root@server home] # exportfs-rv

Exporting 192.168.0.104:/home/TestNFS

-client

1. Check whether the NFS server allows local links to the corresponding shared directories.

[root@client1 /] # showmount-e 192.168.0.104

Export list for 192.168.0.104:

/ home/TestNFS 192.168.0.104

2. Create a local mount point

[root@client1 /] # cd / home/dana

[root@client1 home] # mkdir nfs

[root@client1 home] # ls

Dana nfs

3. Mount the shared directory

[root@client1 home] # mount 192.168.0.104:/home/TestNFS nfs

Mount.nfs: access denied by server while mounting 192.168.0.104:/home/TestNFS

Error report: mount.nfs: access denied by server while mounting 192.168.0.104:/home/TestNFS

Reason: when the NFS service starts, the port used is less than 1024, but the current virtual machine uses NAT, and its network address port translation is generally greater than 1024. It is necessary to disable the secure option, that is, to add insecure.

[root@server /] # cat / var/log/messages | grep mount

……

Jan 14 22:59:46 localhost rpc.mountd [13367]: refused mount request from 192.168.0.104 for / home/TestNFS (/ home/TestNFS): illegal port 37636

Handling method: modify exports on the server side

[root@server /] # vim / etc/exports

[root@server /] # cat / etc/exports

/ home/TestNFS/ 192.168.0.104 (insecure,rw,async,no_root_squash)

[root@server /] # exportfs-rv

Exporting 192.168.0.104:/home/TestNFS

4. Remount the shared directory

[root@client1 home] # mount 192.168.0.104:/home/TestNFS nfs

Root@client ~] # mount

……

Nfsd on / proc/fs/nfsd type nfsd (rw)

192.168.0.104:/home/TestNFS on / home/nfs type nfs (rw,vers=4,addr=192.168.0.104,clientaddr=172.16.71.129)

5. View the file

[root@client1 home] # cd nfs

[root@client1 nfs] # ls

Test.txt

Reference: http://blog.chinaunix.net/uid-20554957-id-3444786.html

Tags: File directory network service port reason address method time server system link native reference processing configuration Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker Shulou Tech Info Redmi macOS Linux