[comp.sys.sun] nfs udp ports?

rusty%garnet.Berkeley.EDU@violet.berkeley.edu (01/28/89)

We have a fileserver whose filesystems are mounted by a large number of
clients on campus.  I would like to gather statistics about how much nfs
traffic is is being generated by each client.  NNStat seems like a good
way to do this.  I need to tell NNStat the udp source and destination
ports for nfs in order to collect these statistics but I can't find this
information written down anywhere.  Does anybody know what port numbers
nfs uses?

[[ According to the NFS(4P) manual page, NFS uses remote procedure calls
(RPC) built on top of the external data representation (XDR) protocol.
That's TCP and UDP port 111, according to /etc/services.  But monitoring
that port will get all RCP traffic, not just NFS traffic.  --wnl ]]

guy@uunet.uu.net (Guy Harris) (01/31/89)

>According to the NFS(4P) manual page, NFS uses remote procedure calls
>(RPC) built on top of the external data representation (XDR) protocol.
>That's TCP and UDP port 111, according to /etc/services.  But monitoring
>that port will get all RCP traffic, not just NFS traffic.  --wnl

Nope.  The entry in "/etc/services" is a bit confusing.  UDP and TCP ports
111 are the ports that the *portmapper* RPC service uses.  Other RPC
services get their own unique ports; they register the port number with
the portmapper service (by talking RPC to port 111 on their own machine),
so that if somebody wants to talk to program 100008, version 1, on machine
"bootme", they send an RPC request to machine "bootme"s UDP or TCP port
111 to ask the portmapper what the port for that program/version number
is.

>I need to tell NNStat the udp source and destination ports for nfs in
>order to collect these statistics but I can't find this information
>written down anywhere.  Does anybody know what port numbers
>nfs uses?

NFS is program number 100003, currently at version 2.  At present, it
always uses UDP port number 2049; however, recent implementations *do*
register this with the portmapper (I think the "nfsd" program, which is a
regular user-mode program, registers the NFS service with the portmapper
just before it takes a deep breath and dives into the kernel NFS server
code, never to return).  I would recommend using the portmapper RPC
service to get the port number, and only if the portmappers says "nobody
here by that name" should you fall back and use a hardcoded port 2049.

I think the version 3 NFS service will *not* use a hardcoded port number;
you'll have to go to the portmapper to find the port number. 

[[ Sorry.  Found it later while digging around in the manuals.  Look in
the "Network Programming" manual, chapter 7, page 169.  Also (as was
mentioned on "sun-nets") the command "/usr/etc/rpcinfo -p" will give you a
list of all the ports (tcp and udp) that rpc knows it's using, including
the one for nfs (at least under 4.0 it does).  --wnl ]]