Method Example for linux Firewall Status Viewing
- 2021-07-24 12:07:51
- OfStack
The Method of linux Firewall State Viewing
1. Basic operation
# View firewall status
service iptables status
# Stop the firewall
service iptables stop
# Start the firewall
service iptables start
# Restart the firewall
service iptables restart
# Permanently close the firewall
chkconfig iptables off
# Restart after permanent shutdown
chkconfig iptables on
2. Open Port 80
vim /etc/sysconfig/iptables
# Add the following code
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
Restart firewall after saving exit
service iptables restart
2. firewall Firewall
1. View firewall service status
systemctl status firewalld
When Active: active (running) is highlighted, it indicates that it is in the started state.
The appearance of Active: inactive (dead) gray means stop, and the words will do.
2. View the status of firewall
firewall-cmd --state
3. Open, restart and close, firewalld. service service
# Open service firewalld start# Restart service firewalld restart# Shut down service firewalld stop
4. View firewall rules
firewall-cmd --list-all
5. Query, open and close ports
# Query whether the port is open
firewall-cmd --query-port=8080/tcp
# Open 80 Port
firewall-cmd --permanent --add-port=80/tcp
# Remove Port
firewall-cmd --permanent --remove-port=8080/tcp
# Restart the firewall ( Restart the firewall after modifying the configuration )
firewall-cmd --reload
Parameter interpretation
1. firwall-cmd: It is a tool provided by Linux to operate firewall;
2,--permanent: indicates that it is set to persistence;
3.--add-port: Identify the added port;