OpenWrt Forum Archive

Topic: [EDIT] ODHCPD and static DHCP stops working for dynamic clients

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

I have a recurring issue where DHCP stops working.  I am using the latest trunk on a DIR 835.

The log shows that  upon renewal, a NAK is sent:

Wed Jan 28 21:20:04 2015 daemon.warn odhcpd[1230]: received DHCPV4_MSG_REQUEST from 0:15:65:29:75:54
Wed Jan 28 21:20:04 2015 daemon.warn odhcpd[1230]: sending DHCPV4_MSG_NAK to ff:ff:ff:ff:ff:ff - 255.255.255.255

following that, all further DHCP requests go unanswered.  If I simply restart odhcpd, it starts working again (/etc/init.d/odhcpd restart)

Wed Jan 28 21:27:26 2015 daemon.info dnsmasq[1994]: read /etc/hosts - 1 addresses
Wed Jan 28 21:27:26 2015 daemon.info dnsmasq[1994]: read /tmp/hosts/odhcpd - 0 addresses
Wed Jan 28 21:27:26 2015 daemon.info dnsmasq[1994]: read /tmp/hosts/dhcp - 1 addresses
Wed Jan 28 21:27:49 2015 daemon.warn odhcpd[3328]: received DHCPV4_MSG_DISCOVER from 0:15:65:29:75:54
Wed Jan 28 21:27:49 2015 daemon.warn odhcpd[3328]: sending DHCPV4_MSG_OFFER to 0:15:65:29:75:54 - 192.168.199.161
Wed Jan 28 21:27:49 2015 daemon.warn odhcpd[3328]: received DHCPV4_MSG_REQUEST from 0:15:65:29:75:54
Wed Jan 28 21:27:49 2015 daemon.warn odhcpd[3328]: sending DHCPV4_MSG_ACK to 0:15:65:29:75:54 - 192.168.199.161

I don't know if this is related to the problem I have as well where if I specify a static lease, ALL DHCP except the static lease doesn't work.  myself and another user had noted this.  here is the config of /etc/config/dhcp

config dnsmasq
    option rebind_protection '1'
    option rebind_localhost '1'
    option local '/lan/'
    option domain 'lan'
    option leasefile '/tmp/dhcp.leases'
    option resolvfile '/tmp/resolv.conf.auto'
    option authoritative '1'
    option dhcpleasemax '100'
    option domainneeded '1'

config dhcp 'lan'
    option interface 'lan'
    option start '100'
    option dhcpv6 'server'
    option ra 'server'
    option ra_management '1'
    option limit '100'
    option leasetime '10m'
    option force '1'

config dhcp 'wan'
    option interface 'wan'
    option ignore '1'

config odhcpd 'odhcpd'
    option leasefile '/tmp/hosts/odhcpd'
    option leasetrigger '/usr/sbin/odhcpd-update'
    option maindhcp '1'

I have tried different lease times, 1h, 1d, 2d 10m etc and the DHCP always eventually goes belly up.  Any tips as to what I should look for to fix?

(Last edited by cconn on 6 Mar 2015, 00:40)

I am still trying to figure this out so I built a new trunk for a new router, DIR-615, and I have the exact same problem.

I found this thread:

https://forum.openwrt.org/viewtopic.php?id=51330


strangely, if I do the opposite, I am able to have both static and dynamic DHCP if I set the following

"option maindhcp '0'

under the odhcpd section.

How can I debug this?  (humbly paging CyrusFF......)

If I do not have any static DHCP configured from LuCI, DHCP for dynamic clients works.  As soon as I define a single static DHCP host, it no longer works, unless I set the maindhcp to 0 under odhcpd.

(Last edited by cconn on 6 Mar 2015, 00:39)

I'm curious as to why odhcpd is providing you with DHCP for ipv4? I run the latest trunk and dhcp is still handled by dnsmasq in my builds. I don't do any customization to my builds other than installing a few extra packages (like tcpdump, openvpn, wget, and a few others). I have numerous static DHCP leases, probably 20 or so, and those all work perfectly fine. What image are you running?

(Last edited by adam2104 on 6 Mar 2015, 03:04)

adam2104 wrote:

I'm curious as to why odhcpd is providing you with DHCP for ipv4? I run the latest trunk and dhcp is still handled by dnsmasq in my builds. I don't do any customization to my builds other than installing a few extra packages (like tcpdump, openvpn, wget, and a few others). I have numerous static DHCP leases, probably 20 or so, and those all work perfectly fine. What image are you running?

I am running a recent trunk i built from svn, and I don't think I have customized anything related to dhcp/odhcpd/dnsmasq.  I chose pretty much standard packages and added IPv6 stuff such as 6rd and some LuCI stuff.  All my wrt configs I do from LuCI.

here is the contents of my dhcp file;

config dnsmasq
    option rebind_protection '1'
    option rebind_localhost '1'
    option local '/lan/'
    option domain 'lan'
    option leasefile '/tmp/dhcp.leases'
    option resolvfile '/tmp/resolv.conf.auto'
    option dhcpleasemax '100'
    option domainneeded '1'
    option localservice '0'

config dhcp 'lan'
    option interface 'lan'
    option start '100'
    option dhcpv6 'server'
    option ra 'server'
    option ra_management '1'
    option limit '100'
    option force '1'
    option leasetime '10d'

