What is port map why is it required ?

What is port map why is it required ?

Linux uses a combination of kernel-level support and continuously running daemon processes to provide NFS file sharing, however, NFS support must be enabled in the Linux kernel in order to function. NFS uses Remote Procedure Calls (RPC) to route requests between clients and servers, meaning that the portmap service must be enabled and active at the proper runlevels for NFS communication to occur. Working with portmap, the following processes ensure that a given NFS connection is allowed and may proceed without error:

NFS and portmap

NFS relies upon remote procedure calls (RPC) to function. The portmap service is required to map RPC requests to the correct services. RPC processes notify portmap when they start, revealing the port number they are monitoring and the RPC program numbers they expect to serve. The client system then contacts portmap on the server with a particular RPC program number. portmap then redirects the client to the proper port number to communicate with its intended service.

Because RPC-based services rely on portmap to make all connections with incoming client requests, portmap must be available before any of these services start. If, for some reason, the portmap service unexpectedly quits, restart portmap and any services running when it was started.

The portmap service can be used with TCP wrappers' hosts access files (/etc/hosts.allow and /etc/hosts.deny) to control which remote systems are permitted to use RPC-based services on the server. See Chapter 15 TCP Wrappers and xinetd for more information. Access control rules for portmap will affect all RPC-based services. Alternatively, it is possible to specify each of the NFS RPC daemons to be affected by a particular access control rule. The man pages for rpc.mountd and rpc.statd contain information regarding the precise syntax for these rules.


The rpcinfo command shows each RPC-based service with its port number, RPC program number, version, and IP protocol type (TCP or UDP).


o make sure the proper NFS RPC-based services are enabled for portmap, use the rpcinfo -p command:

  program vers proto   port
100000 2 tcp 111 portmapper
100000 2 udp 111 portmapper
100024 1 udp 1024 status
100024 1 tcp 1024 status
100011 1 udp 819 rquotad
100011 2 udp 819 rquotad
100005 1 udp 1027 mountd
100005 1 tcp 1106 mountd
100005 2 udp 1027 mountd
100005 2 tcp 1106 mountd
100005 3 udp 1027 mountd
100005 3 tcp 1106 mountd
100003 2 udp 2049 nfs
100003 3 udp 2049 nfs
100021 1 udp 1028 nlockmgr
100021 3 udp 1028 nlockmgr
100021 4 udp 1028 nlockmgr

The -p option probes the portmapper on the specified host or defaults to localhost if no specific host is listed. Other options are available from the rpcinfo man page.

From this output, it is apparent that various NFS services are running. If one of the NFS services does not start up correctly, portmap will be unable to map RPC requests from clients for that service to the correct port. In many cases, restarting NFS as root (/sbin/service nfs restart) will cause those service to correctly register with portmap and begin working.

7 comments:

  1. Here am getting basic info about how portmap is working.

    ReplyDelete
  2. Thank you for this info about PORTMAP & RPC. Pretty straight forward.

    ReplyDelete
  3. Thanks, info was very helpful in understanding portmap.

    ReplyDelete
  4. portmap is NOT required for NFSv4 (https://www.centos.org/docs/5/html/Deployment_Guide-en-US/ch-nfs.html). NFSv3 and backward required the portmapper. Please get your facts right.

    ReplyDelete
  5. Hi Vaseem,

    In debt to you for making my learning on the What is port map why is it required ?area so hassle-free! I lay my faith on your writings.

    When I first got Linux Ubuntu 12.04 LTS it used to only display on the VGA connection and not HDMI, a few days later when I discovered how to install my video card's drivers for Linux, I installed it and it immediately switched to the HDMI connection....

    It was cool to see your article pop up in my google search for the process yesterday. Great Guide.
    Keep up the good work!

    Thank you,
    Kevin

    ReplyDelete
  6. how we can find out portmap logs and usage.can any one help me

    ReplyDelete
  7. how we can find out portmap logs and usage can any help

    ReplyDelete