Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redis bind to more than one IP

Tags:

redis

In the redis.conf the normal setting is

bind 127.0.0.1

I want redis to listen to another ip too (say my local development address)

I tried

bind 127.0.0.1, 123.33.xx.xx

but this does not work. I cannot find any relevant in the document or by googling. Hope someone can help.

like image 792
spacemilkman Avatar asked Apr 20 '13 12:04

spacemilkman


People also ask

What is bind in Redis?

It binds the redis instance to specific interface (and hence specific ip address). Basically your redis server will only listen to connections made to the address specified in via the bind option. This is a security measure that allows for dropping connections not made inside the particular network.

Where is Redis config file?

The Redis configuration file is located at installdir/redis/etc/redis. conf.

How do I configure Redis?

You can obtain a list of all the supported configuration parameters by typing CONFIG GET * in an open redis-cli prompt. All the supported parameters have the same meaning of the equivalent configuration parameter used in the redis. conf file: Note that you should look at the redis.


2 Answers

Binding to multiple IPs is indeed possible since Redis 2.8. Just separate each IP by whitespace (not commas).

bind 127.0.0.1 123.33.xx.xx 

Source: Official default config

like image 178
mahemoff Avatar answered Oct 06 '22 06:10

mahemoff


This answer is not outdated and will work for both older and newer versions

The problem in understanding is that Redis binding doesn't show the client machine's address, but shows the interface through which connection should be established. In your example, if your local development (client) address is 123.33.xx.xx, it doesn't mean that you have to put exactly the same address as a binding, otherwise Redis service will not start.

So if ifconfig on your Redis server machine shows that you have some network interface similar to this:

eth0   Link encap:Ethernet  HWaddr 00:0c:...         inet addr:192.168.1.110  Bcast:192.168.1.255  Mask:255.255.255.0 

you can put the interface's address 192.168.1.110 as a binding and every request to Redis, which pass through this interface, should succeed.

like image 26
Serob_b Avatar answered Oct 06 '22 07:10

Serob_b