Home > Operation and Maintenance > Linux 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
Release: 2023-01-04 09:38:20
Original
164959 people have browsed it

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
Copy after login

# Stop the firewall

service iptables stop
Copy after login

# Start the firewall

service iptables start
Copy after login

# Restart the firewall

service iptables restart
Copy after login
Copy after login

# Permanently close the firewall

chkconfig iptables off
Copy after login

# Restart after permanent shutdown

chkconfig iptables on  
Copy after login

2. Open port 80

vim /etc/sysconfig/iptables
Copy after login

# Add the following code

-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
Copy after login

Save and exit and then restart the firewall

service iptables restart
Copy after login
Copy after login

2. Firewall firewall

1. Check the firewall service status

systemctl status firewalld
Copy after login

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
Copy after login

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

# Open

service firewalld start
Copy after login

# Restart

service firewalld restart
Copy after login

# Close

service firewalld stop
Copy after login

4. Check the firewall rules

firewall-cmd --list-all
Copy after login

5. Query, open and close the port

# Check whether the port is open

firewall-cmd --query-port=8080/tcp
Copy after login

# Open port 80

firewall-cmd --permanent --add-port=80/tcp
Copy after login

# Remove port

firewall-cmd --permanent --remove-port=8080/tcp
Copy after login

#Restart the firewall (restart the firewall after modifying the configuration)

firewall-cmd --reload
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template