Na rozdíl od originálního firmware ASUSu není v základní instalaci OpenWRT obsažen filtr MAC adres pro WiFi síť a je nutno jej doinstalovat a nakonfigurovat ručně.
Nejdříve nainstalujeme balíčky wireless-tools a wlc, tedy utilitku pro rozšířenou konfiguraci a manipulaci s WiFi adaptérem ASUSu , resp. driverem.
opkg update
opkg install wireless-tools wlc
Dále si vytvoříme seznam MAC adres, které budou mít povolen/zakázán (viz níže v kódu skriptu) přístup k naši WiFi síti. Jedná se o prostý textový soubor, kde na každém jeho řádku je zadána MAC adresa síťové karty klientského zařízení a popis pro snadnější orientaci.
nano /etc/maclist
xx:xx:xx:xx:xx:xx MAC1_Description
xx:xx:xx:xx:xx:xx MAC2_Description
xx:xx:xx:xx:xx:xx MAC3_Description
xx:xx:xx:xx:xx:xx MAC4_Description
...
Abychom nemuseli vždy při každém restart routeru nastavovat MAC filtr ručně, vytvoříme INIT script, který to provede automaticky.
nano /etc/init.d/wlmacfilter
#!/bin/sh /etc/rc.common
#
# Allowed MAC addresses are stored in the file
#
ALLOWED_MAC="/etc/maclist";
# Load Mac list
MACLIST=`awk 'BEGIN {LINES = ""} { LINES = LINES$1" " } END {print LINES}' $ALLOWED_MAC`
# The macfilter 2 means that the filter works in "Allow" mode.
# Other options are: 0 - disabled, or 1 - Deny.
# wlc ifname wl0 maclist "xx:xx:xx:xx:xx:xx xx:xx:xx:xx:xx:xx"
START=47
start() {
wlc ifname wl0 maclist "$MACLIST"
wlc ifname wl0 macfilter 2
}
stop() {
wlc ifname wl0 maclist none
wlc ifname wl0 macfilter 0
}
Následně je nutno změnit práva k souboru, povolit automatický start skriptu po restartu routeru a nakonec filtr spustit.
chmod 755 /etc/init.d/wlmacfilter
/etc/init.d/wlmacfilter enabled
/etc/init.d/wlmacfilter start
ve skriptu wlmacfilter se hodnota 2 na řádku wlc ifname wl0 macfilter 2 nahradí hodnotou 1.