Firewalld is the default firewall software for CentOS 7/8, Fedora, and other Linux distributions based on Red Hat. This quick start guide lists some common commands for Firewalld, enabling system administrators to rapidly master its usage.
Checking if Firewalld is Running:
$ firewall-cmd --state
running
Retrieve Active Zones:
$ firewall-cmd --get-active-zones
public
interfaces: ens3
List Running Ports and Services (for the 'public' zone):
$ firewall-cmd --zone=public --list-ports
7000-8000/tcp
$ firewall-cmd --zone=public --list-services
cockpit dhcpv6-client ssh
Enabling SSH Access (choose one of the following two methods):
$ firewall-cmd --add-service=ssh --permanent
$ firewall-cmd --add-port=22/tcp --permanent
$ firewall-cmd --reload
Permanent and Temporary Modes:
The permanent mode requires the addition of the --permanent option when executing commands, and the changes will take effect only after running firewall-cmd --reload or restarting the server. The temporary mode does not require any additional options during command execution and takes effect immediately. However, the settings will be lost after a server reboot. For instance, to permanently allow SSH access, execute the following command.
$ firewall-cmd --zone=public --add-service=ssh --permanent
$ firewall-cmd --reload
Disabling and Stopping Firewalld:
# systemctl stop firewalld.service
# systemctl disable firewalld.service
For more information, refer to the official Firewalld documentation.
23-02-2024 02:02:07
22-02-2024 03:19:32
22-02-2024 03:16:03
22-02-2024 03:14:03
22-02-2024 03:11:58