OpenWrt Forum Archive

Topic: WAN LAN DHCP Question

The content of this topic has been archived on 29 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

I am having the following issues 

1. Every time I restart the router I get a new WAN IP address from cable, using any other router I get the same WAN IP. The WAN is DHCP.

2. The LAN IP gives out IP address not in a conservative order like 192.168.1.100 192.168.1.101 it will just use anything from the range of the LAN DHCP address, can this be changed?

3. Every time we restart the router we lose the LAN leases how is the best way to write it in flash.

My developer claims this is how udhcp works, can it be changed or should we use something else for the DHCP? 

Thanks

2.
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.

UCI doesn't implement the dhcp-sequential-ip as far as I can tell, so you will have to find a way to pass the parameter directly to dnsmasq. You can probably do it by editing /etc/init.d/dnsmasq. Not pretty, but it'll work. This is probably the simplest approach:

Change:

procd_set_param command $PROG -C $CONFIGFILE -k

To:

procd_set_param command $PROG -C $CONFIGFILE -k --dhcp-sequential-ip

3.
Do you lose configured static leases? Or is it just that the router status page no longer shows the current leases? You could log the leases to external syslog for historical purposes. You can set shorter leasetimes, which will cause clients to renew (and thus make the router aware of the lease) quicker after a reboot. If you really want to, you can change "option leasefile '/tmp/dhcp.leases'" in /etc/config/dhcp to a path in flash memory, but as flash memory has limited write cycles I wouldn't do this.

(Last edited by makro on 19 May 2014, 09:35)

The discussion might have continued from here.