config dhcp 'wan'
    option interface 'wan'
    option ignore '1'

config odhcpd 'odhcpd'
    option leasefile '/tmp/hosts/odhcpd'
    option leasetrigger '/usr/sbin/odhcpd-update'
    option maindhcp '1'

if I leave maindhcp to 1 (which I did not set, it was built this way), I can't add any static DHCP entries from LuCI and have dynamic DHCP as well; as soon as I add a static entry, static DHCP is served correctly, but all dynamic DHCP clients fail.

(Last edited by cconn on 6 Mar 2015, 04:14)

That's odd. What target are you running? I'm building ar71xx images for the Netgear WNDR3800 and the WD My Net 750, neither of which is using odhcpd.

adam2104 wrote:

That's odd. What target are you running? I'm building ar71xx images for the Netgear WNDR3800 and the WD My Net 750, neither of which is using odhcpd.

here is my .config on pastebin;

http://pastebin.com/7dDkjCzE

I build for DIR-615-E4 and DIR-835-A1 and in both cases, the odhcpd is a required package as I cannot unselect it, so it is obviously used for something.  And I don't tweak the config files for network or dhcp, the trunk build makes them automatically.


in both, the "option maindhcp '1' " is always set, and if I disable this, I can have both dynamic and static dhcp

mind sharing your .config?

(Last edited by cconn on 6 Mar 2015, 16:19)

amazingly, I saw this this morning:

Changeset 44619 for trunk
View differences
Show lines around each change
Show the changes in full context
Ignore:
Blank lines
Case changes
White space changes

Timestamp:
    2015-03-06T15:41:07+01:00 (6 hours ago) 
Author:
    cyrus
Message:

    odhcpd: improvements for DHCPv4 and compile fixes

    Signed-off-by: Steven Barth <steven@…>

I rebuilt a new trunk from svn, erased my configs and even with "option maindhcp '1' " it works now.

so I am guessing this fixed it.  huh

My .config starts out as this:

# target
CONFIG_TARGET_ar71xx=y
CONFIG_TARGET_ar71xx_generic=y
CONFIG_TARGET_ar71xx_generic_WNDR3700=y

# ddns
CONFIG_PACKAGE_ddns-scripts=y

# luci
CONFIG_PACKAGE_luci-ssl=y
CONFIG_PACKAGE_luci-app-commands=y
CONFIG_PACKAGE_luci-app-ddns=y
CONFIG_PACKAGE_luci-proto-ipv6=y

# qos
CONFIG_PACKAGE_iptables-mod-ipopt=y
CONFIG_PACKAGE_kmod-sched=y
CONFIG_PACKAGE_tc=y

# utils
CONFIG_PACKAGE_ca-certificates=y
CONFIG_PACKAGE_iftop=y
CONFIG_PACKAGE_netcat=y
CONFIG_PACKAGE_wget=y
CONFIG_PACKAGE_tcpdump=y

# vpn
CONFIG_PACKAGE_openvpn-openssl=y

Then I fill it in with "make defconfig". So, nothing fancy there. I take whatever the defaults are after enabling the above packages. I find it odd that "maindhcp" is set to 1 in your config. It's 0 on mine.

(Last edited by adam2104 on 7 Mar 2015, 02:48)

I should mention that I do disable odhcpd to kill ipv6 addressing because it causes slow performance and issues with wifi sync'ing of my iDevices. However, I don't change "maindhcp" in /etc/config/dhcp. I merely disable things using a uci-defaults/99-myboot script.

# disable ipv6
/etc/init.d/odhcpd disable
RULES=`uci show firewall | grep family=ipv6 | awk -F'.' '{ print $1"."$2 }' | sort -r`
for RULE in $RULES; do
    uci delete $RULE
done

# remove wan6
uci delete firewall.@zone[1].network
uci add_list firewall.@zone[1].network='wan'
uci delete network.wan6
uci delete network.lan.ip6assign
uci delete network.globals

Perhaps that's why I don't see the issue. But again, I'm not fiddling with 'maindhcp' so I'm not sure.

adam2104 wrote:

I should mention that I do disable odhcpd to kill ipv6 addressing because it causes slow performance and issues with wifi sync'ing of my iDevices. However, I don't change "maindhcp" in /etc/config/dhcp. I merely disable things using a uci-defaults/99-myboot script.

# disable ipv6
/etc/init.d/odhcpd disable
RULES=`uci show firewall | grep family=ipv6 | awk -F'.' '{ print $1"."$2 }' | sort -r`
for RULE in $RULES; do
    uci delete $RULE
done

# remove wan6
uci delete firewall.@zone[1].network
uci add_list firewall.@zone[1].network='wan'
uci delete network.wan6
uci delete network.lan.ip6assign
uci delete network.globals

Perhaps that's why I don't see the issue. But again, I'm not fiddling with 'maindhcp' so I'm not sure.

I didn't tweak maindhcp, it would appear to be a default.  That said we clearly have a divergence since you are trying to have as little IPv6 as possible and I on the other hand am trying to build a IPv6 capable CPE.

In any case, I am going to tell myself r44619 fixed it for me smile

The discussion might have continued from here.