Redis bind 配置

Redis bind配置 ,首先说结论


  1. bind 127.0.0.1, 只能在本地机器连接
  2. bind 127.0.0.1 192.168.2.14, 可以通过 redis-cli -p 127.0.0.1 或 redis-cli -p 192.168.2.14 链接,就是说127.0.0.1只能是本地使用,所以bind 127.0.0.1仅支持本机,而bind 192.168.2.14 所有可以通过192.168.2.14访问到 192.168.2.14这个服务器的机器,都可以通过 redis-cli -p 192.168.2.14链接redis
  3. bind 0.0.0.0 配置成0.0.0.0 这个redis所在的服务器支持几个ip来连接,就可以通过这几个ip来连接redis(举例说明:假设A服务器 通过 ip addr 查看这个服务器的ip有三个,分别是127.0.0.1,192.168.2.14,336.334.224.1,那么就意味着你可以通过这三个ip来连接redis,你能通过哪个ip可以链接到A服务器,你就可以通过这个ip来连接redis)
  4. 如果不填 ,效果和 bind 0.0.0.0一样

通过上面也大概能猜到,bind 配置就是通过你配置的ip来访问 redis服务的(就是通过127.0.0.1或192.168.2.14来连接,谁能访问到 bind 后面配置的ip,谁就可以通过这个ip来连接redis)
然后我们再来看redis关于bind 的注释

# By default, if no "bind" configuration directive is specified, Redis listens
# for connections from all the network interfaces available on the server.
# It is possible to listen to just one or multiple selected interfaces using
# the "bind" configuration directive, followed by one or more IP addresses.
#
# Examples:
#
# bind 192.168.1.100 10.0.0.1
# bind 127.0.0.1 ::1
#
# ~~~ WARNING ~~~ If the computer running Redis is directly exposed to the
# internet, binding to all the interfaces is dangerous and will expose the
# instance to everybody on the internet. So by default we uncomment the
# following bind directive, that will force Redis to listen only into
# the IPv4 lookback interface address (this means Redis will be able to
# accept connections only from clients running into the same computer it
# is running).
#
# IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES
# JUST COMMENT THE FOLLOWING LINE.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

bind 127.0.0.1

请认真阅读上述英文注释, 下面是google翻译
默认情况下,如果未指定“ bind”配置指令,则Redis将侦听服务器上所有可用网络接口的连接。 可以使用“ bind”配置指令仅侦听一个或多个所选接口,然后侦听一个或多个IP地址。
如果运行Redis的计算机直接暴露于Internet,则绑定到所有接口都是很危险的,并且会将实例暴露给Internet上的所有人。 因此,默认情况下,我们取消注释以下bind指令,这将强制Redis仅侦听IPv4回顾接口地址(这意味着Redis将只能接受来自运行在同一台计算机上的客户端的连接)。
如果您确定要立即侦听所有接口,请仅注意以下内容。
bind 127.0.0.1

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值