• 关于redis bind


    原文:https://my.oschina.net/ironwill/blog/902006

    Redis Version

    Redis server v=3.2.3

    参考

    https://segmentfault.com/q/1010000002921259

    http://blog.csdn.net/hel12he/article/details/46911159

    关于bind

    ################################## NETWORK #####################################
    
    # By default, if no "bind" configuration directive is specified, Redis listens
    # for connections from all the network interfaces available on the server.
    #默认情况下,如果没有声明bind指令,Redis会监听服务器上所有可用的网络接口(网卡)上的连接。
    # It is possible to listen to just one or multiple selected interfaces using
    # the "bind" configuration directive, followed by one or more IP addresses.
    #可以用bind指令指定Redis监听的一个或多个网络接口(网卡),示例如下:
    #
    # Examples:
    #
    #bind 192.168.10.3 192.160.10.4 127.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
    #如果你的Redis部署在公网上,并且监听所有网络接口(网卡),那么你的Redis示例便暴露给了互联网上的每个人,这样是很危险的。
    # 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
    
    • 意思是说 bind 指定是Redis所在服务器网卡的ip,不是指定某些IP可以访问本机Redis实例
    • 如果你的bind指定的不是本机网卡IP,那么可能导致你的Redis实例无法启动

    如何限制或指定IP访问呢?

    1. 如果是内网访问,通过网络接口(网卡)限定,让客户端访问固定网卡连接redis
    2. 如果是公网,通过iptables指定某个IP允许访问!!

    总之,通过bind是无法指定某个IP来访问redis的。这在网上是一个很大的误区!!

  • 相关阅读:
    java基础—面向对象2
    java基础—java读取properties文件
    java基础—super关键字
    java基础—this关键字
    java基础—object类
    java基础—equals方法
    java基础—哈希编码
    Struct2(五)处理表单
    struct2(四)编写Struct2 的Action
    Struct2(三) Struct2 标签
  • 原文地址:https://www.cnblogs.com/binzhou75/p/12100419.html
Copyright © 2020-2023  润新知