View, close and open firewall commands under Linux

View, close and open firewall commands under Linux

1) Permanent effect, will not be restored after restart 
: chkconfig iptables on Close: chkconfig iptables off 
2) Immediate effect, restore 
open after restart: service iptables start Close: service iptables stop 
It should be noted that for other services under Linux On and off operations can be performed with the above commands. 
When the firewall is turned on, make the following settings, open the relevant ports, modify the /etc/sysconfig/iptables file, and add the following content: 
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp - -dport 80 -j ACCEPT 
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
3) View firewall status
chkconfig iptables --list


 
 
Turning off the firewall from the configuration menu does not work. Simply do not install the firewall during installation to

check the firewall status :
/etc/init.d/iptables status

Temporarily turn off the firewall :
/etc/init.d/iptables stop

Disable the firewall in the system Start
/sbin/chkconfig --level 2345 iptables off at startup

Restart iptables :
/etc/init.d/iptables restart

Off topic:
BT or mule speed is slow, no need to close the firewall, just open the corresponding port
in the file
/etc /sysconfig/iptables
adds a line similar to this in the original configuration of the system: RH-Firewall-1-INPUT rule chain:
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 39764 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m udp -p udp --dport 39764 -j ACCEPT
If the original -j REJECT statement is found, the above two sentences should be placed It

takes effect after rebooting  in front of it
: chkconfig iptables on 
关闭: chkconfig iptables off 或者 /sbin/chkconfig --level 2345 iptables off

2) 即时生效,重启后失效

service 方式
开启: service iptables start 
关闭: service iptables stop

iptables方式
查看防火墙状态:
/etc/init.d/iptables status

暂时关闭防火墙:
/etc/init.d/iptables stop

重启iptables:
/etc/init.d/iptables restart

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326446042&siteId=291194637