各种配置文件经常看到bind_ip的设置,为的更加安全
- 1.绑定本地
- [root@host-192-168-1-56 ~]# netstat -nputl|grep -i redis
tcp 0 0 127.0.0.1:6379 0.0.0.0:* LISTEN 12864/redis-server
- 从另一台机器登录:
- [root@hostnfsd :/root]$ redis-cli -p 6379 -h 192.168.1.56 ----内网不能登录
Could not connect to Redis at 192.168.1.56:6379: Connection refused
not connected>
[root@hostnfsd :/root]$ redis-cli -p 6379 -h 125.208.12.56 ----外网不能登录
Could not connect to Redis at 125.208.12.56:6379: Connection refused
not connected>
- 2.绑定内网
- [root@host-192-168-1-56 ~]# netstat -nputl|grep -i redis
tcp 0 0 192.168.1.56:6379 0.0.0.0:* LISTEN 13754/redis-server
[root@hostnfsd :/root]$ redis-cli -p 6379 -h 192.168.1.56 ----只有内网可以登录
redis 192.168.1.56:6379>
[root@hostnfsd :/root]$ redis-cli -p 6379 -h 125.208.12.56
Could not connect to Redis at 125.208.12.56:6379: Connection refused
not connected>
3.绑定外网
[root@host-192-168-1-56 ~]# netstat -nputl|grep -i redis
tcp 0 0 125.208.12.56:6379 0.0.0.0:* LISTEN 13966/redis-server
[root@hostnfsd :/root]$ redis-cli -p 6379 -h 192.168.1.56
Could not connect to Redis at 192.168.1.56:6379: Connection refused
not connected>
[root@hostnfsd :/root]$ redis-cli -p 6379 -h 125.208.12.56 ---只有外网能登陆
redis 125.208.12.56:6379>
[root@host-192-168-1-56 ~]# netstat -nputl|grep -i redis
tcp 0 0 125.208.12.56:6379 0.0.0.0:* LISTEN 13966/redis-server
[root@hostnfsd :/root]$ redis-cli -p 6379 -h 192.168.1.56
Could not connect to Redis at 192.168.1.56:6379: Connection refused
not connected>
[root@hostnfsd :/root]$ redis-cli -p 6379 -h 125.208.12.56 ---只有外网能登陆
redis 125.208.12.56:6379>
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29096438/viewspace-2134843/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/29096438/viewspace-2134843/