# Serveur NFSv4 (jessie) + connection macOS(Mojave)

**URL:** <https://www.debian-fr.org/t/serveur-nfsv4-jessie-connection-macos-mojave/79746>\
**Category:** Support Debian\
**Created:** [Juillet 25, 2019, 1:55 UTC](https://www.debian-fr.org/t/serveur-nfsv4-jessie-connection-macos-mojave/79746 "2019-07-25T13:55:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![trululu](https://www.debian-fr.org/user_avatar/www.debian-fr.org/trululu/32/5304_2.png) [@trululu](https://www.debian-fr.org/u/trululu)\
**Post date:** [Juillet 25, 2019, 1:55 UTC](https://www.debian-fr.org/t/serveur-nfsv4-jessie-connection-macos-mojave/79746/1 "2019-07-25T13:55:34Z")

</div>

Bonjour à tous,

Je souhaite installer sur mon réseau local un serveur NFS en version 4 sur une Jessie (oui je sais c’est vieux : je changerai ça plus tard 😉 ) et je me base - notamment - sur ce [wiki](https://wiki.debian.org/NFSServerSetup).

```
user01@srv01:~$ grep NFSD /boot/config-`uname -r`
CONFIG_NFSD=m
CONFIG_NFSD_V2_ACL=y
CONFIG_NFSD_V3=y
CONFIG_NFSD_V3_ACL=y
CONFIG_NFSD_V4=y
CONFIG_NFSD_PNFS=y
CONFIG_NFSD_V4_SECURITY_LABEL=y
# CONFIG_NFSD_FAULT_INJECTION is not set

```

=\> coté kernel = ok !

```
root@srv01:~# apt-cache policy nfs-kernel-server portmap
nfs-kernel-server:
  Installed: 1:1.2.8-9
  Candidate: 1:1.2.8-9
  Version table:
 *** 1:1.2.8-9 0
        500 http://ftp.fr.debian.org/debian/ jessie/main amd64 Packages
        100 /var/lib/dpkg/status
portmap:
  Installed: (none)
  Candidate: (none)
  Version table:

```

Ça commence : [portmap est en fait un paquet virtuel !](https://packages.debian.org/jessie/portmap)  
Donc :

```
root@srv01:~# apt-cache policy rpcbind
rpcbind:
  Installed: 0.2.1-6+deb8u2
  Candidate: 0.2.1-6+deb8u2
  Version table:
 *** 0.2.1-6+deb8u2 0
        500 http://ftp.fr.debian.org/debian/ jessie/main amd64 Packages
        500 http://security.debian.org/ jessie/updates/main amd64 Packages
        100 /var/lib/dpkg/status

```

=\> coté install, c’est ok !

Comme je ne souhaite avoir mon serveur NFS qu’en version 4 : “_The portmap package is only required if you want to run an NFSv2 or NFSv3 server. If all your clients support NFSv4, you can disable NFSv2 and NFSv3 (as described in the “NFSv4 only” section below) and skip the “Portmap” section below._”

Je passe donc à la section “_Exports_” :

```
root@srv01:~# cat /etc/exports 
# /etc/exports: the access control list for filesystems which may be exported
# to NFS clients. See exports(5).
#
# Example for NFSv2 and NFSv3:
# /srv/homes hostname1(rw,sync,no_subtree_check) hostname2(ro,sync,no_subtree_check)
#
# Example for NFSv4:
# /srv/nfs4 gss/krb5i(rw,sync,fsid=0,crossmnt,no_subtree_check)
# /srv/nfs4/homes gss/krb5i(rw,sync,no_subtree_check)
#

/storage/shares/partage 192.168.1.1/24(rw,sync,no_subtree_check)
root@srv01:~# exportfs -a
root@srv01:~# systemctl restart nfs-kernel-server.service 
root@srv01:~# systemctl status nfs-kernel-server.service 
● nfs-kernel-server.service - LSB: Kernel NFS server support
   Loaded: loaded (/etc/init.d/nfs-kernel-server)
   Active: active (exited) since Thu 2019-07-25 14:43:33 CEST; 14s ago
  Process: 3201 ExecStop=/etc/init.d/nfs-kernel-server stop (code=exited, status=0/SUCCESS)
  Process: 3211 ExecStart=/etc/init.d/nfs-kernel-server start (code=exited, status=0/SUCCESS)

Jul 25 14:43:33 srv01 nfs-kernel-server[3211]: Exporting directories for NFS kernel daemon....
Jul 25 14:43:33 srv01 nfs-kernel-server[3211]: Starting NFS kernel daemon: nfsd
Jul 25 14:43:33 srv01 nfs-kernel-server[3211]: Not starting: portmapper is not running ... (warning).
Jul 25 14:43:33 srv01 systemd[1]: Started LSB: Kernel NFS server support.

```

On pourrait donc croire que c’est OK, sauf que :

```
root@srv01:~# cat /proc/fs/nfsd/versions
-2 -3 -4 -4.1 -4.2

```

=\> toutes les version de NFS sont disabled sur le serveur ! 🙄  
Ça sent pas bon…

Je passe quand même à la section “_NFSv4 Only_” :

```
root@srv01:~# cat /etc/default/nfs-common
# If you do not set values for the NEED_ options, they will be attempted
# autodetected; this should be sufficient for most people. Valid alternatives
# for the NEED_ options are "yes" and "no".

# Do you want to start the statd daemon? It is not needed for NFSv4.
#NEED_STATD=
NEED_STATD="no"

# Options for rpc.statd.
# Should rpc.statd listen on a specific port? This is especially useful
# when you have a port-based firewall. To use a fixed port, set this
# this variable to a statd argument like: "--port 4000 --outgoing-port 4001".
# For more information, see rpc.statd(8) or http://wiki.debian.org/SecuringNFS
#STATDOPTS=
STATDOPTS="--port 37400 --outgoing-port 37401"

# Do you want to start the idmapd daemon? It is only needed for NFSv4.
#NEED_IDMAPD=
NEED_IDMAPD="yes"

# Do you want to start the gssd daemon? It is required for Kerberos mounts.
NEED_GSSD=
root@srv01:~# cat /etc/default/nfs-kernel-server
# Number of servers to start up
RPCNFSDCOUNT=8

# Runtime priority of server (see nice(1))
RPCNFSDPRIORITY=0

# Options for rpc.mountd.
# If you have a port-based firewall, you might want to set up
# a fixed port here using the --port option. For more information, 
# see rpc.mountd(8) or http://wiki.debian.org/SecuringNFS
# To disable NFSv4 on the server, specify '--no-nfs-version 4' here
#RPCMOUNTDOPTS="--manage-gids"
RPCNFSDOPTS="-N 2 -N 3"
RPCMOUNTDOPTS="--port 37402 -N 2 -N 3"

# Do you want to start the svcgssd daemon? It is only required for Kerberos
# exports. Valid alternatives are "yes" and "no"; the default is "no".
NEED_SVCGSSD=""

# Options for rpc.svcgssd.
RPCSVCGSSDOPTS=""
root@srv01:~# systemctl status rpcbind.service 
    ● rpcbind.service
       Loaded: masked (/dev/null)
       Active: inactive (dead)

    Warning: Unit file changed on disk, 'systemctl daemon-reload' recommended.
root@srv01:~# systemctl status rpcbind.socket
    ● rpcbind.socket
       Loaded: masked (/dev/null)
       Active: inactive (dead)

```

(même après un systemctl daemon-reload, j’ai toujours cette alerte : je ne sais pas pourquoi…)

D’après le wiki, ça devrait être bon… sauf que si je fais un showmount sur le client macos :

```
user01@mac01:~$ showmount -e srv01
showmount: Cannot retrieve info from host: srv01: RPC failed:: RPC: Unable to send; errno = Bad file descriptor

```

ou sur un client Stretch:

```
root@debian:~# showmount -e srv01
clnt_create: RPC: Port mapper failure - Unable to receive: errno 0 (success)

```

Ce qui n’est étonnant vu qu’aucun service NFS n’est en écoute :

```
root@srv01:~# netstat -lptn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 2140/sshd       
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 2130/cupsd      
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 2271/master     
tcp 0 0 0.0.0.0:445 0.0.0.0:* LISTEN 2289/smbd       
tcp 0 0 127.0.0.1:3493 0.0.0.0:* LISTEN 2298/upsd       
tcp 0 0 0.0.0.0:139 0.0.0.0:* LISTEN 2289/smbd       
tcp 0 0 127.0.0.1:6379 0.0.0.0:* LISTEN 2114/redis-server 1
tcp6 0 0 :::22 :::* LISTEN 2140/sshd       
tcp6 0 0 ::1:631 :::* LISTEN 2130/cupsd      
tcp6 0 0 ::1:25 :::* LISTEN 2271/master     
tcp6 0 0 :::445 :::* LISTEN 2289/smbd       
tcp6 0 0 :::139 :::* LISTEN 2289/smbd 

```

😭

Quelqu’un aurait-il une idée sur le fait qu’aucun service NFS ne se lance, svp ?  
Thanks in advance,  
Trululu

---

<div class="post-metadata">

**Author:** ![choops](https://www.debian-fr.org/user_avatar/www.debian-fr.org/choops/32/8109_2.png) [@choops](https://www.debian-fr.org/u/choops)\
**Post date:** [Juillet 25, 2019, 2:34 UTC](https://www.debian-fr.org/t/serveur-nfsv4-jessie-connection-macos-mojave/79746/2 "2019-07-25T14:34:31Z")

</div>

Salut

Le ‹&nbsp;`192.168.1.1/24`&nbsp;› dans ton `/etc/exports` me semble le fautif.  
J’aurais plus vu un ‹&nbsp;`192.168.1.0/24`&nbsp;› pour couvrir tout ton réseau (en admettant que ‹&nbsp;`192.168.1.0/24`&nbsp;› soit l’ip de ton réseau) ou simplement un ‹&nbsp;`192.168.1.1`&nbsp;› si tu veux que ce partage NFS ne soit visible que pour la machine dont l’ip est ‹&nbsp;`192.168.1.1`&nbsp;› (en admettant que ce soit le cas pour ta machine ‹&nbsp;`mac01`&nbsp;›).  
Tu peux même être plus bourrin (au moins pour tester) en rendant ce partage visible globalement avec un ciblage sur ‹&nbsp;`*`&nbsp;›.

Evidemment, une fois les modifs apportées au /etc/exports, il faudra que tu redémarres ton service nfs sur le serveur:

```auto
systemctl restart nfs-kernel-server

```

EDIT:  
Un truc que je n’avais pas vu et qui peut aussi être source du problème:  
Le tuto que tu indiques, te suggère de placer ‹&nbsp;`RPCMOUNTDOPTS="--manage-gids -N 2 -N 3"`&nbsp;› dans `/etc/default/nfs-common`.  
Pourquoi y passes-tu ‹&nbsp;`RPCMOUNTDOPTS="--port 37402 -N 2 -N 3"`&nbsp;› ? d’où sort ce port 37402 ?  
D’autant qu’il est bien signalé dans le tuto:

> [@'https://wiki.debian.org/NFSServerSetup' says](#):
>
> NFSv4 only requires a single port (TCP/UDP 2049) and does not require the portmap service to be installed.

---

<div class="post-metadata">

**Author:** ![trululu](https://www.debian-fr.org/user_avatar/www.debian-fr.org/trululu/32/5304_2.png) [@trululu](https://www.debian-fr.org/u/trululu)\
**Post date:** [Août 1, 2019, 9:35 UTC](https://www.debian-fr.org/t/serveur-nfsv4-jessie-connection-macos-mojave/79746/3 "2019-08-01T09:35:58Z")

</div>

Merci choops pour ta réponse. (je reviens un peu tard, désolé)

Le `192.168.1.1` seul, j’avais essayé (j’aurais dû le préciser) mais sans succès.  
Par contre, je n’avais pas pensé à mettre tout simplement le réseau (192.168.1.0/24) mais malheureusement ça n’a pas mieux fonctionné.

Concernant le port 37402, je ne sais pas/plus du tout où j’ai trouvé ça !!! 🙄  
Je ne pense pas l’avoir inventé… mais alors pour quelle raison : mystère !!!  
Par acquis de conscience et suivant tes conseils, je l’ai viré et mis `--manage-gids" -N 2 -N 3` à la place mais toujours aucun changement après redémarrage du service.

Bon, après quelques heures de galère sur ce pb sans résultat (et comme le serveur était loin d’être up-to-date) je l’ai refait complètement sous Buster. (avec la conf `192.168.1.0/24` dans `/etc/exports` et rien de particulier dans `/etc/default/nfs-common`)  
=\> NFS a été fonctionnel dès le 1er coup !

C’est dommage de ne pas connaître la cause exacte de ce dysfonctionnement mais je n’avais pas non plus beaucoup de temps pour investiguer malheureusement…

Merci encore choops pour ton aide !  
A+  
Trululu
