RPCbind Service Failure on CentOS 7.4
Issue Summary
After rebooting a virtual machine, NFS mounts configured in /etc/rc.local failed to execute properly.
Root Cause Analysis
The root cause was that the rpcbind service failed to start, which prevented NFS mounts from functioning. Attempting to restart the service reuslted in the following error:
# systemctl restart rpcbind
A dependency job for rpcbind.service failed. See 'journalctl -xe' for details.
The error message indicates that a dependent service required by rpcbind was not running. Examining the service definition revealed the dependency:
# cat /usr/lib/systemd/system/rpcbind.service
[Unit]
Description=RPC bind service
Requires=rpcbind.socket
After=systemd-tmpfiles-setup.service
[Service]
Type=forking
EnvironmentFile=/etc/sysconfig/rpcbind
ExecStart=/sbin/rpcbind -w $RPCBIND_ARGS
[Install]
Also=rpcbind.socket
The service depends on rpcbind.socket. Attempting to restart the socket also failed:
# systemctl restart rpcbind.socket
Job for rpcbind.socket failed. See "systemctl status rpcbind.socket" and "journalctl -xe" for details.
# systemctl status rpcbind.socket
● rpcbind.socket - RPCbind Server Activation Socket
Loaded: loaded (/usr/lib/systemd/system/rpcbind.socket; enabled; vendor preset: enabled)
Active: failed (Result: resources)
Listen: /var/run/rpcbind.sock (Stream)
[::]:111 (Stream)
0.0.0.0:111 (Stream)
May 22 10:25:30 hostname systemd[1]: Starting RPCbind Server Activation Socket.
May 22 10:26:56 hostname systemd[1]: rpcbind.socket failed to listen on sockets: Address family not supported by protocol
May 22 10:26:56 hostname systemd[1]: Failed to listen on RPCbind Server Activation Socket.
The error message Address family not supported by protocol suggests a protocol compatibility issue. Inspecting the socket configuration:
# cat /usr/lib/systemd/system/rpcbind.socket
[Unit]
Description=RPCbind Server Activation Socket
[Socket]
ListenStream=/var/run/rpcbind.sock
ListenStream=[::]:111
ListenStream=0.0.0.0:111
BindIPv6Only=ipv6-only
[Install]
WantedBy=sockets.target
The socket configuration binds to IPv6 addresses ([::]:111), but the system had IPv6 disabled. Checking the kernel parameters:
# cat /etc/sysctl.conf | grep ipv6
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
IPv6 was disabled at the kernel level, causing the socket to fail when attempting to bind to IPv6 addresses.
Solution 1: Enable IPv6
Modify /etc/sysctl.conf to re-enable IPv6 support:
net.ipv6.conf.all.disable_ipv6 = 0
net.ipv6.conf.default.disable_ipv6 = 0
Apply the changes:
# sysctl -p
Restart the service:
# systemctl restart rpcbind
The service should now start successfully, and NFS mounts can proceed normally.
Solution 2: Modify Socket Configuration
Alternatively, modify the socket unit file to remove IPv6 dependencies:
# cat /usr/lib/systemd/system/rpcbind.socket
[Unit]
Description=RPCbind Server Activation Socket
[Socket]
ListenStream=/var/run/rpcbind.sock
[Install]
WantedBy=sockets.target
After saving the changes, restart the service. NFS mounts will function correctly once rpcbind is operational.