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.
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 the open ports that the system is listening to and confirm with netstat. As we see port 143 is open.
How to check whether the firewall is turned on or not? Centos6 uses service iptables status to check
##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 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. View iptables rules If you want to view the rules currently running by iptables, use iptables -L to list them. As shown in this column, my Linux host port 143 firewall is open to the outside world. Test whether the firewall is OK through a computer on the same network segment. Telnet linux host IP 143 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 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.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!