Assign DHCP IP Addresses in Incremental Order?

I would like my home network IPs to be simple and memorable. For my main devices, I want to manually assign them (main PC -> 10.0.0.10). But for random devices that join the network, it would be nice if they also got simple IPs. I think 25 or 50 IPs is the most my network will have. A "simple" IP to me might be the smallest integer in 10.0.0.[1-255] that is available that hasn't already been assigned. (I want to change my main IP range to be 10.x.y.z but that's a different topic.)

This is my current IP list, most of these were assigned automatically.

ips

Is there a way with openwrt / dnsmasq to assign rules about dhcp assignment? One of my lxc containers on my proxmox server got assigned 192.168.1.122 and I'm not sure why. There are plenty of IPs in the x.y.z.10-121 range that were available.

From the dnsmasq man page:

--dhcp-sequential-ip Dnsmasq is designed to choose IP addresses for DHCP clients using a hash of the client's MAC address. This normally allows a client's address to remain stable long-term, even if the client sometimes allows its DHCP lease to expire. In this default mode IP addresses are distributed pseudo-randomly over the entire available address range. There are sometimes circumstances (typically server deployment) where it is more convenient to have IP addresses allocated sequentially, starting from the lowest available address, and setting this flag enables this mode. Note that in the sequential mode, clients which allow a lease to expire are much more likely to move IP address; for this reason it should not be generally used.

In LuCI, there is an option in "DHCP and DNS" called "Allocate IPs sequentially". This sets the sequential_ip configuration option and should do what you want.

2 Likes

Hey

Network - DHCP And DNS - General - check Allocate IPs sequentially

Check mobile phones dont have random mac on the wifi network

2 Likes

If I do have "known" devices that I want to keep static (PCs, containers, servers, phones) is the best way to make them static Openwrt? Or should I change anything on the client side?

I clicked the link and it was a link to a plumbing contractor's site. Someone did notice that almost immediately and removed it. If you didn't intend it to be spam it certainly was.

There is a reason those two were deleted.

Yeah best to set them static aswell in OpenWRT. Case when a phone or computer is disconnected for a period of time, The router might give out that IP to something else.

Least then OpenWRT will know not to use that address for another device.

1 Like

I agree with @anon24915552 except that there might be cases where a static IP makes sense, e.g. when the DHCP server is down. Just make sure to assign an IP address outside of the DHCP range (the default range starts at 192.168.1.100, so anything below 192.168.1.100 can be safely assigned statically).

I use static IP’s for all my trusted devices starting at 10.10.1.100-250 incrementing by 5 with leases set at infinite and everything else assigned starting at 2-19 using the DHCP option sequestial_ip '1' with lease time set at 5 Min.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.