centos 7 安装iptables防火墙
firewalle:
开启6379端口和16379端口
[root@localhost ~]# firewall-cmd --zone=public --add-port=6379/tcp --permanent
[root@localhost ~]# firewall-cmd --zone=public --add-port=16379/tcp --permanent
重启防火墙
[root@localhost ~]# firewall-cmd --reload
CentOS7默认的防火墙不是iptables,而是firewalle.
cent7以下用到的防火墙是iptables,关闭防火墙代码如下
关闭防火墙命令:
service iptables stop
永久关闭防火墙:
chkconfig iptables off
cent7以上关闭命令:
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
1、安装iptable iptable-service
#先检查是否安装了iptables
service iptables status
#安装iptables
yum install -y iptables
#升级iptables(安装的最新版本则不需要)
yum update iptables
#安装iptables-services
yum install iptables-services
2、禁用/停止自带的firewalld服务
#停止firewalld服务
systemctl stop firewalld
#禁用firewalld服务
systemctl mask firewalld
3、设置现有规则
#查看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 4、其他规则设定
#如果要添加内网ip信任(接受其所有TCP请求)
iptables -A INPUT -p tcp -s 45.96.174.68 -j ACCEPT
#过滤所有非以上规则的请求
iptables -P INPUT DROP
#要封停一个IP,使用下面这条命令:
iptables -I INPUT -s ***.***.***.*** -j DROP
#要解封一个IP,使用下面这条命令:
iptables -D INPUT -s ***.***.***.*** -j DROP 5、保存规则设定
#保存上述规则
service iptables save 6、开启iptables服务
#注册iptables服务
#相当于以前的chkconfig iptables on
systemctl enable iptables.service
#开启服务
systemctl start iptables.service
#查看状态
systemctl status iptables.service
7、映射端口(如将mysql默认的3306端口映射成1306对外提供服务)
iptables -t mangle -I PREROUTING -p tcp --dport 1306 -j MARK --set-mark 883306
iptables -t nat -I PREROUTING -p tcp --dport 1306 -j REDIRECT --to-ports 3306
iptables -I INPUT -p tcp --dport 3306 -m mark --mark 883306 -j ACCEPT
内容转载自:https://www.cnblogs.com/anne32184/p/5961806.html
centos 7 安装iptables防火墙的更多相关文章
- CentOS切换为iptables防火墙并进行相关配置
CentOS切换为iptables防火墙 切换到iptables首先应该关掉默认的firewalld,然后安装iptables服务. 1.关闭firewall: service firewalld s ...
- CentOS下配置iptables防火墙 linux NAT(iptables)配置
CentOS下配置防火墙 配置nat转发服务CentOS下配置iptables防火墙 linux NAT(iptables)配置 CentOS下配置iptables 1,vim /etc/syscon ...
- Centos7下安装iptables防火墙
说明:centos7默认使用的firewalld防火墙,由于习惯使用iptables做防火墙,所以在安装好centos7系统后,会将默认的firewall关闭,并另安装iptables进行防火墙规则设 ...
- CentOS之——CentOS7安装iptables防火墙
转载请注明出处:http://blog.csdn.net/l1028386804/article/details/50779761 CentOS7默认的防火墙不是iptables,而是firewall ...
- Centos安装iptables防火墙
一.安装说明: 1.因为centos7.0及以上版本就默认安装了firewall防火墙,但有时候根据项目实际所需,服务器上还是需要安装iptables,以下就是具体的安装步骤: 2.因阿里云在服务器外 ...
- CentOS7安装iptables防火墙
CentOS7默认的防火墙不是iptables,而是firewalle. 安装iptable iptable-service #先检查是否安装了iptables service iptables st ...
- entOS7安装iptables防火墙,试验未通过
CentOS7默认的防火墙不是iptables,而是firewalle. 安装iptable iptable-service #先检查是否安装了iptables service iptables st ...
- CentOS 7安装iptables服务,以及常用命令
之前使用的是CentOS6.5,并且学艺不精,用啥查啥,用完就忘.并且网上大部分资料是基于CentOS7之前的版本. 在CentOS7中,默认的防火墙不是iptables,而是firewalld.而且 ...
- CentOS 7设置iptables防火墙开放proftpd端口
由于ftp的被动模式是这样的,客户端跟服务器端的21号端口交互信令,服务器端开启21号端口能够使客户端登录以及查看目录.但是ftp被动模式用于传输数据的端口却不是21,而是大于1024的随机或配置文件 ...
随机推荐
- ARIMA模型总结
时间序列建模基本步骤 获取被观测系统时间序列数据: 对数据绘图,观测是否为平稳时间序列:对于非平稳时间序列要先进行d阶差分运算,化为平稳时间序列: 经过第二步处理,已经得到平稳时间序列.要对平稳时间序 ...
- python dict的函数
1. dict.clear() 删除字典内所有元素 2. dict.copy() 返回一个字典的浅复制 3. dict.fromkeys(seq[, val]) 创建一个新字典,以序列 seq 中元素 ...
- oracle中实现某个用户truncate 其它用户下的表
oracle文档中对truncate权限的要求是需要某表在当前登录的用户下,或者当前登录的用户有drop any table的权限. 但是如果不满足第一个条件的情况下,要让某用户满足第二个条件就导致权 ...
- InternalError (see above for traceback): Blas GEMV launch failed: m=1, n=100
python tensorflow 运行提示错误:InternalError (see above for traceback): Blas GEMV launch failed: m=1, n=1 ...
- hiho一下 第168周
题目1 : 扩展二进制数 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 我们都知道二进制数的每一位可以是0或1.有一天小Hi突发奇想:如果允许使用数字2会发生什么事情? ...
- Python IO内核交互了解
注:Unix \ Linux 环境下的network IO 用户空间与内核空间 现在操作系统都是采用虚拟存储器,那么对32位操作系统而言,它的寻址空间(虚拟存储空间)为4G(2的32次方).操作系 ...
- Shell egrep
1.egrep是grep命令的扩展.grep使用需要脱义字符“\”.-E也可以满足. 2.正则参数. (). #任意一个任意字符. ()? #0或1个前面的字符. ()+ #1或多次的前面字符. () ...
- docker安装openwrt镜像(不完美案例)
镜像从http://downloads.openwrt.org/releases下载 注意选择generic-rootfs.tar.gz这种类型的镜像 使用docker import导入镜像,导入后可 ...
- java基础hashmap
Iterator中hasNext(), next() 在Iterator类中,我们经常用到两个方法: hasNext(), next(),具体含义: next(), 是返回当前元素, 并指向下一个元 ...
- Bytom Java版本离线签名
比原项目仓库: Github地址:https://github.com/Bytom/bytom Gitee地址:https://gitee.com/BytomBlockchain/bytom tx_s ...