8
1
# ip link set wlan0 netns 1
RTNETLINK answers: Invalid argument
It works for usual ethernet. It also works for proprietary broadcom "wl" driver.
How to do it for usual mac80211-based driver?
8
1
# ip link set wlan0 netns 1
RTNETLINK answers: Invalid argument
It works for usual ethernet. It also works for proprietary broadcom "wl" driver.
How to do it for usual mac80211-based driver?
11
You need to move the PHY:
iw phy phy0 set netns 666
Where 666 is the pid of some process running in that network namespace; for netspaces created by iproute2
tools (with ip netns
), you can create a short-lived process in there and get its pid:
iw phy phy0 set netns "$(ip netns exec mynetns sh -c '
sleep 1 >&- & echo "$!"')"
To move it back to the root namespace:
ip netns exec mynetns iw phy phy0 set netns 1
0
Implemented my own workaround: vethify
ip link add type veth
; ip link set veth1 netns <some_pid>
; vethify wlan0 veth0
on host network namespace. It will copy all captured on wlan0 to veth0 and back;ethtool --offload veth1 rx off tx off && ethtool -K veth1 gso off
.Note: vethify sees all packets in the network namespace, not only wlan0's and veth0's. It will add latency and cause additional overhead.
Welcome to Super User! While this may answer the question, it would be a better answer if you could provide some explanation why it does so. – DavidPostill – 2015-04-14T15:40:54.633
Crashed the kernel playing with
iw ... setns
... – Vi. – 2015-04-15T13:22:03.953What is the 666? Man says it is a pid, but a pid of which process should I provide here? – Bjarke Freund-Hansen – 2016-09-12T07:44:13.737
666
is a PID of a process already in the network namespace you want to use. You can replace666
byname XXX
whereXXX
is the namespace's name. – Pierre – 2019-02-22T16:41:12.430$ sudo iw phy phy0 set netns 19470
command failed: Operation not supported (-95)
(FFS, I've edited this comment so many times but nothing is working; how do I do this on multiple lines?) – flarn2006 – 2019-04-09T23:31:24.537