firewall 安装

Follow the below steps for the default installation of firewalld service in centos 7.

Firstfirewalld is pre-installed in centos 7. If firewalld is not installed, install it. To verify and install, issue the below commands.

rpm -qa firwalld
# expected output: firewalld-0.6.3-2.el7_7.2.noarch

# if not installed, install it
yum install firewalld

Secondfirewalld mostly runs as a service. Check the service exists on the host.

ll /usr/lib/systemd/system | grep firewalld
# expected output: -rw-r--r-. 1 root root 674 Jan 30 2018 firewalld.service
# OR
ll /etc/systemd/system | grep firewalld

Third: Verify firawalld service is running and enabled.

If the service is running and it’s not enabled, every restart will bring it down. Use the below command.

# check the status of the service (running and eanbled)
systemctl status firewalld

# if the service is not running, start it
systemctl start firewalld

# if the service has exited , restart it(check for error if any)
systemctl restart firewalld

# if the service is not enabled, enable it
systemctl enable firewalld


firewall 使用


firewall-cmd –zone=public –add-port=2181/tcp –permanent

firewall-cmd –zone=public –add-port=2888/tcp –permanent

firewall-cmd –zone=public –add-port=3888/tcp –permanent

firewall-cmd –reload