[Solved] Wifi DHCP not working on CM4 with DFRobot

Im actually tryin to get my wifi working on a CM4 with DFRobot hat its a great setup and has worked well for as long as I've had it but I'd like to be able to connect directly to the CM4's wifi if/when needed.

I can actually connect to the CM4 wireless but its not getting an IP address from the DHCP from the LAN.

Network Configuration:

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

config globals 'globals'

config interface 'lan'
option proto 'static'
option netmask '255.255.255.0'
option device 'eth1'
option ipaddr '192.168.1.1'
list dns '192.168.1.4'

config interface 'wan'
option device 'eth0'
option proto 'dhcp'
option type 'bridge'

config interface 'wlan'
option proto 'none'
option device 'radio0.network1'

Wireless Configuration:

config wifi-device 'radio0'
option type 'mac80211'
option path 'platform/soc/fe300000.mmcnr/mmc_host/mmc1/mmc1:0001/mmc1:0001:1'
option band '5g'
option htmode 'VHT80'
option channel 'auto'
option cell_density '0'

config wifi-iface 'default_radio0'
option device 'radio0'
option ssid 'OpenWrt'
option encryption 'psk2'
option key 'PASSWORD'
option mode 'ap'
option network 'lan wlan'

DHCP Configuration:

config dnsmasq
        option domainneeded '1'
        option localise_queries '1'
        option rebind_protection '1'
        option rebind_localhost '1'
        option local '/lan/'
        option domain 'lan'
        option expandhosts '1'
        option authoritative '1'
        option readethers '1'
        option leasefile '/tmp/dhcp.leases'
        option resolvfile '/tmp/resolv.conf.d/resolv.conf.auto'
        option localservice '1'
        option ednspacket_max '1232'

config dhcp 'lan'
        option interface 'lan'
        option leasetime '12h'
        option dhcpv4 'server'
        option start '50'
        option limit '200'
        list dhcp_option '6,192.168.1.4'
        option force '1'

config dhcp 'wan'
        option interface 'wan'
        option ignore '1'
        list ra_flags 'none'

I see several errors:

First, you need a bridge for your lan...

Add this:

config device
	option name 'br-lan'
	option type 'bridge'
	list ports 'eth1'

Then, exit your lan to use the bridge (you can also remove the dns line here, it does nothing):

config interface 'lan'
    option proto 'static'
    option netmask '255.255.255.0'
    option device 'br-lan'
    option ipaddr '192.168.1.1'

Next, remove the wlan interface you created... it doesn't belong here, just delete:

Also remove the bridge line in your wan interface... that doesn't belong there:

In your wireless file, the only network that should be associated with the radio is the lan. Remove wlan.

Then, restart and test again.

Okay I did this, i tripled checked before saving config files and rebooted. Now the I cant login to the router and the network is down :expressionless:

Try failsafe mode, and then post your config files here:

Please connect to your OpenWrt device using ssh and copy the output of the following commands and post it here using the "Preformatted text </> " button:
grafik
Remember to redact passwords, MAC addresses and any public IP addresses you may have:

ubus call system board
cat /etc/config/network
cat /etc/config/wireless
cat /etc/config/dhcp
cat /etc/config/firewall

First off thanks for looking into this with me. I was able to get the LAN back up by using putty/UART and changing the lan interface option back to eth1 from the br-lan change i made

So the lan for the house is back up but if I try to connect directly to the PiCM4's built in wifi same problem, it makes the connection but it doesnt assign an IP from the Lan. I have to be missing the smallest detail

Network Config

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

config globals 'globals'

config interface 'lan'
        option proto 'static'
        option netmask '255.255.255.0'
        option device 'eth1'
        option ipaddr '192.168.1.1'

config interface 'wan'
        option device 'eth0'
        option proto 'dhcp'

config device
        option type 'br-lan'
        option name 'bridge'
        list ports 'eth1'

Wireless config

config wifi-device 'radio0'
        option type 'mac80211'
        option path 'platform/soc/fe300000.mmcnr/mmc_host/mmc1/mmc1:0001/mmc1:0>
        option band '5g'
        option htmode 'VHT80'
        option channel 'auto'
        option cell_density '0'

