Redis Version
Redis server v=3.2.3
参考
关于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访问呢?
- 如果是内网访问,通过网络接口(网卡)限定,让客户端访问固定网卡连接redis
- 如果是公网,通过iptables指定某个IP允许访问!!
总之,通过bind是无法指定某个IP来访问redis的。这在网上是一个很大的误区!!