My nextcloudpi IP address keeps changing

Hello! I have a nextcloudpi set up and I use duckdns to allow external access… The problem is my pi’s IP address keeps randomly changing (think 192.168.0.100 to 192.168.0.105 or 192.168.0.101 etc) and it’s messing up forwarded ports. Every time it changes, I have to set it to the new IP on my devices, my family can’t log into their accounts on my cloud and I have to go into my router settings every time and delete the previous exception and make an new one and forward ports again.

Is there a way to stop the IP from changing randomly? it’s genuinely beginning to p*ss me off and it’s wasting my time and energy so any help appreciated. :stuck_out_tongue:

Thanks,
MattyWS

This is how DHCP handles on your local network. Devices are assigned an IP until the lease expires, depending on your DHCP settings, and then assigned a new one.

You have two options

  1. Set your linux server to a static IP rather than have DHCP turned on. (instructions for your specific OS are easily searchable). Usually you set it at the beginning or end of your network eg. 192.168.0.2 or 192.168.0.254. That way you can go to your DHCP server settings, usually on your router, and shortening the scope to exclude it from assigning those IP addresses to another device.

  2. Set your DHCP server to assign your linux server a reserved DHCP address. You will have to enter in your server’s MAC address, also called physical, burned-in, or ether address, and then give it a specific IP.

2 Likes

Thanks for the reply, I vaguely figured that much out before I saw your post and thought I could fix it in the ncp server settings but checking a box that said “static IP” but now I can’t access it at all. :sweat_smile:

This is certainly a learning experience for me. I assume it may be different for various setups but I’m using nextcloudpi for mine. I don’t suppose anyone would know how to resolve this now? I can only access the settings from the pi terminal now so thats fun.

Easiest for you is probably option 2:
In your PiOS terminal you can type
ifconfig -a
look for your pi’s ether address. It’s sorted by interface. If you are using a wired network the interface should be called something like eth0
with an ether address like AA:BB:CC:DD:EE:FF

Then you can log into your router, search in your DHCP settings for IPv4 reserved address. Enter that Mac Address and give it an ip in your network 192.168.0.X

reboot your pi server, and you should be good to go

You can set your router in the “advanced” settings usually. Set the IP lease from dynamic to static lease or there might be a setting to have the IP never expire.

I never have to do anything else except in the router and the IP always stays the same for every PC or server I set for static lease or never expire lease etc.