2

How can I permanently add virtual wireless interfaces to my network configuration with iw?

I created the following interfaces:

iw phy phy0 interface add vwlan0 type station
iw phy phy0 interface add vwlan1 type __ap

The first is configured as a wifi client connecting to an existing network (wpa_supplicant) The second is configured as wireless hotspot (hostapd + dnsmasq)

The setup works, but now I can't quite figure out what the best strategy is to save this configuration permanently.

Have made an init script for wpa_supplicant Have made an init script for the hotspot Virtual adaptor network settings set in /etc/network/interfaces

But all this depends on the wireless interfaces being created. What would be the best way to make sure these interfaces are created before the network is set up and the services are run?

As a bonus, since this wireless interface is a usb device, would it be possible to have the interfaces created (and the services started) when the interface is hotplugged?

I know you can execute code after a network interface is up, but the wlan0 interface that is hotplugged should never be up.

Operating system is raspbian

6

Create an udev rule, as in the udev(7) manual page:

ACTION=="add", SUBSYSTEM=="ieee80211", KERNEL=="phy0", \
    RUN+="/usr/bin/iw phy %k interface add vwlan0 type station", \
    RUN+="/usr/bin/iw phy %k interface add vwlan1 type station"

(The subsystem match is mostly just paranoia.)

Put them in /etc/udev/rules.d/90-wireless.rules or something such.

As for service startup, it depends on your init system and network configuration... with the regular SysV init that Debian uses, the only way is by starting the services from the same udev rule.

4
  • Thanks for the hint, I'll read up on udev a bit and try it out.
    – walli
    May 28 '14 at 14:50
  • If you run into this circa 2021 note that /usr/bin/iw is now /sbin/iw, at least on raspbian/buster.
    – Luke
    Sep 18 at 4:21
  • @Luke: I just pretend that all Debian users have installed usrmerge by now, as "does this go to bin or sbin" is right on the bottom of the list of things worth worrying about.
    – user1686
    Sep 18 at 4:59
  • @user1686 that's fair, but this is raspbian and I spent like two hours fighting with udev/perusing logs before realizing that it's the path to iw causing the problem :eyeroll:
    – Luke
    Sep 18 at 23:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.