Home>Article>Operation and Maintenance> What are the methods to check the firewall status in Linux?

What are the methods to check the firewall status in Linux?

coldplay.xixi
coldplay.xixi Original
2020-12-30 10:50:12 164661browse

How to check the firewall status in Linux: 1. iptables firewall, check the firewall status, the code is [service iptables status]; 2. Firewall firewall, the code is [firewall-cmd --state].

What are the methods to check the firewall status in Linux?

The operating environment of this tutorial: linux7.3 system, DELL G3 computer.

How to check the firewall status in Linux:

1. iptables firewall

1. Basic operations

# Check the 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

Save and exit and then restart the firewall

service iptables restart

2. Firewall firewall

1. Check the firewall service status

systemctl status firewalld

AppearActive: active (running)Highlighted means it is started state.

AppearsActive: inactive (dead)Gray means stop, you can also read the word.

2. Check the status of firewall

firewall-cmd --state

3. Open, restart, close, firewalld.service service

# Open

service firewalld start

# Restart

service firewalld restart

# Close

service firewalld stop

4. Check the firewall rules

firewall-cmd --list-all

5. Query, open and close the port

# Check whether the port is open

firewall-cmd --query-port=8080/tcp

# Open port 80

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 explanation

1.firwall-cmd: It is a tool provided by Linux to operate the firewall;

2.permanent: Indicates that it is set to persistent;

3 ,add-port: identifies the added port;

Related learning recommendations:linux video tutorial

The above is the detailed content of What are the methods to check the firewall status in Linux?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn