1

I want hostapd to assign each station a given VLAN based on MAC address. BTW, my network is quite small. Using RADIUS would be an overkill.

According to the hostapd manual:

Optionally, the local MAC ACL list (accept_mac_file) can be used to set static client MAC address to VLAN ID mapping.

Let's assume I only have 1 station (with MAC DE:AD:BE:EF:CA:FE). I've created a VLAN using:

sudo ip link add link wlan0 name vlan.100 type vlan id 100
sudo ip addr add 192.168.100.1/24 brd 192.168.100.255 dev vlan.100
sudo ip link set dev vlan.100 up

On hostapd.conf I'm using:

#  Interface to use
interface=wlan0
#  Driver
driver=nl80211
#  Name of the network
ssid=YaddaYadda
#  Use the 2.4GHz band: g = IEEE 802.11g (2.4 GHz)
hw_mode=g
#  Use channel 6
channel=6
#  Enable 802.11n
ieee80211n=1
#  Enable 40MHz channels with 20ns guard interval
ht_capab=[HT40][SHORT-GI-20][DSSS_CCK-40]
#  Accept only known MAC addresses
macaddr_acl=1
accept_mac_file=/etc/hostapd/accept
#  Use WPA authentication
auth_algs=1
#  Send empty SSID in beacons and ignore probe request frames that do not specify full SSID
ignore_broadcast_ssid=1
#  Use WPA2
wpa=2
#  Use a pre-shared key
wpa_key_mgmt=WPA-PSK
#  Enable the wireless multimedia extensions
wmm_enabled=1
#  The network hashed passphrase
wpa_psk=786451648446NotReallyTheHashedPassphrase849989654651651651654564
#  Use AES, instead of TKIP
rsn_pairwise=CCMP
# Isolate Clients
ap_isolate=1

#  HOSTAPD event logger configuration
logger_syslog=-1
logger_syslog_level=2
logger_stdout=-1
logger_stdout_level=2

#  Country code
country_code=NO

On file /etc/hostapd/accept I have included the following:

DE:AD:BE:EF:CA:FE vlan.100

hostapd starts without any issues. However, after connecting my station with MAC DE:AD:BE:EF:CA:FE, I'm still getting all the traffic on wlan0 and not on vlan.100...

hostapd does not say much about how the file accept_mac_file should look like to map MAC <-> VLAN ID. I've tried comma, with and without spaces, but no luck...

Has anyone been able to get this MAC <-> VLAN mapping to work?

Your Answer

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

Browse other questions tagged or ask your own question.