Home  >  Article  >  Operation and Maintenance  >  Check if the firewall is turned on in linux

Check if the firewall is turned on in linux

藏色散人
藏色散人Original
2021-01-25 15:57:3252185browse

How to check whether the firewall is turned on in Linux: First use the "ifconfig" or "ip addr" command to check the IP of the Linux host; then use the "service iptables status" command to check whether the firewall is turned on.

Check if the firewall is turned on in linux

Demo environment in the article: centos6 system, Dell G3 computer.

Recommendation: "linux video tutorial"

linux check whether the firewall is turned on and delete iptables rules

Preparation

First confirm the IP

For the test later, we first confirm the IP of the linux host. You can use ifconfig or ip addr to view.

Check if the firewall is turned on in linux

Check the open ports that the system is listening to and confirm with netstat. As we see port 143 is open.

Check if the firewall is turned on in linux

How to check whether the firewall is turned on or not? Centos6 uses service iptables status to check

Check if the firewall is turned on in linux

##centos7 system iptables is called firewalld. Use systemctl status firewalld to check whether it is started. As shown in the figure, it is already running

Check if the firewall is turned on in linux

Restart the firewall service. Since the current release version centos7 is the mainstream, the following part will introduce the usage of the firewall of centos7. Restarting and closing the firewall service will not prompt you. Unless there is an error configuration.

Check if the firewall is turned on in linux

View iptables rules If you want to view the rules currently running by iptables, use iptables -L to list them.

Check if the firewall is turned on in linux

As shown in this column, my Linux host port 143 firewall is open to the outside world.

Check if the firewall is turned on in linux

Test whether the firewall is OK through a computer on the same network segment. Telnet linux host IP 143

Check if the firewall is turned on in linux

Delete iptables Rules If you delete the iptables rules, you can test and see that port 143 is unavailable. The command is

firewall-cmd --zone= public --remove-port=143/tcp --permanent

Check if the firewall is turned on in linux

View the port number input allowed by the firewall The command firewall-cmd --zone=public --list-ports can view the port numbers outside the firewall list of external network computers and delete them accordingly. If you want to cancel deletion of iptables rules, you can directly stop or disable the firewalld service.

Check if the firewall is turned on in linux

The above is the detailed content of Check if the firewall is turned on 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