Unable to utilize wireless adapter in a container

Hello,

I have a host running Ubuntu 22.04LTS and I am running an LXC container, also utilizing the Ubuntu 22.04 image.

I am trying to make use of a USB wireless adapter within a LXC container. I have added the following in the LXC container profile:

wlx00ef44fc4085:
name: wlx00ef44fc4085
nictype: physical
parent: wlx00ef44fc4085
type: nic

This allows that USB wireless adapter to be recognized within the LXC container via " ip link " / " ip address " output.
Within the LXC container (a Ubuntu 22.04 image), I am using Netplan to connect the USB wireless adapter to an access-point. Here is the snippet of the netplan file:

network:
renderer: NetworkManager
version: 2
wifis:
wlx00ef44fc4085:
dhcp4: true
optional: true
access-points:
“MYSSID”:
password: “MYPASSWORD”

When I apply the netplan config within the container (netplan apply), I am given this output:

root@test:~# netplan apply

wlx00ef44fc4085: Failed to write ‘change’ to ‘/sys/devices/pci0000:00/0000:00:14.0/usb1/1-3/1-3:1.0/net/wlx00ef44fc4085/uevent’: Read-only file system
Traceback (most recent call last):
File “/usr/sbin/netplan”, line 23, in
netplan.main()
File “/usr/share/netplan/netplan/cli/core.py”, line 50, in main
self.run_command()
File “/usr/share/netplan/netplan/cli/utils.py”, line 231, in run_command
self.func()
File “/usr/share/netplan/netplan/cli/commands/apply.py”, line 61, in run
self.run_command()
File “/usr/share/netplan/netplan/cli/utils.py”, line 231, in run_command
self.func()
File “/usr/share/netplan/netplan/cli/commands/apply.py”, line 253, in command_apply
subprocess.check_call([‘udevadm’, ‘trigger’, ‘–attr-match=subsystem=net’])
File “/usr/lib/python3.10/subprocess.py”, line 369, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command ‘[‘udevadm’, ‘trigger’, ‘–attr-match=subsystem=net’]’ returned non-zero exit status 1.
root@test:~#

I am stuck here. I have tried to Google around for solutions but I am coming up short. I have attempted to change this container in a privilege container, as well as set the apparmor.profile to unconfined. I have tried LXD 5.0LTS and the latest (5.19) … all scenarios provide the same outcome.

Any hints at this point?
Again, goal is for the container to entirely utilize/manage/control the USB wireless adapter.

Looks like I am able to connect to my wireless adapter on my container. It is not an LXC issue, but a Netplan issue.

Effectively, utilizing " iw " and " wpa_supplicant ", within the container, works like a charm. For the Google’ers out there, basic steps to prove the wireless adapter works:

ip link ← find your wireless adapter
iw <wifi adapter> scan ← scan nearby networks
wpa_passphrase SSID PASSWORD ← generated output, copy it to a file (i.e.: /root/connect_to_my_wifi ) – for complicated WPA passwords (non-alphabet characters), try this: wifi - Use wpa_supplicant without plain text passwords - Unix & Linux Stack Exchange
wpa_supplicant -B -i <wifi adapter> -c /root/connect_to_my_wifi ← to get you connected

The above is the quick and dirty just to get some results after hours / days of searching the Internet for a solution. Please harden and adjust accordingly, to your specific use-case, if this is working for you.

Any comments or additional suggestions for people referencing this in the future are welcomed!

Final note: all I did for an LXC perspective is just take the Wireless Adapter as a physical NIC and move it directly to the container. No privilege or nesting required. Here is what I have in my LXC profile for this specific container:

devices:
  wlx00ef44fc4085:
     name: wlx00ef44fc4085
     nictype: physical
     parent: wlx00ef44fc4085
     type: nic

Thats it.