# bind 192.168.1.100 10.0.0.1 # bind 192.168.1.8 # bind 127.0.0.1
After the modification is completed, the redis service needs to be restarted.
redis-server redis.conf如果iptables 没有开启6379端口,用这个方法开启端口
Command: /sbin/iptables -I INPUT -p tcp --dport 6379 -j ACCEPT Save firewall modification command: /etc/rc.d/init.d/iptables save
Allow specified external network IP access through iptables
Modify the Linux firewall (iptables) and open your redis service port. The default is 6379.
//只允许127.0.0.1访问6379iptables -A INPUT -s 127.0.0.1 -p tcp --dport 6379 -j ACCEPT//其他ip访问全部拒绝iptables -A INPUT -p TCP --dport 6379 -j REJECT
Before rejection is not configured
After rejection is configured
Another way is to enable it through bind mode
The above is to configure redis to be accessible from the external network. And only allow the specified IP to access all the contents of redis.
Related recommendations: Redis Tutorial
The above is the detailed content of How to configure redis to be accessible from the external network and only allow specified IPs to access redis. For more information, please follow other related articles on the PHP Chinese website!