Centos6、Centos7防火墙基本操作整理

Centos7:
查看防火墙状态:
firewall-cmd --state
开启防火墙:
systemctl start firewalld.service
关闭防火墙(重启失效):
systemctl stop firewalld.service
开机不启动防火墙:
systemctl disable firewalld.service
开机启动防火墙:
systemctl enable firewalld.service
重启防火墙:
firewall-cmd --reload
查看已开放端口:
firewall-cmd --list-ports
查看指定端口状态(以1521端口为例):
firewall-cmd --zone=public --query-port=1521/tcp
开放指定端口:
firewall-cmd --zone=public --add-port=1521/tcp --permanent
关闭指定端口:
firewall-cmd --zone=public --remove-port=1521/tcp --permanent
开放、关闭端口注意:
重启防火墙才生效
--permanent:永久生效,否则重启失效
Centos6:
查看防火墙状态:
service iptables status
开启防火墙:
service iptables start
关闭防火墙(重启失效):
service iptables stop
开机不启动防火墙:
chkconfig iptables off
开机启动防火墙:
chkconfig iptables on
查看端口状态:
/etc/init.d/iptables status
重启防火墙
service iptables restart
开放指定端口:
修改 /etc/sysconfig/iptables 文件:
添加
-A INPUT -m state --state NEW -m tcp -p tcp --dport 1521 -j ACCEPT
保存重启防火墙

上一篇:Unable to parse template "Class" Error message: Selected class file name 'MyLocaleResolver.java' mapped to not java file type 'Velocity template'


下一篇:python sys.path.append()