1.任意运行一条iptables防火墙规则配置命令:html
iptables -P OUTPUT ACCEPT
2.对iptables服务进行保存:linux
service iptables save
3.重启iptables服务:vim
service iptables restart
查看防火墙的状态:centos
[root@localhost ~]# service iptable status tcp
保存退出后重启防火墙spa
[root@localhost ~]# service iptables restart
关闭防火墙.net
[root@localhost ~]#servcie iptables stop --临时关闭防火墙rest
[root@localhost ~]#chkconfig iptables off --永久关闭防火墙 code
centos 6 开放80端口htm
vim /etc/sysconfig/iptables # 加入以下代码,只须要把端口修改一下就变成了其余的,而后service iptables restart重启
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
CentOS 7.0默认使用的是firewall做为防火墙,这里改成iptables防火墙步骤。
一、中止并屏蔽firewalld服务
systemctl stop firewalld systemctl mask firewalld
二、安装iptables-services软件包
yum install iptables-services
三、在引导时启用iptables服务
systemctl enable iptables
四、启动iptables服务
systemctl start iptables
五、保存防火墙规则
service iptables save 或 /usr/libexec/iptables/iptables.init save
另外:管理iptables服务
systemctl [stop|start|restart] iptables
centOS 7防火墙:
firewall-cmd --query-port=8080/tcp # 查询端口是否开放
firewall-cmd --permanent --add-port=80/tcp # 开放80端口
firewall-cmd --permanent --remove-port=8080/tcp # 移除端口
[root@localhost ~]# systemctl stop firewalld.service #中止/关闭firewall
[root@localhost ~]# systemctl disable firewalld.service #禁止firewall开机启动
[root@localhost ~]# firewall-cmd --reload #重启
服务
[root@localhost ~]# systemctl enable firewalld.service #在开机时启用一个服务
[root@localhost ~]# systemctl disable firewalld.service #在开机时禁用一个服务
[root@localhost ~]# systemctl is-enabled firewalld.service #查看服务是否开机启动
[root@localhost ~]# systemctl list-unit-files|grep enabled #查看已启动的服务列表
[root@localhost ~]# firewall-cmd --list-ports #查看防火墙的端口有没有打开
查看firewall的状态
[root@localhost ~]# systemctl status firewalld #查看防火墙状态
[root@localhost ~]# firewall-cmd --state #查看默认防火墙状态(关闭后显示notrunning,开启后显示running)
[root@localhost ~]# systemctl list-unit-files | grep firewalld.service #检查防火墙的状态
firewalld.service disabled #防火墙处于关闭状态
注意:
一、打开全部的端口
iptables -P OUTPUT ACCEPT
二、关闭有的端口
iptables -P INPUT ACCEPT
其余参考连接:http://songbgi.iteye.com/blog/1703583
https://www.linuxidc.com/Linux/2016-12/138979.htm
RedHat 7:https://www.cnblogs.com/shiguotao-com/p/4562137.html
iptables其余的使用方法:https://www.linuxidc.com/Linux/2015-05/117473.htm