Block an IP address in firewall-cmd

Sometimes you need to block an IP address (or a range of IP addresses) from accessing your machine. In this case firewall-cmd can help you through these commands:

firewall-cmd --permanent --add-rich-rule="rule family='ipv4' source address='xxx.xxx.xxx.xxx/xx' drop"
firewall-cmd --reload
firewall-cmd --list-all

And finally, if you decide to remove this rule, you can use these commands:

firewall-cmd --permanent --remove-rich-rule="rule family='ipv4' source address='xxx.xxx.xxx.xxx/xx' drop"
firewall-cmd --reload
firewall-cmd --list-all