jammsen / docker-palworld-dedicated-server

Docker container to easily provision and manage Palworld Dedicated Server
https://hub.docker.com/r/jammsen/palworld-dedicated-server
MIT License
911 stars 158 forks source link

[Feature Request] Add an option for dynamic IPs #127

Closed AngryBirdz closed 8 months ago

AngryBirdz commented 8 months ago

Have you read the Important information text above

Describe the feature

For people like me who are self-hosting their server without a fixed IP, it would be handy for us if the container configuration could automaticaly handle the PUBLIC_IP variable by fetching it on restart. This should be easy enough to implement. I've already tested my example code from your container and it worked. It could be something like:

if [[ $PUBLIC_IP == "dynamic" ]]; then
    PUBLIC_IP=$(curl -s http://ipecho.net/plain)
fi

Additional information

Final checks

masonen commented 8 months ago

I realy do like the idea.

Since we need to restart the server anyways on changes of the public ip let me suggest to add a cronjob inside the container (since the crontab is there anyways) that retrieves the current public IP and compare it with the curenlty configured one and restart the server if it has changed and run it minutely or so

Also id rather rely on something like cloudflare or dyndns.org to retrieve the IP

dig +short txt ch whoami.cloudflare @1.0.0.1

Rave1996 commented 8 months ago

If you leave the PUBLIC_IP env var empty, the server will (automatically) get the external IP.

You could also make a script to update the A record in some DDNS service (using their respective API), i'm doing this but with HomeAssistant + Cloudflare, works flawlessly.

jammsen commented 8 months ago

Hey @AngryBirdz @masonen

For people like me who are self-hosting their server without a fixed IP, it would be handy for us if the container configuration could automaticaly handle the PUBLIC_IP variable by fetching it on restart.

Afaik what @Rave1996 wrote is true:

If you leave the PUBLIC_IP env var empty, the server will (automatically) get the external IP.

The dedicated-server already does that by itself. If you leave the PUBLIC_IP empty then the config will be written in a way that the server knows, it has to do that. But you dont get back an ip or a log entry in the server-log. Just the be transparent here.

Also IF we would add this function, i would prefer the "dig"-way a lot more then query some random webpage that might be offline. But im not really sure if its really needed. Any feedback on this?

Ping @Plarpoon @thejcpalma @caleb-devops

Plarpoon commented 8 months ago

I also have a dynamic IP and personally think this request is out of scope of this project.

There are plenty of completely free dynamic IP websites online like DynDNS you can use to always contact your homelab. If you want something more professional you can buy yourself a domain (mine is on cloudflare and I pay 8€ a year), then you can redirect the DNS to your machine.

Considering these extremely cheap options I would honestly not focus on this.

jammsen commented 8 months ago

I also have a dynamic IP and personally think this request is out of scope of this project.

There are plenty of completely free dynamic IP websites online like DynDNS you can use to always contact your homelab. If you want something more professional you can buy yourself a domain (mine is on cloudflare and I pay 8€ a year), then you can redirect the DNS to your machine.

Considering these extremely cheap options I would honestly not focus on this.

I mean the server already determines the IP of "PUBLIC_IP" if its empty, so i dont have to do something, because the server does it itself. If thats not enough for a "dynamic" approach, im not sure what getting the IP from "dig" or "curl something" would do different. But i might miss something here.

Also https://www.noip.com/ does that for free, 3 sub-domains per account, im using that for over 10 years.

AngryBirdz commented 8 months ago

In my case, when I tried this Docker image for the first time I had some problems. Everything is fine now, but one of them was that the container could not access the Internet if I left the PUBLIC_IP variable empty. Manually entering my public IP address fixed the issue.

Now I just did another test by deploying a second container leaving the PUBLIC_IP variable empty. The container was deployed without incident and had access to the internet. I really don't know what happened. 🤔

thejcpalma commented 8 months ago

Also https://www.noip.com/ does that for free, 3 sub-domains per account, im using that for over 10 years.

Also have DuckDNS, it's really cool but you also have many other.

Take a look here.

masonen commented 8 months ago

Does anyone know if the dedicated server restarts automatically once the local ip has changed ? Could not find reliable information about this.

thejcpalma commented 8 months ago

Does anyone know if the dedicated server restarts automatically once the local ip has changed ? Could not find reliable information about this.

If you for example change the Host machine IP?

You'll need to update the entry on the router for the port forward but the server doesnt restart if the Host changes IP address.

Rave1996 commented 8 months ago

Does anyone know if the dedicated server restarts automatically once the local ip has changed ? Could not find reliable information about this.

No need, the server automatically allows any connection by doing that even if the external IP changes.

thejcpalma commented 8 months ago

Does anyone know if the dedicated server restarts automatically once the local ip has changed ? Could not find reliable information about this.

No need, the server automatically allows any connection by doing that even if the external IP changes.

I don't know if he's talking about externalpublic IP or the host machine. If it's the host he needs to adjust the forwarding on the router to accomodate the new change

Rave1996 commented 8 months ago

Does anyone know if the dedicated server restarts automatically once the local ip has changed ? Could not find reliable information about this.

No need, the server automatically allows any connection by doing that even if the external IP changes.

I don't know if he's talking about externalpublic IP or the host machine. If it's the host he needs to adjust the forwarding on the router to accomodate the new change

He's talking about the IP required to connect from outside his network (even after his ISP changes it)..., the port forwarding is another completly different setting that's not related to the repository and the local IP wont change unless he moves the server to another device or changes his network card.

thejcpalma commented 8 months ago

Exactly. Public IPs are dynamic (most of the time), that's why using a DuckDNS (which you can host/install easily, or even run a docker container) or another of course. Local IP changes (the IP of the host machine running docker) don't affect anything on the container. Usually local IP doesn't change (like @Rave1996 is saying) but it can (for example, the DHCP leases on the router aren't permanent unless you set a rule on the router for a fixed IP to a specific mac address or if you set a fixed IP on the machine - which might bug if it asks for that IP, and it is already assigned to another machine).

So, summing up:

jammsen commented 8 months ago

Does anyone know if the dedicated server restarts automatically once the local ip has changed ? Could not find reliable information about this.

Hey @masonen - This question is a little bit to vague, do you mind getting it more detailed please? Before people get crazy about solutions here? 🤣 If however the question was already answered, please write something 🙏

masonen commented 8 months ago

yeah my question was related to if the server requires a restart IF the external public ip changes - but it doesnt question answered. sorry for the late response - release days are hard.. :D

thejcpalma commented 8 months ago

I think we can close this issue 😉 @masonen

jammsen commented 8 months ago

yeah my question was related to if the server requires a restart IF the external public ip changes - but it doesnt question answered. sorry for the late response - release days are hard

@masonen afaik the server needs to restart to re-detect the ip. So no-noninteractive thing.

Im closing this issue as resolved, feel free to reach out again if you need help.

If you like this project, please consider giving this repo and the docker-hub-repo a Star.