CentOS7默认的防火墙不是iptables,而是firewalle;
#先检查是否安装了iptables service iptables status #安装iptables yum install -y iptables #升级iptables yum update iptables #安装iptables-services yum install iptables-services
禁用/停止自带的firewalld服务
#停止firewalld服务 systemctl stop firewalld #禁用firewalld服务 systemctl disable firewalld
启动iptables
#启动iptables service iptables start 或者 service iptables restart #关闭iptables service iptables stop #查看iptables 状态 service iptables status
设置规则
#查看iptables现有规则 iptables -L -n #先允许所有,不然有可能会杯具 iptables -P INPUT ACCEPT #清空所有默认规则 iptables -F #清空所有自定义规则 iptables -X #所有计数器归0 iptables -Z #允许来自于lo接口的数据包(本地访问) iptables -A INPUT -i lo -j ACCEPT #开放22端口 iptables -A INPUT -p tcp --dport 22 -j ACCEPT #开放21端口(FTP) iptables -A INPUT -p tcp --dport 21 -j ACCEPT #开放80端口(HTTP) iptables -A INPUT -p tcp --dport 80 -j ACCEPT #开放443端口(HTTPS) iptables -A INPUT -p tcp --dport 443 -j ACCEPT #允许ping iptables -A INPUT -p icmp --icmp-type 8 -j ACCEPT #允许接受本机请求之后的返回数据 RELATED,是为FTP设置的 iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT #其他入站一律丢弃 iptables -P INPUT DROP #所有出站一律绿灯 iptables -P OUTPUT ACCEPT #所有转发一律丢弃 iptables -P FORWARD DROP
相关推荐
Centos离线安装iptables
CentOS 安装使用Iptables,1.安装iptables-services2.设置开机启动3.配置说明
centos6 iptables常用操作, 规则的新增。
阿里云Centos配置iptables防火墙.docx
centos7默认安装了firewall.如果不需要这个,可以把这个关闭,并且把iptables给装上去,并且把相关平常使用比较多的端口进行配置
centos7安装iptables并配置规则
本篇文章主要介绍了CentOS7安装iptables防火墙的方法,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
CentOS配置iptables防火墙.docx
虽说阿里云推出了云盾服务,但是自己再加一层防火墙总归是更安全些,下面是...说明iptables服务是有安装的,但是没有启动服务。 如果没有安装的话可以直接yum安装 yum install -y iptables 启动iptables [root@woxpl
centos7 iptables-services-1.4.21-17.el7.x86_64.rpm 安装包 下载
Linus服务器上iptables一键生成已有的端口防火墙。centos7需要输入y进行安装iptables。可用于批量生成启动iptables,最后可以根据需求进行个别调整。
CentOS7安装及网络配置完整过程(可解决Dell R730) 本文将指导您完成CentOS7的安装和网络配置,解决Dell R730服务器的安装问题。 一、服务器配置硬件 在安装CentOS7之前,需要了解服务器的硬件配置。Dell R730...
系统升级到CentOS 7后总感觉iptables怪怪的,比如不管怎么保存重启后都被初始化一下,即便我最后发大绝招启动时候加命令: 首先iptables-save > /etc/iptables.rules保存当前状态。 然后再在/etc/rc.local中强制加上 /...
阿里云CentOS6.8启动iptables的sh文件,放到CentOS系统里直接启动
CentOS操作系统下配置iptables防火墙.docx
CentOS 7的iptables服务.docx
iptables-1.4.21-35.el7.x86_64.rpm iptables-services-1.4.21-35.el7.x86_64.rpm
CentOS 7 iptables的安装及使用-附件资源