# [SOLVED] nfs/nlockmgr ports

## hujuice

I'm unable to drive the rpc ports of a NFSv3 installation, managed with net-fs/nfs-utils-1.2.3-r1.

I need it because I need an iptables filter.

```
# rpcinfo -p

 programma vers proto   porta

    100000    4   tcp    111  portmapper

    100000    3   tcp    111  portmapper

    100000    2   tcp    111  portmapper

    100000    4   udp    111  portmapper

    100000    3   udp    111  portmapper

    100000    2   udp    111  portmapper

    100024    1   udp  32765  status

    100024    1   tcp  32765  status

    100005    1   udp  32767  mountd

    100005    1   tcp  32767  mountd

    100005    2   udp  32767  mountd

    100005    2   tcp  32767  mountd

    100005    3   udp  32767  mountd

    100005    3   tcp  32767  mountd

    100003    2   tcp   2049  nfs

    100003    3   tcp   2049  nfs

    100003    2   udp   2049  nfs

    100003    3   udp   2049  nfs

    100021    1   udp  46220  nlockmgr

    100021    3   udp  46220  nlockmgr

    100021    4   udp  46220  nlockmgr

    100021    1   tcp  48833  nlockmgr

    100021    3   tcp  48833  nlockmgr

    100021    4   tcp  48833  nlockmgr
```

The lockmgr ports appear to be randomly chosen, while an iptables filter needs a known port. 

Who drives the nlockmgr ports? How to configure them to have a know value?

Could someone suggest something to me?   :Shocked: 

Regards,

HUJuice

----------

## Hu

Set /proc/sys/fs/nfs/nlm_tcpport to the desired port number.

----------

## hujuice

 *Hu wrote:*   

> Set /proc/sys/fs/nfs/nlm_tcpport to the desired port number.

 

Thank you Hu. You're right but it is not resolved.

Until some week ago (before a nfs-utils upgrade?) I managed this value (and the corresponding nlm_udpport) via /etc/sysctl.conf.

Now I obtain the following:

```
 * Configuring kernel parameters ...

 * Unknown keys: error: "fs.nfs.nlm_tcpport" is an unknown key

error: "fs.nfs.nlm_udpport" is an unknown key
```

And the values, in fact, are not set.

Manually setting the proc values and restarting nfs works fine.

nfsd, lockd and so on are built as modules. Should I set some module option?

Hujuice

----------

## hujuice

 *hujuice wrote:*   

> Should I set some module option?

 

The way to anchor lockd to a known port is:

```
modules_2_6="${modules_2_6} lockd"

module_lockd_args="nlm_udpport=4001 nlm_tcpport=4001"
```

with your preferred port number.

Solved.

HUJuice

----------

## Hu

Those sysctl values exist only when the corresponding code is available.  Since you did not include NFS in the main kernel binary, the sysctl is not available when the system initializes.  If you intend to have NFS always available, it would be simpler to build it in than to have a permanently loaded module.

----------

## hujuice

That makes sense.

My problem, anyway, was generated by some changes (in baselayout? in nfs-utils? in the kernel?).

I'm completely sure that the modular NFS solution and the sysctl.conf management worked until a handful of weeks ago.

Also, I just updated the gentoo-wiki.com related page, that simply suggested the sysctl.conf way.

Regards,

HUJuice

----------

