CentOS 7.0 firewall and centos7.0 Firewall
CentOS 7.0 uses a firewall by default.
In addition, common firewalls include iptables firewalls.
Official firewall documentation: https: // Firewall
Firewall Configuration: firewalld Configuration
Stored in Various XML files in/usr/lib/firewalld/and/etc/firewalld.
1. Basic operations
Service firewalld restart service firewalld start enable service firewalld stop disable
2. view the Firewall Service Status
systemctl status firewall
View the Firewall Status
firewall-cmd --state
View firewall rules
firewall-cmd --list-all
Install the firewall command:
yum install firewalld firewalld-config
Common firewall port enabling commands:
firewall-cmd --zone=public --add-port=80/tcp --permanentfirewall-cmd --zone=public --add-port=443/tcp --permanentfirewall-cmd --zone=public --add-port=22/tcp --permanentfirewall-cmd --zone=public --add-port=21/tcp --permanentfirewall-cmd --zone=public --add-port=53/udp --permanent
Common firewall port shutdown commands:
firewall-cmd --zone=public --remove-port=80/tcp --permanentfirewall-cmd --zone=public --remove-port=443/tcp --permanentfirewall-cmd --zone=public --remove-port=22/tcp --permanentfirewall-cmd --zone=public --remove-port=21/tcp --permanentfirewall-cmd --zone=public --remove-port=53/udp --permanent
Batch add port range
firewall-cmd --zone=public --add-port=4400-4600/udp --permanentfirewall-cmd --zone=public --add-port=4400-4600/tcp --permanent
Enable the firewall command:
systemctl start firewalld.service
Restart firewall command:
Firewall-cmd -- reload or service firewalld restart
View the port list:
firewall-cmd --permanent --list-port
Disable Firewall
systemctl stop firewalld
Set startup
systemctl enable firewalld
Stop and disable startup
sytemctl disable firewalld
View status
Systemctl status firewalld or firewall-cmd -- state
3. How to add a port
Firwall-cmd -- permanent -- add-port = 9527/tcp 1, firwall-cmd: A tool provided by Linux to operate firewall; 2, -- permanent: indicates that the setting is persistent; 3. -- add-port: identifies the added port;
Reload takes effect. Set firewall-cmd -- reload.