iptables 设置指定IP客户端访问服务器redis端口
一、需求描述
服务器172.28.18.75开放了6379redis端口,由于没有设置登录密码,所以需要防火墙设置只能指定的IP地址172.28.5.125客户端访问redis端口
二、查看172.28.18.75的防火墙规则
[root@zabbix_server ~]# iptables -nvL
Chain INPUT (policy DROP packets, bytes)
pkts bytes target prot opt in out source destination
230K 23M ACCEPT all -- * * 0.0.0.0/ 0.0.0.0/ state RELATED,ESTABLISHED
ACCEPT icmp -- * * 0.0.0.0/ 0.0.0.0/
ACCEPT tcp -- * * 0.0.0.0/ 0.0.0.0/ state NEW tcp dpt:
ACCEPT tcp -- * * 0.0.0.0/ 0.0.0.0/ state NEW tcp dpt:
ACCEPT tcp -- * * 0.0.0.0/ 0.0.0.0/ state NEW tcp dpt:
ACCEPT tcp -- * * 0.0.0.0/ 0.0.0.0/ state NEW tcp dpt:
ACCEPT tcp -- * * 0.0.0.0/ 0.0.0.0/ state NEW tcp dpt:
ACCEPT tcp -- * * 0.0.0.0/ 0.0.0.0/ state NEW tcp dpt:
ACCEPT tcp -- * * 0.0.0.0/ 0.0.0.0/ state NEW tcp dpt:
ACCEPT tcp -- * * 0.0.0.0/ 0.0.0.0/ state NEW tcp dpt:
ACCEPT tcp -- * * 0.0.0.0/ 0.0.0.0/ state NEW tcp dpt:
ACCEPT tcp -- * * 0.0.0.0/ 0.0.0.0/ state NEW tcp dpt:
ACCEPT tcp -- * * 0.0.0.0/ 0.0.0.0/ state NEW tcp dpt:
ACCEPT tcp -- * * 0.0.0.0/ 0.0.0.0/ state NEW tcp dpt:
ACCEPT tcp -- * * 0.0.0.0/ 0.0.0.0/ state NEW tcp dpt:
ACCEPT tcp -- * * 0.0.0.0/ 0.0.0.0/ state NEW tcp dpt:
ACCEPT tcp -- * * 0.0.0.0/ 0.0.0.0/ state NEW tcp dpt:
ACCEPT tcp -- * * 0.0.0.0/ 0.0.0.0/ state NEW tcp dpt:
ACCEPT tcp -- * * 0.0.0.0/ 0.0.0.0/ state NEW tcp dpt:
ACCEPT tcp -- * * 0.0.0.0/ 0.0.0.0/ state NEW tcp dpt:
ACCEPT tcp -- * * 0.0.0.0/ 0.0.0.0/ state NEW tcp dpt:
ACCEPT tcp -- * * 0.0.0.0/ 0.0.0.0/ state NEW tcp dpt:
Chain INPUT (policy DROP 2 packets, 104 bytes)默认规则是禁止,那么只需要添加允许访问IP的规则即可
三、添加规则:指定127.0.0.1的IP可以访问redis6379
[root@zabbix_server ~]# iptables -A INPUT -s 127.0.0.1 -p tcp --dport -j ACCEPT
在172.28.18.75上测试
[root@zabbix_server ~]# redis-cli
127.0.0.1:> get keys
(nil)
四、添加规则:指定172.28.5.125P可以访问172.28.18.75的redis6379
[root@zabbix_server ~]# iptables -A INPUT -s 172.28.5.125 -p tcp --dport -j ACCEPT
查看规则
[root@zabbix_server ~]# iptables -nvL
Chain INPUT (policy DROP packets, bytes)
pkts bytes target prot opt in out source destination
466K 46M ACCEPT all -- * * 0.0.0.0/ 0.0.0.0/ state RELATED,ESTABLISHED
ACCEPT icmp -- * * 0.0.0.0/ 0.0.0.0/
ACCEPT tcp -- * * 0.0.0.0/ 0.0.0.0/ state NEW tcp dpt:
ACCEPT tcp -- * * 0.0.0.0/ 0.0.0.0/ state NEW tcp dpt:
ACCEPT tcp -- * * 0.0.0.0/ 0.0.0.0/ state NEW tcp dpt:
ACCEPT tcp -- * * 0.0.0.0/ 0.0.0.0/ state NEW tcp dpt:
ACCEPT tcp -- * * 0.0.0.0/ 0.0.0.0/ state NEW tcp dpt:
ACCEPT tcp -- * * 0.0.0.0/ 0.0.0.0/ state NEW tcp dpt:
ACCEPT tcp -- * * 0.0.0.0/ 0.0.0.0/ state NEW tcp dpt:
ACCEPT tcp -- * * 0.0.0.0/ 0.0.0.0/ state NEW tcp dpt:
ACCEPT tcp -- * * 0.0.0.0/ 0.0.0.0/ state NEW tcp dpt:
ACCEPT tcp -- * * 0.0.0.0/ 0.0.0.0/ state NEW tcp dpt:
ACCEPT tcp -- * * 0.0.0.0/ 0.0.0.0/ state NEW tcp dpt:
ACCEPT tcp -- * * 0.0.0.0/ 0.0.0.0/ state NEW tcp dpt:
ACCEPT tcp -- * * 0.0.0.0/ 0.0.0.0/ state NEW tcp dpt:
ACCEPT tcp -- * * 0.0.0.0/ 0.0.0.0/ state NEW tcp dpt:
ACCEPT tcp -- * * 0.0.0.0/ 0.0.0.0/ state NEW tcp dpt:
ACCEPT tcp -- * * 0.0.0.0/ 0.0.0.0/ state NEW tcp dpt:
ACCEPT tcp -- * * 0.0.0.0/ 0.0.0.0/ state NEW tcp dpt:
ACCEPT tcp -- * * 0.0.0.0/ 0.0.0.0/ state NEW tcp dpt:
ACCEPT tcp -- * * 0.0.0.0/ 0.0.0.0/ state NEW tcp dpt:
ACCEPT tcp -- * * 0.0.0.0/ 0.0.0.0/ state NEW tcp dpt:
ACCEPT tcp -- * * 127.0.0.1 0.0.0.0/ tcp dpt:
ACCEPT tcp -- * * 172.28.5.125 0.0.0.0/ tcp dpt:
在172.28.5.125上测试
[root@redis- ~]# redis-cli -h 172.28.18.75
172.28.18.75:> get keys
(nil)
访问成功
五、添加规则:指定IP地址段172.28.146.1-172.28.146.252可以访问redis6379
[root@zabbix_server ~]# iptables -A INPUT -s 172.28.146.1/ -p tcp --dport -j ACCEPT
六、保存规则
[root@zabbix_server ~]# service iptables save
iptables:将防火墙规则保存到 /etc/sysconfig/iptables:[确定]
七、重启服务
[root@zabbix_server ~]# service iptables restart
iptables:将链设置为政策 ACCEPT:filter [确定]
iptables:清除防火墙规则:[确定]
iptables:正在卸载模块:[确定]
iptables:应用防火墙规则:[确定]
iptables 设置指定IP客户端访问服务器redis端口的更多相关文章
- iptables 设置特定IP访问指定端口
一.添加规则:设置禁止所有IP访问指定端口8075 [root@zabbix_server ~]# iptables -I INPUT -p tcp --dport -j DROP 二.测试telne ...
- mysql设置指定ip远程访问连接的方法
本文实例讲述了mysql设置指定ip远程访问连接的方法,分享给大家供大家参考.具体实现方法如下: 1. 授权用户root使用密码jb51从任意主机连接到mysql服务器: 复制代码 代码如下: GRA ...
- mysql设置指定ip远程访问连接实例
1. 授权用户root使用密码jb51从任意主机连接到mysql服务器: 复制代码代码如下: GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED ...
- windows防火墙安全设置指定ip访问指定端口
场景摘要: 1.我有三台腾讯云服务器 2.我日常办公网络的ip换了 3.我在腾讯云上面改了安全规则,也不能访问我A服务器的21,1433等端口 4.开始我以为是办公网络的安全设置问题 5.我进B服务器 ...
- Mysql中设置指定IP的特定用户及特定权限
创建用户:格式:grant select on 数据库.* to 用户名@登录主机 identified by '密码' 举例: 例 1:增加一个用户 test1 密码为 abc,让他可以在任何主机上 ...
- mysql设置指定ip访问,用户权限相关操作
基础语法GRANT priv_type ON database.table TO user[IDENTIFIED BY [PASSWORD] 'password'] [,user [IDENTIFIE ...
- 阿里云设置指定ip访问实例
添加安全组规则 添加允许访问的外网IP,优先级设置为1,并将所有ip设置为拒绝访问,优先级设置为2. 参考地址: https://help.aliyun.com/document_detail/254 ...
- 网络设置-指定ip
1 克隆centos6.设置网卡 vim /etc/udev/rules.d/70-persistent-net.rules 确定光标所在的位置 d3d删除以下三行,更改NAME为0 vim /etc ...
- Ubuntu 14.04 设置静态IP
使用Network Manager UI界面中指定 手动时,无法保存. 通过修改配置文件解决来此问题.记录以下. 如果输入过密码后,就会出现在这个目录下面, 以如下chinaNet为例 gaojing ...
随机推荐
- 八十五:redis之redis的事物、发布和订阅操作 (2019-11-18 22:54)
redis事物可以一次执行多个命令,事物具有以下特征1.隔离操作:事物中的所有命令都会序列化.按顺序执行,不会被其他命令打扰2.原子操作:事物中的命令要么全部被执行,要么全部都不执行 开启一个事物,以 ...
- openLdap安装教程
环境 操作系统:centOS 7.0 OpenLDAP:2.4.X 安装 从yum源安装 yum install openldap openldap-servers openldap-clients ...
- asp.NET 下真正实现大文件上传
一般10M以下的文件上传通过设置Web.Config,再用VS自带的FileUpload控件就可以了,但是如果要上传100M甚至1G的文件就不能这样上传了.我这里分享一下我自己开发的一套大文件上传控件 ...
- mysql命令行备份方法
一.mysql备份 1.备份命令 格式:mysqldump -h主机IP -P端口 -u用户名 -p密码 --database 数据库名 > 文件名.sql # 本地备份可以不添加端口和主机IP ...
- 攻防世界新手区pwn writeup
CGfsb 题目地址:https://adworld.xctf.org.cn/task/answer?type=pwn&number=2&grade=0&id=5050 下载文 ...
- 【Python开发】urllib2异常处理
一.urllib2模块回顾 urllib2模块中最重要的函数是urlopen()函数,用于获取URLs资源(Uniform Resorce Locators).urlopen函数不仅可以用于简单的情况 ...
- [python] a little deep learning case
from numpy import exp, array, random, dot class NeuralNetwork(): def __init__(self): random.seed(1) ...
- 【Python】【基础知识】【内置函数】【help的使用方法】
原英文帮助文档: help([object]) Invoke the built-in help system. (This function is intended for interactive ...
- 与高精死杠的几天——记两道简单的高精dp
(同样也是noip往年的题 1.矩阵取数游戏 题目链接[Luogu P1005 矩阵取数游戏] \(\mathcal{SOLUTION}:\) 通过对题目条件的分析,我们可以发现,每一行取数对答案的 ...
- rabbitmq五种消息模型整理
目录 0. 配置项目 1. 基本消息模型 1.1 生产者发送消息 1.2 消费者获取消息(自动ACK) 1.3 消息确认机制(ACK) 1.4 消费者获取消息(手动ACK) 1.5 自动ACK存在的问 ...