Portmapper question

der Mouse mouse at thunder.mcrcim.mcgill.edu
Thu Jun 6 23:11:51 AEST 1991


In article <33719 at shamash.cdc.com>, ldk at raistlin (ld kelley x-6857) writes:

> When the portmapper assigns ports to programs that are registering,
> how does it keep from using ports that are reserved (via the services
> file) for other programs?

You don't say what sort of system you're talking about, so I'll use the
handiest one I have access to which has a portmapper.  This is a Sun
running SunOS 4.1.

With that out of the way...the portmapper *doesn't* assign ports;
clients tell it what port they're listening on.

Clients then come in two flavors: those that use a port dedicated to
their use and those that use just any old port.  (The former are rare,
precisely because of the portmapper's existence; NFS is the only one
that comes to mind, and that for historical reasons.)  Your question
doesn't really apply to the former, and for the latter, it's avoided
because when the client binds to "just any port", the kernel picks the
port, and it picks ports from a restricted range.  From <netinet/in.h>:

	/*
	 * Ports < IPPORT_RESERVED are reserved for
	 * privileged processes (e.g. root).
	 * Ports > IPPORT_USERRESERVED are reserved
	 * for servers, not necessarily privileged.
	 */
	#define IPPORT_RESERVED         1024
	#define IPPORT_USERRESERVED     5000

Thus, by implication, the kernel will never assign a port number
outside of [1024..5000].  Now if only we had some assurance that
everybody used the same technique with the same numbers....

					der Mouse

			old: mcgill-vision!mouse
			new: mouse at larry.mcrcim.mcgill.edu



More information about the Comp.unix.wizards mailing list