Locking down rpcbind on OpenSolaris
Every now and again one is asked how one can lock down rpcbind from with a shared-ip zone without being able to use ipfilter from within the zone. Fortunately tcpwrappers save the day by allowing us to enable rcpbind to use the tcpwrapper functionality to lockdown who can connect to port 111 (the port which Sun RPC use).
You have run rpcinfo against a zone and it returns numerous lines saying that rpcbind and additional rpc based serivces are available remotely.
rpcinfo -p IP.AD.DR.ESS
program vers proto port service
100000 4 tcp 111 rpcbind
100000 3 tcp 111 rpcbind
100000 2 tcp 111 rpcbind
100000 4 udp 111 rpcbind
100000 3 udp 111 rpcbind
100000 2 udp 111 rpcbind
100024 1 udp 62025 status
100024 1 tcp 36015 status
100133 1 udp 62025
100133 1 tcp 36015
100021 1 udp 4045 nlockmgr
100021 2 udp 4045 nlockmgr
100021 3 udp 4045 nlockmgr
100021 4 udp 4045 nlockmgr
100021 1 tcp 4045 nlockmgr
100021 2 tcp 4045 nlockmgr
100021 3 tcp 4045 nlockmgr
100021 4 tcp 4045 nlockmgr
For tcpwrappers to allow and deny traffic to rpcbind, we need to create two files namely hosts.deny and hosts.allow both under the /etc directory.
echo "rpcbind: ALL" >> /etc/hosts.deny
echo "rcpbind: 10. 192.168. 127." >> /etc/hosts.allow
Once this has been done, we are now ready to enable tcpwrappers to disallow access to rpcbind:
svccfg -s rpc/bind setprop config/enable_tcpwrappers=true
svcadm refresh rpc/bind
One can also run a quick script which I quickly put together that will run the four commands mentioned above for you:
curl http://github.com/jacques/adminscripts/raw/master/lockdownrpcbind.sh | sh -x
One can verify that rcp/bind is sitting behind tcpwrappers using by running:
# svcprop -p config/enable_tcpwrappers rpc/bind
true
And remotely one can verify this by running:
# rpcinfo -p IP.AD.DR.ESS
rpcinfo: can't contact portmapper: RPC: Rpcbind failure - RPC: Failed (unspecified error)