'Virtual wlan interface with systemd-netword

i would like to ask how i can add a virtual wifi interface permanently on a system that runs systemd-networkd. The purpose is to have 2 access points (2.4/5ghz) using hostapd. Adding it manualy works fine using iw dev wlan0 interface add wlan0_sta type managed addr 12:34:56:78:ab:cd
but it disapeares after restart.



Solution 1:[1]

Setup wlan interface (wlan0) ''' Create this file with your settings:

root@raspberrypi:~ # cat >/etc/systemd/network/08-wifi.network <<EOF
[Match]
Name=wl*
[Network]
# to use static IP (with your settings) toggle commenting the next 8 lines.
#Address=192.168.50.61/24
#DNS=84.200.69.80 1.1.1.1
#[Route]
#Gateway=192.168.50.1
#Metric=20
DHCP=yes
[DHCP]
RouteMetric=20
EOF

Setup wpa_supplicant with this file and your settings for country=, ssid= and psk= and enable it:

root@raspberrypi:~ # cat >/etc/wpa_supplicant/wpa_supplicant-wlan0.conf <<EOF
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=DE

network={
    ssid="TestNet"
    psk="realyNotMyPassword"
    key_mgmt=WPA-PSK
    proto=RSN WPA
}
EOF

root@raspberrypi:~ # chmod 600 /etc/wpa_supplicant/wpa_supplicant-wlan0.conf
root@raspberrypi:~ # systemctl disable wpa_supplicant.service
root@raspberrypi:~ # systemctl enable [email protected]
root@raspberrypi:~ # rfkill unblock 0
root@raspberrypi:~ # exit
root@raspberrypi:~ $'''

Reboot and good luck ;-)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Freaky