Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Dynamic IP #247

Open
Svenum opened this issue Feb 6, 2023 · 14 comments
Open

Dynamic IP #247

Svenum opened this issue Feb 6, 2023 · 14 comments
Labels
enhancement New feature or request

Comments

@Svenum
Copy link

Svenum commented Feb 6, 2023

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?

@m1k1o
Copy link
Owner

m1k1o commented Feb 6, 2023

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: m1k1o/neko-rooms#62

@Svenum
Copy link
Author

Svenum commented Feb 6, 2023

Yes I want to use long running sessions.
m1k1o/neko-rooms#62 is same as i want.

@m1k1o m1k1o added the enhancement New feature or request label Feb 6, 2023
@Xeddius
Copy link
Contributor

Xeddius commented Feb 12, 2023

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.

@Svenum
Copy link
Author

Svenum commented Feb 12, 2023

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

@m1k1o
Copy link
Owner

m1k1o commented Feb 12, 2023

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?

@Svenum
Copy link
Author

Svenum commented Feb 12, 2023

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

@86dd
Copy link

86dd commented Feb 27, 2023

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.

@Svenum
Copy link
Author

Svenum commented Apr 30, 2023

Some news on this toppic?

@alanmilinovic
Copy link

alanmilinovic commented Sep 22, 2023

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.

@Svenum
Copy link
Author

Svenum commented Oct 15, 2023

Any updates in this Case?

@alanmilinovic
Copy link

Any updates in this Case?

No

@m1k1o
Copy link
Owner

m1k1o commented Oct 15, 2023

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.

@Svenum
Copy link
Author

Svenum commented Oct 15, 2023

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

@alanmilinovic
Copy link

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.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants