How to keep Unraid or Docker IP Address Static


Recommended Posts

From time to time my Unraid server changes IP addresses.  Typically this hasn't inconvenienced me in anyway besides having to update my Plex bookmark.  But now it's causing a much larger issue with another docker I am trying out (Nextcloud) because everytime the IP address changes it trashes the Nextcloud app on my phone (have to remove account and re-login and re-sync all of my files and re-setup my camera sync, etc.).

 

How can I keep either the server IP address or the Nextcloud IP address static?  I've read this section of the configuration tutorial, but that says it is only for networks without a DHCP server.  And since my server IP is 192.168.X.X that means I do have a DHCP server, correct?  My mesh router, unfortunately, does not provide many features for advanced users so I'll probably need to find a solution within Unraid.

 

Edit: is this the answer?  If I go into Settings > Network Settings I can change the IPv4 Address Assignment to "static" and it fills in the current info for me.  Is that is?  It's that easy?

Edited by zero_koop
Link to comment
1 hour ago, zero_koop said:

Edit: is this the answer?  If I go into Settings > Network Settings I can change the IPv4 Address Assignment to "static" and it fills in the current info for me.  Is that is?  It's that easy?

Yes.  It is that easy. 

 

Many prefer to assign the static address in the router if that is supported and leave unRAID at DHCP in Network Settings.  However, if your router does not support assigning static addresses to clients (most do support this).  The way you mentioned is the way to do it in unRAID.

  • Thanks 1
Link to comment

Doing that will indeed set the server's address as static but that particular address is one of the pool of addresses that your DHCP server can allocate to any device that requests one. Therefore it could just as easily allocate it to your phone or tablet or other connected device. If you want to set a static address on your server you need to choose one that isn't in the DHCP server's pool. Suppose, for example that your router address is 192.168.100.1 and the DHCP server's pool consists of the range 192.168.10.2 to 192.168.10.100, then any address between 192.168.10.101 and 192.168.10.254 would be safe to use, as long as it's unique and not allocated to anything else. If you use static addresses then you have to take responsibility for managing them.

  • Thanks 1
Link to comment
9 minutes ago, zero_koop said:

In a worst case scenario, if that were to happen (same IP addressed assigned to my phone)

Depending on how long your router allows DHCP addresses to be reserved and how often your server is offline will have a lot to do with determining if the server IP address can be assigned to another device. 

 

Some routers basically let DHCP assigned addresses persist permanently while others have a limit of 7 days or less.  Once your server grabs the preferred address, nothing else should get that same address assigned unless the server is forced to give it up or is offline.

 

I once had a router that did not make it easy to assign static IP addresses but allowed fairly long lease time.  To make sure that address would never be assigned elsewhere I did as John M said and set my DHCP pool to begin at 192.168.1.21 and left anything below .21 to be assigned as static addresses.  Worked great.

 

My current router allows static IPs to be assigned, but, I still keep DHCP to a range outside of the static addresses.

 

Just disconnecting the phone would not necessarily let the router reassign that address immediately unless you rebooted the server and it saw that address was available.

Edited by Hoopster
  • Like 1
Link to comment
2 hours ago, zero_koop said:

or the Nextcloud IP address static

Assigning static IP addresses to docker involves making the appropriate network selection in the docker container.

 

I set up a VLAN in my router and unRAID specifically for docker containers to which I wanted to assign a static IP address.  It shows up as Custom:br0.3 in the Network selection in the container.

 

image.thumb.png.6ea8c08f878974219f64d424161737a4.png

 

If you have your eth0 bridged in Network settings, you should also have a Custom:br0 that will allows the same.

 

I followed the same rules here as with static address and the router DHCP and I did not allow the VLAN in unRAID to assign DHCP addresses.  I wanted to manually assign them and so I made sure they were not in the router DHCP range as the router DHCP and VLAN DHCP have no concept of communicating with each other and need to be in separate ranges to avoid any possible conflicts.

Edited by Hoopster
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.