Secure the rpcbind service

You can secure rpcbind by restricting access to all networks and defining specific exceptions by using firewall rules on the server.

Before you begin

  • The rpcbind package is installed.
  • The firewalld package is installed and the service is running.

About this task

The rpcbind service is a dynamic port-assignment daemon for remote procedure calls (RPC) services such as Network Information Service (NIS) and Network File System (NFS). Because it has weak authentication mechanisms and can assign a wide range of ports for the services it controls, secure rpcbind.

Note
  • The rpcbind service is required on NFSv3 servers.
  • The rpcbind service is not required on NFSv4.

Procedure

  1. Add firewall rules, for example:
    • Limit TCP connection and accept packages only from the 192.168.0.0/24 host on port 111:
      # firewall-cmd --add-rich-rule='rule family="ipv4" port port="111" protocol="tcp" source address="192.168.0.0/24" invert="True" drop'
    • Limit TCP connection and accept packages only from local host on port 111:
      # firewall-cmd --add-rich-rule='rule family="ipv4" port port="111" protocol="tcp" source address="127.0.0.1" accept'
    • Limit UDP connection and accept packages only from the 192.168.0.0/24 host on port 111:
      # firewall-cmd --permanent --add-rich-rule='rule family="ipv4" port port="111" protocol="udp" source address="192.168.0.0/24" invert="True" drop'

      To make the firewall settings permanent, use the --permanent option when adding firewall rules.

  2. Reload the firewall to apply the new rules:
    # firewall-cmd --reload

Results

  • List the firewall rules:
    # firewall-cmd --list-rich-rule
    rule family="ipv4" port port="111" protocol="tcp" source address="192.168.0.0/24" invert="True" drop
    rule family="ipv4" port port="111" protocol="tcp" source address="127.0.0.1" accept
    rule family="ipv4" port port="111" protocol="udp" source address="192.168.0.0/24" invert="True" drop
  • If NFS clients cannot connect after applying the firewall rules, verify that the client IP addresses are within the allowed subnet:
    # firewall-cmd --list-all

    Check that the rich rules allow the client’s source address.

  • If clients from the allowed subnet still cannot connect, verify that the rpcbind service is running:
    # systemctl status rpcbind
  • If firewall changes are not taking effect, verify that the rules were made permanent:
    # firewall-cmd --permanent --list-rich-rules

    If the rules are missing, re-add them with the --permanent option and reload the firewall.

  • If you added rules without --permanent and then reloaded, the rules are lost. Use --runtime-to-permanent to save current runtime rules:
    # firewall-cmd --runtime-to-permanent