linux firewall queries and Configuration

A, iptables firewall
1, the basic operation

# Check firewall status

service iptables status  

# Stop firewall

service iptables stop  

# Enable the firewall

service iptables start  

# Restart the firewall

service iptables restart  

# Permanently turn off the firewall

chkconfig iptables off  

# Permanently closed after restart

chkconfig iptables on  

2, open port 80

Vim / etc / sysconfig / iptables
# adding the following code
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
Save and exit reboot the firewall

service iptables restart
two, firewall firewall
1, see the firewall service status

systemctl status firewalld

Appears Active: active (running) cut highlighted it means is activated state.

Appears Active: inactive (dead) in gray stop, look at the words will do.
2, see the firewall status

cmd---state Firewall
3, turn on, restart, shut down, firewalld.service service

# Enable
Service firewalld Start
# Restart
Service firewalld restart
# Close
Service firewalld STOP
4, View firewall rule

All --list-cmd-Firewall
5, query, open and closed ports

# Query whether the port open
Firewall-cmd --query-Port = 8080 / tcp
# 80 open ports
Firewall-cmd = --permanent --add-Port 80 / tcp
# remove port
firewall-cmd --permanent --remove- = 8080 Port / TCP
# restart firewall (firewall modified configured to restart)
firewall-cmd --reload

# of parameters
1, firwall-cmd: the operation is a tool provided for Linux firewall;
2, - Permanent: expressed to durable;
. 3, - the Add-port: port identification added;

 

Original: https: //blog.csdn.net/bbwangj/article/details/74502967

Guess you like

Origin www.cnblogs.com/Tomlin/p/12583699.html