What's new

How to Force Router to use Next IP Number instead of Random??

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

Forerunner

Occasional Visitor
Is there a way to force the router to pick the next IP number for a local device for example my Laptop would be 192.168.1.2 is there a way to force the next client to be given the ip 192.168.1.3? etc and also for the router DHCP to give a random IP each time as for some reason my devices get the same IP back even when they disconnect and reconnect a week later they are given the same local IP even when i don't have any static IP's selected.

Thanks
 
Use the following parameter with dnsmasq
--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.​
 
Is there a way to force the router to pick the next IP number for a local device for example my Laptop would be 192.168.1.2 is there a way to force the next client to be given the ip 192.168.1.3? etc and also for the router DHCP to give a random IP each time as for some reason my devices get the same IP back even when they disconnect and reconnect a week later they are given the same local IP even when i don't have any static IP's selected.

Thanks
The default IP is based on a hash of the client mac address within the set DHCP range (it's generally desirable for a client to always get the same address even if it's not manually assigned). There's no way to assign a random IP that I know of.

For sequentially assigned IPs, make a /jffs/configs/dnsmasq.conf.add with the following line

dhcp-sequential-ip

Note that this means your IP address is likely to change depending on how many clients are connected.
 
Is there a way to force the router to pick the next IP number for a local device for example my Laptop would be 192.168.1.2 is there a way to force the next client to be given the ip 192.168.1.3? etc and also for the router DHCP to give a random IP each time as for some reason my devices get the same IP back even when they disconnect and reconnect a week later they are given the same local IP even when i don't have any static IP's selected.

i will be the devils advocate here and ask why is there a need not to let the router do as it pleases , how does this effect your connection and or internet ?

the only reason this would be an issue is if access control is activated and blocking access via ip address and changing ip addresses bypasses the block ( which usually isnt the case as mac addresses are used for access control anyway )

so whats your problem with getting the same ip address a week later as its got no effect on anything you do on the internet and only effects internal usage within your lan / wlan
 
I would think the easiest way to do that is just go to
Manually Assigned IP around the DHCP list
and manually give the IP address you want via the DHCP server to specific devices.
this way you can have your sequential numbers :)
or just give static IP address's to all your devices.
 
The default IP is based on a hash of the client mac address within the set DHCP range (it's generally desirable for a client to always get the same address even if it's not manually assigned). There's no way to assign a random IP that I know of.

For sequentially assigned IPs, make a /jffs/configs/dnsmasq.conf.add with the following line

dhcp-sequential-ip

Note that this means your IP address is likely to change depending on how many clients are connected.


There isn't a particular reason I want to have this setup just makes it easier when I want to FTP into several of my TV Sub Boxes. I have done that and it didn't give the IPs in order.

My dnsmasq.conf.add looks like this

no-resolv
server=127.0.0.1#65053
dhcp-sequential-ip
 
We'd have to see all the DHCP entries in the syslog to fully understand what's going on.

But typically a client will ask the DHCP server for the same address that it previously had and the server will give it to it. If the client doesn't know what address it previously had (or it's forgotten it, or the lease has expired) it will send a DHCPDISCOVER message. It is only in this scenario that the DHCP server will issue a new/different IP address.

Even then there's no guarantee what address you will get. It would be far better to create a DHCP reservation for each of the devices you are concerned about. That way you can be sure of their addresses.
 
Last edited:
There isn't a particular reason I want to have this setup just makes it easier when I want to FTP into several of my TV Sub Boxes. I have done that and it didn't give the IPs in order.
Did you reboot the router after making the change (or service restart_dnsmasq)?
Also, for wired clients, they generally remember their last IP and will re-request the same one as Colin said. Windows especially had a long memory. You may need to reboot the clients to pick up the change or do an ipconfig /release, ipconfig /renew on those.
 
I believe its working now. The numbers are starting from 162 because it looks like my Network switch is forcing its IP and everything else is then counting after that.
 
i will be the devils advocate here and ask why is there a need not to let the router do as it pleases , how does this effect your connection and or internet ?

I agree - as long as it's within scope and not a reserved DHCP address...

Not much bother...
 

Latest threads

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top