1

In my Ubuntu virtual machine in Hyper-V, I have installed Redis and it runs on startup (by doing sudo systemctl enable redis) and I have configured it to bind 127.0.0.1 192.168.10.100 in the config (the 2nd IP is for internal connections across the local network).

The problem I have is that when I start the virtual machine, it won't allow connections from other local computers (connecting from 192.168.10.100). But when I restart Redis by doing sudo systemctl restart redis it only then allows.

This problem is not because I forgot to restart Redis when adding 192.168.10.100 to the Redis bind.

parpar8090
  • 41
  • 5
  • In init script did you run redis after the second IP is up? – Romeo Ninov Aug 31 '22 at 15:20
  • @RomeoNinov I haven't modified `/etc/systemd/system/redis.service` so I'm not sure. Looking at that file I don't see where I could bind it. It does have `--supervised systemd`. It also says `--daemonized no` but in `redis.conf` it's set to yes – parpar8090 Aug 31 '22 at 16:23
  • You do not get my point. You set second IP. Is it run redis after the set of this second IP? – Romeo Ninov Aug 31 '22 at 16:30
  • @RomeoNinov I'm not sure, how can I check? – parpar8090 Aug 31 '22 at 16:46
  • If you run second IP in systemd you should have in redix `Requires=secondip.service` and/or `After=secondip.service` – Romeo Ninov Aug 31 '22 at 16:57
  • @RomeoNinov I'm not very experienced with linux so I'm not sure how can I run the second IP in systemd. Looking at the redis.service I see there's `After=network.target` not sure how I can see what's inside network.target. – parpar8090 Aug 31 '22 at 17:09
  • Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/138911/discussion-between-parpar8090-and-romeo-ninov). – parpar8090 Aug 31 '22 at 17:14

1 Answers1

0

This happens because redis is started before your interface is actually up and configured, I've been dealing with the same issue

I've added After=network-online.target to my redis.service file, this should actually wait until the network interface is "up", instead of just initialised (which may or may not include an IP). This might work for you

Unfortunately I haven't been able to test this yet, but I will update this comment once I've rebooted this system at least once

Isa
  • 166
  • 2