FirewallD is a frontend controller / wrapper for iptables used to implement persistent network traffic rules. Working with FirewallD has two main differences compared to directly controlling iptables (Ref: Introduction to FirewallD on CentOS):
FirewallD uses zones and services instead of chain and rules.
It manages rulesets dynamically, allowing updates without breaking existing sessions and connections.
FirewallD is included by default with CentOS 7 and is enabled by default.
firewall-cmd
firewall-cmd is the command line client of the FirewallD. It provides interface to manage runtime and permanent configuration.
Firewalld uses two configuration sets: Runtime and Permanent. Runtime configuration changes are not retained on reboot or upon restarting FirewallD whereas permanent changes are not applied to a running system.
Zones
Right after the minimal install of CentOS on pulpo-admin, the default zone is public:
and all active network interfaces are bound to the public zone:
But that is not enough. The interface is under control of NetworkManager. Be default, all interfaces are bound to the default zone, which is public. To really permanently bind eno1 to the trusted zone, we need to modify NetworkManager configuration. We can use nmcli, Network Manager Command Line Interface, to do so.
Alternatively, we can change the zone of eno1 by editing the file /etc/sysconfig/network-scripts/ifcfg-eno1. Add ZONE=trusted to the file; then run nmcli con reload.
Verify that eno1 is now bound to trusted:
And we now have 2 active zones:
Fail2ban
Fail2ban scans log files and bans IP addresses that makes too many password failures. It updates firewall rules to reject the IP address. Fail2Ban can read multiple log files such as sshd or Apache web server ones.