Score:1

How to correct bad auto netplan configuration of wpa_supplicant Ubuntu 20:04

cn flag

I use Ubuntu 20.04 desktop on a Raspberry Pi 4 and I am trying to configure netplan. I have seen How to configure wpa_supplicant in Ubuntu server 20.04. I configured netplan to connect to wlan0 and it worked. I also configured /etc/default/crda by putting REGDOMAIN=IT,
but on the wpa_supplicant log I see:

wpa_supplicant[910]: wlan0: CTRL-EVENT-REGDOM-CHANGE init=COUNTRY_IE type=COUNTRY alpha2=DE

So the Wi-Fi connection is not stable.

I use NetworkManager and if I restart it after setting the correct value with:

sudo iw reg set IT

wpa_supplicant sets it back to the wrong DE value.

How can I avoid netplan setting the wrong country?

Update

I have write a service:
sudo apt install iw
I choose a folder under root user /etc/init.d/ and write a file named wireless:

/etc/init.d/wireless

#!/bin/sh
# by Leonardo: workaround
iw wlan0 set power_save off
iw reg set IT
exit 0

then: sudo chmod ugo+x /etc/init.d/wireless

write another file
/etc/systemd/system/wireless-on.service

[Unit]
Description=workaround for set wireless country and to no power management 
After=network-online.target

[Service]
Type=oneshot
ExecStart=/etc/init.d/wireless

[Install]
WantedBy=multi-user.target

then:
sudo systemctl enable wireless-on.service

restart

this made connection stable to me.
sorry for my bad english

cn flag
I write a service that change country and turn off Power save After connection. It seems to work. This Is only a workaround.
Score:2
pl flag

LP: #1951586 has more information, in particular in comments 15 through 19 (and onwards) but I'll try and condense it for this answer. Still, I would recommend reading that for more background information...

WiFi APs can (optionally) advertise a regulatory domain which clients may apply (whether or not clients are mandated to apply advertised regulatory domains, I don't know). As this is optional, not all APs (in fact only the minority in my experience) do this, but it would appear that the AP you're authenticated with is advertising that clients should be using the "DE" regulatory domain, and your client is obeying this.

I'm reasonably certain there is no way to override the AP's specification in netplan's configuration at the time of writing. I'm less certain whether there is any facility in wpa-supplicant (which netplan is using under the covers) to override the AP's specified regulatory domain (in other words netplan may have no choice in this regard).

A minor addendum to slangasek's answer -- netplan 0.105 added the regulatory-domain key because /etc/default/crda was removed in Ubuntu 22.04 (more precisely, the userland crda database was removed upstream), thus the only means of persisting the wifi regulatory domain became modifying the Linux kernel command line (in fact, that's the subject of the bug report I linked earlier) until netplan was enhanced. This is something to be aware of should you decide to move to 22.04.

Score:0
um flag

I used to use Netplan this way:

sudo nano /etc/netplan/$YOUR_NETPLAN_PROFILE_NAME.yaml

Paste and correct XXXX to a valid value in this config:

network:
  wifis:
    wXXXXXXXX:
      addresses:
        - $YOUR_IP/24
      gateway4: 192.168.1.1
      nameservers:
        addresses: [1.1.1.1, 1.0.0.1]
      dhcp4: no
      dhcp6: no
      access-points:
        "$YOUR_NETWOK_WIFI_ID":
          password: "XXXXXXXXXXX"
  version: 2
  renderer: NetworkManager

Then run:

sudo netplan apply /etc/netplan/$YOUR_NETPLAN_PROFILE_NAME.yaml
Score:0
us flag

https://netplan.readthedocs.io/en/latest/netplan-yaml.html documents that it is possible to configure your wifi regulatory domain using the regulatory-domain key in netplan. However, this is only available in Ubuntu 22.04, as the feature is introduced in netplan 0.105 and 20.04 includes netplan 0.104.

If this is a new system, there's not really a good reason to deploy with the three-year-old Ubuntu 20.04 instead of Ubuntu 22.04.

cn flag
Not implemented on Ubuntu 20.04 now
I sit in a Tesla and translated this thread with Ai:

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.