【问题标题】:Redis - Bind interfaces does not work (Connection refused)!Redis - 绑定接口不起作用(连接被拒绝)!
【发布时间】:2017-09-07 10:03:15
【问题描述】:

我正在尝试将 Redis(redis.confbind 参数)配置为仅接受来自某些 ips 的访问。在我的情况下,我想启用对环回网络接口 (127.0.0.1/::1) 和 ip 192.168.56.101 的访问(192.168.56.102 是 Redis 服务器的 ip)。根据我目前阅读的所有文档,下面的配置应该可以工作......

bind 127.0.0.1 ::1 192.168.56.101

...但事实并非如此。

我尝试了其他几种配置...

bind 127.0.0.1 192.168.56.101 ::1
bind 127.0.0.1 192.168.56.101
bind 192.168.56.101
bind 192.168.56.0
bind 192.168.0.0

...没有任何效果。 =|

唯一有效的配置是这个......

bind 0.0.0.0

但是,这个配置打开了对任何 ip 的访问权限!

注意:protected-mode 参数 (redis.conf) 具有 no 值。

知道会发生什么吗?

参考:

Redis bind to more than one IP

https://redis.io/topics/security

http://download.redis.io/redis-stable/redis.conf

进一步的问题:

如何启用对 IP 范围的访问(bind 参数)?有点像...

bind 192.168.56.0

...或者...

bind 192.168.56.0/24

在这些示例中,任何 ip 以“192.168.56”开头的机器都可以访问 Redis 服务器。

@卡尔·达科斯塔 @杰基

谢谢!

【问题讨论】:

    标签: redis


    【解决方案1】:

    我认为您误解了bind 配置和IP-whitelist

    bind 配置指定了 Redis 监听的 IP 地址。如果将 Redis 绑定到环回接口,则只有本地客户端可以访问 Redis。如果希望其他主机访问 Redis,则必须将 Redis 绑定到所有网络接口(即 0.0.0.0)或某些指定的网络接口。

    你需要的是IP-whitelist,它列出了可以访问Redis的IP地址。 AFAIK,到目前为止,Redis 支持(如果我错了,请纠正我)。

    还有其他限制对Redis的访问的解决方案(所有这些解决方案都需要Redis NOT在环回接口上绑定)。

    通过身份验证限制访问

    您可以使用requirepass 配置为 Redis 设置密码。只有拥有密码的客户端才能访问 Redis。

    通过操作系统实用程序限制访问

    在 Linux 上,您可以使用iptables 来控制网络访问。使用此实用程序,您只能允许指定的主机访问 Redis 绑定的端口。

    【讨论】:

      猜你喜欢
      • 2021-01-24
      • 2017-07-10
      • 2016-02-14
      • 2018-09-29
      • 2019-01-22
      • 2021-10-22
      • 1970-01-01
      • 2022-10-20
      • 2021-04-24
      相关资源
      最近更新 更多