CentOS 7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙。
1、关闭firewall:
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
2、安装iptables防火墙
yum install iptables-services #安装
vi /etc/sysconfig/iptables #编辑防火墙配置文件
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
:wq! #保存退出
systemctl restart iptables.service #最后重启防火墙使配置生效
systemctl enable iptables.service #设置防火墙开机启动
相关推荐
Centos离线安装iptables
centos6 iptables常用操作, 规则的新增。
阿里云Centos配置iptables防火墙.docx
centos7 iptables-services-1.4.21-17.el7.x86_64.rpm 安装包 下载
CentOS 7 iptables的安装及使用-附件资源
CentOS 安装使用Iptables,1.安装iptables-services2.设置开机启动3.配置说明
主要为大家详细介绍了阿里云Centos配置iptables防火墙教程,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
系统升级到CentOS 7后总感觉iptables怪怪的,比如不管怎么保存重启后都被初始化一下,即便我最后发大绝招启动时候加命令: 首先iptables-save > /etc/iptables.rules保存当前状态。 然后再在/etc/rc.local中强制加上 /...
CentOS配置iptables防火墙.docx
下面小编就为大家带来一篇centOS7 下利用iptables配置IP地址白名单的方法。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧
centos7默认安装了firewall.如果不需要这个,可以把这个关闭,并且把iptables给装上去,并且把相关平常使用比较多的端口进行配置
centos7安装iptables并配置规则
阿里云CentOS6.8启动iptables的sh文件,放到CentOS系统里直接启动
Linus服务器上iptables一键生成已有的端口防火墙。centos7需要输入y进行安装iptables。可用于批量生成启动iptables,最后可以根据需求进行个别调整。
CentOS操作系统下配置iptables防火墙.docx
本篇文章主要介绍了CentOS7安装iptables防火墙的方法,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