Failed to move network device "wlan0" to network namespace 2153: Operation not permitted

Excuse me, I’m trying to move wlan0 interface from host to lxc, but I always get the problem “Failed to move network device wlan0 to network namespace 2153: Operation not permitted”. I used a external wifi dongle, and my configuration of lxc likes belows.

lxc.network.type = phys
lxc.network.flags = up
lxc.network.link = wlan0
lxc.network.name = wlan0

Can someone give me some advice? Thank you.

1 Like

The wlan0 device is a child device of the physical wireless card, some drivers let you have multiple wlan devices on a single phy device but they all need to be moved as one unit between namespaces.

You may want to try setting the interface to phy0 (link and name) which may fix this. It could also depend on the wireless driver.

@stgraber, like belows?

lxc.network.type = phys
lxc.network.flags = up
lxc.network.link = phy0
lxc.network.name = phy0

I think so, yes

It doesn’ work, because the phy0 doesn’t exist. When I startup the lxc, the problem is “lxc_network - network.c:instantiate_phys:347 - Failed to retrieve ifindex for phy0”.
I have used “ifconfig -a” to check the existence of phy0, but I only find the wlan0.

I encountered a similar problem while running lxc-2.1.1 and lxc-3.1.0 on Debian Stretch:

lxc-start: test: network.c: lxc_network_move_created_netdev_priv: 2438 Failed to move network device "wlan0" to network namespace 1033: Operation not permitted

I’ve tried different kernel and driver versions. Strangely this did not occure on Ubuntu 18.04 or 19.04 so I started compairing installed packages and noticed that iw was not installed in Debian Stretch.

Installing iw fixed the problem for me.

1 Like

Installing iw on the host worked for me as well. I’m using lxc 4.0.5 and rt2800usb device driver (Panda Wireless USB adapter with RT5372 chipset). I had to use the wlan device (not the phy) like so:
lxc.net.1.type = phys
lxc.net.1.flags = up
lxc.net.1.link = wlp0s29f7u5
lxc.net.1.name = wlan0

I’ve read several posts that make it seem like lxc should work with the phy0 device but it didn’t for me. I’m not sure of the details (did iw simply “connect” wlp0s29f7u5 to phy0?) or if this is a “bug” in lxc. This little tip ended my long struggle. Thanks.