Dhcpd does not provide a gateway on the wifi side of a bridge

WRT1900ACSv2 attempt 2. This device is functional, and is so far working pretty well. I only have one outstanding problem. I've replaced dnsmasq with dhcpd and bind9, and everything is working fine ... except that wifi clients don't get an ipv4 default gateway.

IPv6 works fine via odhcpd and ethernet clients get v4 gateways provided.

Here's the kicker: ethernet and wifi are all on the same bridge (br-lan), which makes up vlan1 of the switch, as well as wlan0 and wlan1 (5ghz and 2.4ghz respectively). And wlan clients get everything but the gateway - they have no issues receiving a v4 address. But nothing shows up in the v4 routing table. I can even ping from wifi to lan and back. Just no default gateway.

Any ideas?

https://openwrt.org/docs/guide-user/base-system/dhcp_configuration#replacing_dnsmasq_with_odhcpd_and_unbound

uci show dhcp

So, you're saying to delete dhcpd?

The package odhcpd-ipv6only doesn't provide DHCPv4.
Follow the link above to set up odhcpd properly for dual-stack mode.

Hi there, thanks for your quick responses. I'm aware that odhcpd-ipv6only is .. well, ipv6 only.

But I'm using dhcpd. Not odhcpd. They're different daemons. Package isc-dhcp-server-ipv4. It's what I've been using on my previous dhcp/dns server, which was replaced due to stability issues.

Are you saying that the problem I'm facing is a bug in the isc dhcpd?

Okay, let's see the configuration, it may provide some clues.

option domain-name "mydomainname";

default-lease-time 600;

max-lease-time 7200;

authoritative;

subnet 192.168.174.0 netmask 255.255.255.0 {
    range 192.168.174.30 192.168.174.80;
    range 192.168.174.130 192.168.174.180;
    option subnet-mask 255.255.255.0;
    option broadcast-address 192.168.174.255;
    option routers 192.168.174.1;
    option domain-name-servers 192.168.174.1;
}

And then a bunch of hosts sections that look like:

host printer.mydomainname {
    hardware ethernet 8D:8D:8D:8D:8D:8D;
    fixed-address 192.168.174.88;
}

Here's the output of uci show dhcp, for good measure:

dhcp.lan=dhcp
dhcp.lan.interface='lan'
dhcp.lan.start='100'
dhcp.lan.limit='150'
dhcp.lan.leasetime='12h'
dhcp.lan.dhcpv6='server'
dhcp.lan.ra='server'
dhcp.lan.ra_management='1'
dhcp.wan=dhcp
dhcp.wan.interface='wan'
dhcp.wan.ignore='1'
dhcp.odhcpd=odhcpd
dhcp.odhcpd.maindhcp='0'
dhcp.odhcpd.leasefile='/tmp/hosts/odhcpd'
dhcp.odhcpd.leasetrigger='/usr/sbin/odhcpd-update'
dhcp.odhcpd.loglevel='4'

Thanks!
Gray.

opkg list-installed \*dhcp\*
netstat -l -n -p | grep -e dhcpd
pgrep -f -a dhcpd
isc-dhcp-server-ipv4 - 4.4.1-3
odhcp6c - 2018-07-14-67ae6a71-15
odhcpd-ipv6only - 1.15-3
root@CoreRouter:~# netstat -l -n -p | grep -e dhcpd
udp        0      0 0.0.0.0:67              0.0.0.0:*                           30226/dhcpd
udp        0      0 :::547                  :::*                                1651/odhcpd
raw        0      0 0.0.0.0:1               0.0.0.0:*               1           30226/dhcpd
raw        0      0 ::%3069689872:58        ::%428721:*             58          1651/odhcpd
raw        0      0 ::%3069689872:58        ::%428721:*             58          1651/odhcpd
root@CoreRouter:~# pgrep -f -a dhcpd
1651 /usr/sbin/odhcpd
30226 /usr/sbin/dhcpd -q -f -cf /tmp/run/dhcpd.conf -lf /tmp/dhcpd.leases br-lan

cat /etc/config/network ; cat /etc/config/wireless

config interface 'loopback'
	option ifname 'lo'
	option proto 'static'
	option ipaddr '127.0.0.1'
	option netmask '255.0.0.0'

config globals 'globals'
	option ula_prefix 'snip'

config interface 'lan'
	option type 'bridge'
	option ifname 'eth0.1'
	option proto 'static'
	option netmask '255.255.255.0'
	option ip6assign '64'
	option ip6hint 'snip'
	option ipaddr '192.168.174.1'

config interface 'wan'
	option ifname 'eth1.2'
	option proto 'pppoe'
	option ipv6 'auto'
	option username 'snip'
	option ac 'snip'
	option service 'snip'
	option password 'snip'

config interface 'wan6'
	option proto '6in4'
	option ifname '@wan'
	option peeraddr '216.66.88.98'
	option ip6addr 'snip'
	option ip6prefix 'snip'
	option ipaddr 'snip'

config switch
	option name 'switch0'
	option reset '1'
	option enable_vlan '1'

config switch_vlan
	option device 'switch0'
	option vlan '1'
	option ports '0 1 2 3 5t'

config switch_vlan
	option device 'switch0'
	option vlan '2'
	option ports '4 6t'


