How to permanently add wireless interfaces with iw

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

walli

Posted 2014-05-28T02:00:23.190

Reputation: 109

Answers

5

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.

user1686

Posted 2014-05-28T02:00:23.190

Reputation: 283 655

Thanks for the hint, I'll read up on udev a bit and try it out. – walli – 2014-05-28T14:50:04.750