How to block certain IP address from bitcoind or using ufw
You can use the rpcallowip feature in your bitcoin.conf to whitelist IP addresses.
https://bitcoin.org/en/release/v0.10.0#rpc-access-control-changes