config wifi-device 'radio0'
	option type 'mac80211'
	option hwmode '11a'
	option path 'soc/soc:pcie/pci0000:00/0000:00:01.0/0000:01:00.0'
	option htmode 'VHT80'
	option country 'GB'
	option channel '48'
	option legacy_rates '1'

config wifi-iface 'default_radio0'
	option device 'radio0'
	option network 'lan'
	option mode 'ap'
	option macaddr 'snip'
	option ssid 'snip'
	option encryption 'psk2+ccmp'
	option key 'snip'

config wifi-device 'radio1'
	option type 'mac80211'
	option channel '11'
	option hwmode '11g'
	option path 'soc/soc:pcie/pci0000:00/0000:00:02.0/0000:02:00.0'
	option htmode 'HT20'
	option country 'GB'
	option legacy_rates '1'

config wifi-iface 'default_radio1'
	option device 'radio1'
	option network 'lan'
	option mode 'ap'
	option macaddr 'snip'
	option ssid 'snip'
	option encryption 'psk2+ccmp'
	option key 'snip'
cat /tmp/run/dhcpd.conf
authoritative;
default-lease-time 3600;
max-lease-time 86400;
subnet 192.168.174.0 netmask 255.255.255.0 {
 range 192.168.174.100 192.168.174.250;
 option subnet-mask 255.255.255.0;
 option broadcast-address 192.168.174.255;
 default-lease-time 43200;
 max-lease-time 43200;
 option routers 192.168.174.1;
 option domain-name-servers 192.168.174.1;
}

It seems that persistent configuration is overridden by UCI configuration.
Although it doesn't change option routers, option range is affected.

Your original issue looks more like a bug.
I suggest to try odhcpd as I have no issues using it for both DHCPv4 and DHCPv6.

A couple of things to try:

  1. Disable DHCP on LAN interface ( dhcp.lan.ignore='1')
  2. Packet capture on a wireless host to verify the contents of the dhcp offer.

Ok, here's the latest - replaced dhcpd with odhcpd. Here's my config:

dhcp.lan=dhcp
dhcp.lan.interface='lan'
dhcp.lan.start='100'
dhcp.lan.limit='150'
dhcp.lan.leasetime='12h'
dhcp.lan.dhcpv6='server'
dhcp.lan.ra='server'
dhcp.lan.ra_management='1'
dhcp.lan.dhcpv4='server'
dhcp.lan.domain='snip'
dhcp.lan.dns='192.168.174.1'
dhcp.wan=dhcp
dhcp.wan.interface='wan'
dhcp.wan.ignore='1'
dhcp.odhcpd=odhcpd
dhcp.odhcpd.leasefile='/tmp/hosts/odhcpd'
dhcp.odhcpd.leasetrigger='/usr/sbin/odhcpd-update'
dhcp.odhcpd.loglevel='4'
dhcp.odhcpd.maindhcp='1'
dhcp.@host[9].mac='fc:f8:ae:55:ec:59'
dhcp.@host[9].ip='192.168.174.88'
dhcp.@host[9].hostid='GAFF'

There's obviously a few more hosts in there. But as an example, that host now isn't getting the provided IP address, and there are still no gateways being provided.

I'll open up wireshark next.

Edit: Ok, nothing is getting an IP address any more.

I post my working configuration, so you can compare it with yours:

# opkg list-installed \*dhcp\*
odhcp6c - 2018-07-14-67ae6a71-15
odhcpd - 1.15-3

# netstat -l -n -p | grep -e dhcpd
udp        0      0 0.0.0.0:67              0.0.0.0:*                           8728/odhcpd
udp        0      0 :::547                  :::*                                8728/odhcpd
raw        0      0 ::%1:58                 ::%4448380:*            58          8728/odhcpd
raw        0      0 ::%1:58                 ::%4448380:*            58          8728/odhcpd

# pgrep -f -a dhcpd
8728 /usr/sbin/odhcpd

# uci show dhcp
dhcp.lan=dhcp
dhcp.lan.interface='lan'
dhcp.lan.start='100'
dhcp.lan.limit='150'
dhcp.lan.leasetime='12h'
dhcp.lan.dhcpv4='server'
dhcp.lan.dhcpv6='server'
dhcp.lan.ra='server'
dhcp.lan.dns='8.8.8.8' '8.8.4.4'
dhcp.odhcpd=odhcpd
dhcp.odhcpd.maindhcp='1'
dhcp.odhcpd.leasefile='/tmp/hosts/odhcpd'
dhcp.odhcpd.leasetrigger='/usr/sbin/odhcpd-update'
dhcp.odhcpd.loglevel='4'
dhcp.@host[0]=host
dhcp.@host[0].mac='00:28:f8:91:28:91'
dhcp.@host[0].ip='192.168.1.2'
dhcp.@host[0].name='vglaptop'

# grep 192.*vglaptop /tmp/hosts/odhcpd 
192.168.1.2	vglaptop

Thanks everyone, I seem to have it working now, but with only one remaining host which isn't getting the gateway - so I'm going to assume that machine's just possessed, and have done with it.

2 Likes

If your problem is solved, feel free to mark the relevant post as the solution; and edit the title to add "[SOLVED]" to the beginning (click the pencil behind the topic).

grafik