Home Linux & Systems Cybersecurity Cloud & DevOps Networks & Infrastructure SIEM & Monitoring DFIR & Threat Intel Development & Other All categories Projects About Tools

NFS Server – Folder Sharing

Leer en espanol
NFS Server – Folder Sharing

Table of contents

The Network File System, or NFS, is an application-level protocol, according to the OSI Model. It is used for distributed file systems in a d environment. ===

¿QUE ES NFS?

He Network File System (Network File System), o NFS, it's a protocol application level, depending on the OSI model. It is used for distributed file systems in a local area computer network environment. Enables different systems connected to the same network to access remote files as if they were local files

We install the necessary packages.

text
aptitude install nfs-kernel-server portmap nfs-common nfswatch

We verify that portmap is running.

text
ps aux | grep portmap

daemon 1166 0.0 0.0 1808 448 ? Ss Dec26 0:00 /sbin/portmap

To know if NFS is running, we will query the portmap to tell us what services it has running.

text
rpcinfo -p

programa vers proto puerto

100000 2 tcp 111 portmapper

100000 2 udp 111 portmapper

100024 1 udp 53104 status

100024 1 tcp 40155 status

100021 1 udp 42941 nlockmgr

100021 3 udp 42941 nlockmgr

100021 4 udp 42941 nlockmgr

100021 1 tcp 48742 nlockmgr

100021 3 tcp 48742 nlockmgr

100021 4 tcp 48742 nlockmgr

100003 2 tcp 2049 nfs

100003 3 tcp 2049 nfs

100003 4 tcp 2049 nfs

100003 2 udp 2049 nfs

100003 3 udp 2049 nfs

100003 4 udp 2049 nfs

100005 1 udp 49454 mountd

100005 1 tcp 45660 mountd

100005 2 udp 49454 mountd

100005 2 tcp 45660 mountd

100005 3 udp 49454 mountd

100005 3 tcp 45660 mountd

Once the verification is done we are going to mount the disk, FS or folder that we want. The configuration is done in the file: /etc/exports

Bash
vi /etc/exports

Syntax:

We insert the route, IP, subnet mask and permissions

Example:

text
/media/DATOS 192.168.1.0/255.255.255.0(rw)

Basic configuration /etc/hosts.allow and /etc/hosts.deny

text
/etc/hosts.deny

portmap:ALL

lockd:ALL

mountd:ALL

rquotad:ALL

statd:ALL
/etc/hosts.allow

portmap:192.168.0.0/255.255.255.0

lockd:192.168.0.0/255.255.255.0

mountd:192.168.0.0/255.255.255.0

rquotad:192.168.0.0/255.255.255.0

statd:192.168.0.0/255.255.255.0

We start the daemon

text
/etc/init.d/nfs-kernel-server restart

We check that you have shared it correctly.

Bash
exportfs
/media/DATOS 192.168.1.0/255.255.255.0

Client settings

We install the necessary packages.

Bash
apt-get install rpcbind nfs-common

We must allow the server's rpcbind.

vi /etc/hosts.allow

and we add:

rpcbind: 192.168.1.101/255.255.255.255

Command syntax:

We insert ip or name, shared directory and mount point

Bash
mount -nfs <IP O NOMBREEA>:/<DIRECTORIO> <PUNTO DE MONTAJE>

Example:

Bash
mount  -nfs 192.168.1.101:/media/DATOS  /DATOS -o nolock

If we want the NFS file system to be mounted at boot, we must add an entry in the file /etc/fstab. In our example we would add

text
192.168.1.101:/DATOS /DATOS nfs rw,hard,intr 0 0

Greetings, rokitoh!

Comments