1

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

3 Answers3

2

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.

Dave Jones
  • 151
  • 4
0

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.

slangasek
  • 5,562
0

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