[HOWTO] Update MAC filter from command line

mgor

New Around Here
So, I got around replacing my old Airport Express when a good deal for a Asus AC68U came around.

I have a server at home that is functioning as Firewall, DNS, DHCP etc. My DHCP server only accept DHCP requests from known clients and I also have a MAC filter for connecting to my wireless network.

With my old solution, whenever someone new wanted to connect to my wireless network, I'd have to add them first in the DHCP server and then to the MAC filter on the AirPort Express.

Being able to run Linux on the AP I thought I could automate the second part of the process, e.g. adding the client MAC to the MAC filter on the AP.

I created a script that every 10 minute login to the DHCP server and parses the host and MAC address for the clients it accepts.

If nothing has changed, then nothing is changed on the AP.

I didn't find much information of people already have done this, so I'd thought I share. I went through the web guy code (which is really, really ugly) to find out what was done when changing the MAC filter.

The script assumes that you want to have the same MAC addresses both for 2.4 and 5 GHz filters. It also assumes that the user you're connecting with has a public key that has been added to ~/.ssh/authorized_keys on the DHCP server.

If you don't want the script, but want to know how it's done, in short:
Code:
maclist="<mac1>client1<mac2>client2"
nvram set wl_maclist_x=$maclist
nvram set wl0_maclist_x=$maclist
nvram set wl1_maclist_x=$maclist
nvram set x_Setting=1
nvram set w_Setting=1
nvram commit
service restart_wireless

https://github.com/mgor/asuswrt-scripts
 

ColinTaylor

Part of the Furniture
Hi mgor. Thanks for the script, looks interesting.

I'll make a couple of comments if I may.

1) I don't think you need to set a value for wl_maclist_x as I believe it's just a temporary variable used by the GUI.

2) You might need/want to also set wl0_maclist and wl1_maclist to be consistent with what ASUS does. i.e.
Code:
wl0_maclist=00:A0:96:CA:F0:F6
wl0_maclist_x=<00:A0:96:CA:F0:F6>BDP-S390
 

Boy1979

New Around Here
Hi mgor. Thanks for the script, looks interesting.

I'll make a couple of comments if I may.

1) I don't think you need to set a value for wl_maclist_x as I believe it's just a temporary variable used by the GUI.

2) You might need/want to also set wl0_maclist and wl1_maclist to be consistent with what ASUS does. i.e.
Code:
wl0_maclist=00:A0:96:CA:F0:F6
wl0_maclist_x=<00:A0:96:CA:F0:F6>BDP-S390

Hi,

you only need to update

wl0_maclist_x for 2.4Ghz
wl1_maclist_x for 5.0Ghz

thats enough.

regards Boy1979
 

mgor

New Around Here
Hey,

Thanks for your feedback!

I figured that it might not be needed, however, there are some nvram variables (such as the [wx]_Setting) that is used when the router is rebooted and services are started. Hence, I thought it wouldn't hurt to set these as well just in case, because I didn't look through all related code :)

I couldn't see that wl[0-1]_maclist was touched by the actions triggered when adding MAC addresses in the web ui.
 
Last edited:

Similar threads

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top