neko icon indicating copy to clipboard operation
neko copied to clipboard

Dynamic IP

Open Svenum opened this issue 2 years ago • 14 comments

I want to expose my docker to the public internet, but i have a dynamic IP from my ISP. Is it Posible to set a refresh interval or a dyndns to the ENV section, so that the IP updates automaticaly?

Svenum avatar Feb 06 '23 20:02 Svenum

Currently, if you do not specify any NEKO_NAT1TO1 when strating the instance, a request is made to http://checkip.amazonaws.com. But it is not refreshed throughout the session.

Do you plan to have that long running sessions? You could theoretically restart them when IP has changed or peridically, to refresh IP now.

There has been raised a similar concern, but in the context of neko rooms: https://github.com/m1k1o/neko-rooms/issues/62

m1k1o avatar Feb 06 '23 20:02 m1k1o

Yes I want to use long running sessions. https://github.com/m1k1o/neko-rooms/issues/62 is same as i want.

Svenum avatar Feb 06 '23 20:02 Svenum

I want to expose my docker to the public internet, but i have a dynamic IP from my ISP. Is it Posible to set a refresh interval or a dyndns to the ENV section, so that the IP updates automaticaly?

I highly recommend a dynamic dns provider with a reverse proxy like Caddy V2 (which also has a lightweight docker image). It will allow you to set a custom url, and it should keep the instance accessible. It also has the added bonus of providing HTTPS support.

Xeddius avatar Feb 12 '23 03:02 Xeddius

I have an dyndns provider but it dont fetch the ip every request or so. It only fetches the IP on Container start

Svenum avatar Feb 12 '23 12:02 Svenum

It could be easily implemented by adding new goroutine and ticker every X minutes. Or would you prefer having possibility to set it using CLI and calling it using crontab?

m1k1o avatar Feb 12 '23 12:02 m1k1o

Every X seconds is better maybe to set the interval via ENV.

Svenum avatar Feb 12 '23 16:02 Svenum

It could be easily implemented by adding new goroutine and ticker every X minutes. Or would you prefer having possibility to set it using CLI and calling it using crontab?

Both might make sense, however the latter one probably makes the most sense for now. I for example run my own DDNS server, so I can make it push the new IPv4 to the host running the Neko as soon as it changes. However, someone else who uses an external DDNS provider is probably not be able to do that, so just an ENVVAR you can set to seconds in how often it will fetch the new IPv4 from NEKO_IPFETCH is a good idea.

86dd avatar Feb 27 '23 16:02 86dd

Some news on this toppic?

Svenum avatar Apr 30 '23 20:04 Svenum

In my case I am having a VPN on my server and neko pick-up the wrong IP before VPN is established. Having an interval that will fetch the IP regularly would be great.

For now I simply execute container down and up commands automatically after VPN is established.

alanmilinovic avatar Sep 22 '23 05:09 alanmilinovic

Any updates in this Case?

Svenum avatar Oct 15 '23 10:10 Svenum

Any updates in this Case?

No

alanmilinovic avatar Oct 15 '23 10:10 alanmilinovic

I looked at the code and the whole module must be restaretd. So there is no difference in setting up custom CRON script that restarts neko:

docker exec neko supervisorctl restart neko

You could wrap it in such simple bash script:

#!/bin/bash

# Get current ip
current_ip=$(dig +short myip.opendns.com @resolver1.opendns.com)

# Get last ip
last_ip=$(cat /opt/last_ip)

# Check if ip changed
if [ "$current_ip" != "$last_ip" ]; then
    # Restart network
    docker exec neko supervisorctl restart neko
    # Save new ip
    echo $current_ip > /opt/last_ip
fi

And run e.g. every 5min in CRON.

m1k1o avatar Oct 15 '23 10:10 m1k1o

Maybe you could buildin this script in the container so that you can enable it with an env?

Svenum avatar Oct 15 '23 10:10 Svenum

Maybe you could buildin this script in the container so that you can enable it with an env?

I agree, that was the idea at some point in time.

alanmilinovic avatar Oct 15 '23 10:10 alanmilinovic