config wifi-iface 'default_radio0'
        option device 'radio0'
        option ssid 'OpenWrt'
        option encryption 'psk2'
        option key 'PASSWORD'
        option mode 'ap'
        option network 'lan'

DHCP Config

config dnsmasq
        option domainneeded '1'
        option localise_queries '1'
        option rebind_protection '1'
        option rebind_localhost '1'
        option local '/lan/'
        option domain 'lan'
        option expandhosts '1'
        option authoritative '1'
        option readethers '1'
        option leasefile '/tmp/dhcp.leases'
        option resolvfile '/tmp/resolv.conf.d/resolv.conf.auto'
        option localservice '1'
        option ednspacket_max '1232'

config dhcp 'lan'
        option interface 'lan'
        option leasetime '12h'
        option dhcpv4 'server'
        option start '50'
        option limit '200'
        list dhcp_option '6,192.168.1.4'
        option force '1'

config dhcp 'wan'
        option interface 'wan'
        option ignore '1'
        list ra_flags 'none'

config odhcpd 'odhcpd'
        option maindhcp '0'
        option leasefile '/tmp/hosts/odhcpd'
        option leasetrigger '/usr/sbin/odhcpd-update'
        option loglevel '4'

config host
        option dns '1'
        option ip '192.168.1.2'
        option mac 'XXXXXXXX'
        option name 'WRT3200ACM'

config host
        option name 'PiholePiVPN'
        option dns '1'
        option mac 'XXXXXXXX'
        option ip '192.168.1.4'

Firewall config


config defaults
	option input 'ACCEPT'
	option output 'ACCEPT'
	option forward 'REJECT'
	option synflood_protect '1'

config zone
	option name 'lan'
	option input 'ACCEPT'
	option output 'ACCEPT'
	option forward 'ACCEPT'
	list network 'lan'
	list network 'wlan'

config zone
	option name 'wan'
	option input 'REJECT'
	option output 'ACCEPT'
	option forward 'REJECT'
	option masq '1'
	option mtu_fix '1'
	list network 'wan'

config forwarding
	option src 'lan'
	option dest 'wan'

config rule
	option name 'Allow-DHCP-Renew'
	option src 'wan'
	option proto 'udp'
	option dest_port '68'
	option target 'ACCEPT'
	option family 'ipv4'

config rule
	option name 'Allow-Ping'
	option src 'wan'
	option proto 'icmp'
	option icmp_type 'echo-request'
	option family 'ipv4'
	option target 'ACCEPT'

config rule
	option name 'Allow-IGMP'
	option src 'wan'
	option proto 'igmp'
	option family 'ipv4'
	option target 'ACCEPT'

config rule
	option name 'Allow-DHCPv6'
	option src 'wan'
	option proto 'udp'
	option src_ip 'fc00::/6'
	option dest_ip 'fc00::/6'
	option dest_port '546'
	option family 'ipv6'
	option target 'ACCEPT'

config rule
	option name 'Allow-MLD'
	option src 'wan'
	option proto 'icmp'
	option src_ip 'fe80::/10'
	list icmp_type '130/0'
	list icmp_type '131/0'
	list icmp_type '132/0'
	list icmp_type '143/0'
	option family 'ipv6'
	option target 'ACCEPT'

config rule
	option name 'Allow-ICMPv6-Input'
	option src 'wan'
	option proto 'icmp'
	list icmp_type 'echo-request'
	list icmp_type 'echo-reply'
	list icmp_type 'destination-unreachable'
	list icmp_type 'packet-too-big'
	list icmp_type 'time-exceeded'
	list icmp_type 'bad-header'
	list icmp_type 'unknown-header-type'
	list icmp_type 'router-solicitation'
	list icmp_type 'neighbour-solicitation'
	list icmp_type 'router-advertisement'
	list icmp_type 'neighbour-advertisement'
	option limit '1000/sec'
	option family 'ipv6'
	option target 'ACCEPT'

config rule
	option name 'Allow-ICMPv6-Forward'
	option src 'wan'
	option dest '*'
	option proto 'icmp'
	list icmp_type 'echo-request'
	list icmp_type 'echo-reply'
	list icmp_type 'destination-unreachable'
	list icmp_type 'packet-too-big'
	list icmp_type 'time-exceeded'
	list icmp_type 'bad-header'
	list icmp_type 'unknown-header-type'
	option limit '1000/sec'
	option family 'ipv6'
	option target 'ACCEPT'

config rule
	option name 'Allow-IPSec-ESP'
	option src 'wan'
	option dest 'lan'
	option proto 'esp'
	option target 'ACCEPT'

config rule
	option name 'Allow-ISAKMP'
	option src 'wan'
	option dest 'lan'
	option dest_port '500'
	option proto 'udp'
	option target 'ACCEPT'

config rule
	option name 'Support-UDP-Traceroute'
	option src 'wan'
	option dest_port '33434:33689'
	option proto 'udp'
	option family 'ipv4'
	option target 'REJECT'
	option enabled 'false'

config include
	option path '/etc/firewall.user'

config redirect
	option target 'DNAT'
	option name 'PiPlex'
	list proto 'tcp'
	option src 'wan'
	option src_dport '32400'
	option dest 'lan'
	option dest_ip '192.168.1.10'
	option dest_port '32400'

config redirect
	option target 'DNAT'
	option name 'PiVPN'
	list proto 'udp'
	option src 'wan'
	option src_dport '51820'
	option dest 'lan'
	option dest_ip '192.168.1.4'
	option dest_port '51820'

config redirect
	option dest 'lan'
	option target 'DNAT'
	option name 'Channels'
	list proto 'tcp'
	option src 'wan'
	option src_dport '8089'
	option dest_ip '192.168.1.10'

config nat
	list proto 'tcp'
	list proto 'udp'
	option src 'lan'
	option dest_ip '192.168.1.4'
	option dest_port '53'
	option target 'MASQUERADE'
	option name 'Pi-hole DNS Intercept'

config redirect
	option dest 'lan'
	option target 'DNAT'
	option src 'lan'
	option src_ip '!192.168.1.4'
	option src_dport '53'
	option dest_ip '192.168.1.4'
	option dest_port '53'
	option name 'Pi-Hole DNS Intercept'

config forwarding
	option dest 'lan'

config forwarding
	option src 'lan'

config forwarding
	option dest 'lan'

config forwarding
	option src 'lan'

config forwarding
	option dest 'lan'

config forwarding
	option src 'lan'

This must be connected to a bridge if the goal is to have wifi + ethernet connectivity. So, br-lan is the correct option to be used instead of eth1... I'm not sure why it is causing a problem, though.

Meanwhile... remove wlan from the lan firewall zone:

And delete all of these:

Can you provide the output of this:

{
	"kernel": "5.10.161",
	"hostname": "OpenWrt",
	"system": "ARMv8 Processor rev 3",
	"model": "Raspberry Pi Compute Module 4 Rev 1.0",
	"board_name": "raspberrypi,4-compute-module",
	"rootfs_type": "ext4",
	"release": {
		"distribution": "OpenWrt",
		"version": "22.03.3",
		"revision": "r20028-43d71ad93e",
		"target": "bcm27xx/bcm2711",
		"description": "OpenWrt 22.03.3 r20028-43d71ad93e"
	}
}

Ok... that looks fine.

Once you fix the other things I mentioned, change your lan device to br-lan (but don't restart)... then post the config files once again for review.

1 Like

Okay - Changed, saved, not rebooted. Admittedly i made a dumb mistake, when i typed it in i originally had entered it as
option name 'bridge'
option type 'br-lan'

I made the corrections as it reads below, waiting to reboot

root@OpenWrt:~# cat /etc/config/network 

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

config globals 'globals'

config interface 'lan'
	option proto 'static'
	option netmask '255.255.255.0'
	option device 'br-lan'
	option ipaddr '192.168.1.1'

config interface 'wan'
	option device 'eth0'
	option proto 'dhcp'

config device
	option name 'br-lan'
	option type 'bridge'
	list ports 'eth1'

ok... this looks correct. Try rebooting and see what happens.

omg - rebooted, 100% perfect. LAN is up AND when I connected to the PiCM4 built in wirelss I was finally able to get assigned an IP from the LAN.

Thank you very much for the help, i gave up on it when I set this up like over a year ago and thought I'd give it another shot. Really happy, thanks again.

Glad it's working now!

If your problem is solved, please consider marking this topic as [Solved]. See How to mark a topic as [Solved] for a short how-to.
Thanks! :slight_smile: