linux - How to permanently add wireless interfaces with iw

07
2014-07
  • walli

    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

  • Answers
  • grawity

    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.


  • Related Question

    linux - How to add route permanently
  • Intra

    I'm using gentoo linux I want to add a route and have it persist after /etc/init.d/net.eth0 restart

    I can add successfully

    route add -net x.x.x.x/x gw x.x.x.x eth0
    

    How can I make this persistent?


  • Related Answers
  • Daniel Pittman

    You want to configure a static route, which is distribution specific. The route command itself has no way to arrange that, but on Gentoo /etc/conf.d/net will allow static routes defined with ip to be added on network restart.