linux防火墙设置常用命令

1.永久性生效,重启后不会复原

开启: chkconfig iptables on

关闭: chkconfig iptables off

2.即时生效,重启后复原

开启: service iptables start

关闭: service iptables stop


3.在不关闭防火墙的情况下选择性开放端口访问权限

直接编辑/etc/sysconfig/iptables
-A INPUT -p tcp -m tcp --dport 8080 -j ACCEPT
保存在前面部分
再重启:
service iptables restart

4.查询端口占用情况:

netstat -anp | grep portno(例如:netstat –apn | grep 80)

原文地址:https://www.cnblogs.com/alan0521/p/10262436.html