Hostapd - One vlan per interface or bss and use of environment variables.
Instead of using dynamic vlan and radius, there is another way of implementing vlan with hostapd.
It is possible to set up one vlan per interface and one vlan per bss. The interfaces and bsses need to be added to a vlan aware bridge. The only problem is to keep WPA-PSK functional, it is not possible to attach vlan devices to the bridge interface, ie no br0.100 etc. Instead we can attach a veth pair device to the bridge. For a full example see buildWubuntu
The hostapd-launch script helps to launch hostapd and setup the vlan id's. It starts hostapd with all .conf files in /etc/hostapd/
hostapd.conf:
interface=wlp1s0
bridge=br0
bridge_vlan=2
bss=guest24
bridge=br0
bridge_vlan=3
/etc/systems/system/hostapd.service.d/override.conf
[Service]
SyslogIdentifier=hostapd
ExecStart=
ExecStart=/usr/local/sbin/hostapd-launch
br0.netdev
[NetDev]
Name=br0
Kind=bridge
[Bridge]
DefaultPVID=0
VLANFiltering=1
br0.network
[Match]
Name=br0
[Network]
Address=192.168.5.1/24
[BridgeVLAN]
VLAN=2-3
PVID=2
EgressUntagged=2
eth3.netdev
[NetDev]
Name=eth3
Kind=veth
[Peer]
Name=veth3
veth3.network:
[Match]
Name=veth3
[Network]
Bridge=br0
[BridgeVLAN]
VLAN=3
PVID=3
EgressUntagged=3
eth3.network
[Match]
Name=eth3
[Network]
Address=192.168.6.1/24
The script also enables the use of environment variables like so:
hostapd.conf:
interface=wlp1s0
nas_identifier=$HOSTNAME-$conf_filename
bss=guest24
nas_identifier=$HOSTNAME-$bss