Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> My router assigns dynamic IP addresses, meaning my server location kept changing.

I've had a similar problem in the past. It turns out that most routers have a way to assign an IP address statically based on the MAC address of the requesting device without affecting the other DHCP devices on the network.

I do this for my pi-hole, my NAS and my gaming PC.



> Dynamic IPs

I thought that step one of geekdom was assigning a few static IPs.

Ruining the home network while ‘optimising’ has happened a few too many times.


As long as that's on the router's side. I guess I did that on my phone for some reason so when I upgraded and migrated they had the same address. I'm surprised it worked at all. It was just painfully slow.


The wording can vary quite a bit: I've seen names like static, fixed, DHCP reservation, etc. -- I tend to like DHCP reservation, because from the client's perspective, "static" means not using DHCP, but this does use DHCP (just not the pool).


Most home routers also have some addresses that are outside the range managed by DHCP, or if DHCP is set to manage the entire range of LAN address have a setting where you can reduce that range. This gives you a third way to manage static assignments.

Let's assume the LAN is 10.0.0/24, so addresses of devices on the LAN are 10.0.0.1-10.0.0.254. In the following I'll omit the 10.0.0. part of an address, so will just refer to addresses 1-254.

Find the range DHCP manages, which should be somewhere in the router settings. If it is 1-254 reduce it. Let's say it is 1-200 (either by default or after you have reduced it).

Then you can simply go the settings on your server or other device that you want to have a static address and configure it to use a hard coded address outside that range, such as 201.

A possible downside of that is that on some devices if you want to give it a hard coded address you also have to hard code the gateway address and the name servers.

Some devices though have an option to use a hard coded address but still get the gateway and name servers from DHCP.

In summary, there are three ways to manage address for a given device on most home routers.

1. DHCP assigns the address. It can choose any address in its pool. Each time the device needs an IP address, such as after a boot or when its lease expires, it could get a different IP address.

2. DHCP assigns the address, but you can tell it to give a specific address from the pool to a given device identified by the device's MAC address.

3. Tell the device to use an address outside the router's DHCP pool. It's up to you to decide how to assign these address and how to make sure no conflicts arise.

For #2 if you want some device to have a fixed IP address but you don't actually care what that address is, many routers have an easy way to do that. Connect the device under #1, so DHCP picks the address.

Then go find the table in the router's web interface that shows all currently connected devices and find your device. Many routers will have a toggle in there to tell it to switch to #2 for that device. From then on the device's current address will be reserved for it.

That's a little easier than going through their "assign an IP" dialog, because that usually makes you enter the MAC address. If you go through the connection table details it doesn't have to ask you for the MAC address.


What's bizarre is that my previous TP-Link routers alawys had this ability, but when I upgraded two years ago, it was gone.


My current TP-Link router hides this behind the "Advanced" settings toggle.


I've got a TP-Link Archer C7, hardware version 5. No such toggle unfortunately, but thanks nevertheless. Perhaps I should try and flash it with OpenWRT.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: