Score:0

Ubuntu Server 22.04 LTS using netplan and networkd on RPi4b won't assign DHCP IP to wlan0

sl flag

Fresh install of Ubuntu Server 22.04 LTS on a 4GB Raspberry Pi 4b with PRO activated. On the initial boot up, I didn't realize I needed to wait until the cloud-init sequence finished so I may have screwed it up by logging in too soon on the console.

With the Raspberry Pi Imager creating the bootable media for Ubuntu Server 22.04 LTS, I used the Advanced Options to specify a Wi-Fi SSID and password.

The Server brings up the RPi4's eth0 interface and gets a DHCP address reservation from my router just fine. It just won't get an IP for the built-in Broadcom Wi-Fi interface which I need to use so I can disconnect the wired connection.

I have read netplan setup articles and looked at a lot of posts on various forums about getting Wi-Fi working. I have tried all sorts of things over the last 4 days and cannot get the built-in RPi4b Wi-Fi interface working under Server 22.04 LTS.

Ubuntu Desktop 22.04 LTS with PRO activated brings up both the eth0 and wlan0 interfaces. Both get DHCP IPs from my router's MAC reservations while using netplan with NetworkManager.

There's a mention in dmesg of eth0 link being up but no mention of wlan0 or phy0. The only lines related to wireless in dmesg are a few cfg80211 lines about power save being enabled.

Server 22.04 uses netplan with networkd to bring up the interfaces. Here's what I've tried to no avail. eth0 gets an IP4 fine but no IP is assigned to wlan0. In /etc/netplan I've tried defining both interfaces together in 01-network-manager-all.yaml like this.

network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      dhcp4: yes
  wifis:
    wlan0:
      dhcp4: yes
      access-points:
        "MySSID":
          password: "MyPWD"

I left out the key "optional:". It doesn't make a difference in the result with or without that line being in the yaml file. When I add in that key for either or both interfaces, it doesn't make any difference with "optional:" set to either "true" or "false".

netplan --debug try (or generate or apply) says the configurations I've tried are valid, multiple times, and doesn't show anything that looks bad to me. Here is some of the output.

starting new processing pass
wlan0: adding wifi AP 'MySSID'
We have some netdefs, pass them through a final round of validation
wlan0: setting default backend to 1
Configuration is valid
eth0: setting default backend to 1
Configuration is valid
Generating output files..
openvswitch: definition eth0 is not for us (backend 1)
NetworkManager: definition eth0 is not for us (backend 1)
Creating wpa_supplicant config
wlan0: Creating wpa_supplicant configuration file run/netplan/wpa-wlan0.conf
Creating wpa_supplicant unit /run/systemd/system/netplan-wpa-wlan0.service
Creating wpa_supplicant service enablement link 
   /run/systemd/system/systemd-networkd.service.wants/netplan-wpa-wlan0.service
openvswitch: definition wlan0 is not for us (backend 1)
NetworkManager: definition wlan0 is not for us (backend 1)

I've looked at the wpa_supplicant file which seems to look okay. It has the correct SSID and password.

$ sudo cat /run/netplan/wpa-wlan0.conf
ctrl_interface=/run/wpa_supplicant

network={
  ssid="MySSID"
  key_mgmt=WPA-PSK
  psk="MyPWD"
}

I did notice in the networkd journalctl entries say that eth0 gets an IP while wlan0 does not get an IP. I don't know why it doesn't.

$ sudo journalctl -b -u systemd-networkd
16:27:47 rpi4 systemd-networkd[775]: wlan0: Link DOWN
16:27:48 rpi4 systemd-networkd[775]: eth0: Re-configuring with /run/systemd/network/10-netplan-eth0.network
16:27:48 rpi4 systemd-networkd[775]: eth0: Failed to send DHCP RELEASE, ignoring: Stale file handle
16:27:48 rpi4 systemd-networkd[775]: eth0: DHCP lease lost
16:27:48 rpi4 systemd-networkd[775]: eth0: DHCPv6 lease lost
16:27:48 rpi4 systemd-networkd[775]: eth0: DHCPv4 address 192.168.nn.nn/24 via 192.168.nn.mm
16:27:48 rpi4 systemd-networkd[775]: wlan0: Re-configuring with /run/systemd/network/10-netplan-wlan0.network
16:27:48 rpi4 systemd-networkd[775]: wlan0: DHCPv6 lease lost
16:27:48 rpi4 systemd-networkd[775]: wlan0: Link UP

Both the 10-netplan-eth0.network and the 10-netplan-wlan0.network files look identical except for Name= and RouteMetric.

$ sudo iw wlan0 info
Interface wlan0
        ifindex 3
        wdev 0x1
        addr dc:a6:32:85:nn:mm
        type managed
        wiphy 0
        channel 116 (5580 MHz), width: 20 MHz, center1: 5580 MHz
        txpower 31.00 dBm


$ sudo iwconfig wlan0
wlan0     IEEE 802.11  ESSID:off/any
          Mode:Managed  Access Point: Not-Associated   Tx-Power=31 dBm
          Retry short limit:7   RTS thr:off   Fragment thr:off
          Encryption key:off
          Power Management:on

I've tried a NetPlan yaml file with the lines for wifis and without the lines for ethernets. eth0 still works fine, but still no IP is assigned for wlan0. This is all I get.

$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether dc:a6:32:nn:nn:nn brd ff:ff:ff:ff:ff:ff
    inet 192.168.nn.nn/24 metric 100 brd 192.168.nn.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::dea6:xxxx:xxx:xxxx/64 scope link
       valid_lft forever preferred_lft forever
3: wlan0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN group default qlen 1000
    link/ether dc:a6:32:nn:nn:mm brd ff:ff:ff:ff:ff:ff

I tried another recommendation using just

network:
  version: 2
  renderer: networkd

eth0 gets enabled with a DHCP IP but no IP is assigned to wlan0.

At this point I'm out of options to try so I would appreciate help getting the Wi-Fi, which works for Desktop, to work for Server.

David avatar
cn flag
The default kernel for server and desktop may be different due to different hardware stacks.
ch flag
Is it possible to port your working network configuration from desktop to server for testing?
SDMark avatar
sl flag
Both Desktop and Server have the same kernels. Linux 5.15.0-1026-raspi #28-Ubuntu SMP PREEMPT Fri Mar 10 14:28:52 UTC 2023 aarch64 aarch64 aarch64 GNU/Linux
SDMark avatar
sl flag
I think the issue in porting from Desktop to Server is that Desktop uses NetworkManager and so there are different files and directories involved. At this point, I'm not sure what files to look at.
ng flag
I have exactly the opposite problem with 22.04 server on an RPi 3. I get an ipv4 addres for wlan0 but none for eth0.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.