Art-of-WiFi / UniFi-API-client

A PHP API client class to interact with Ubiquiti's UniFi Controller API
MIT License
1.09k stars 217 forks source link

MAC address filtering for each port specifically #97

Closed NicolasSmit closed 3 years ago

NicolasSmit commented 3 years ago

Hi

Is it possible to manage MAC address filter on each port of a POE, using Art-Of-Wifi library or any API call ? Reading the documentation, I wasn't able to identify any function able to do that.

Thanks

malle-pietje commented 3 years ago

This can be achieved using the port overrides. The payload for the override to whitelist a MAC address on port 5 would look like this:

      {
         "port_idx":5,
         "portconf_id":"558c39fee4b053d0b32a8bb2",
         "port_security_mac_address":[
            "aa:bb:cc:dd:ee:ff"
         ],
         "port_security_enabled":true
      }

You can use this example as a starting point to work with port overrides: https://github.com/Art-of-WiFi/UniFi-API-client/blob/master/examples/update_switch_poe-mode.php

malle-pietje commented 3 years ago

Obviously, you'll need to pass the payload to the method/function as a PHP associative array... The above JSON format is what the API Client passes on to the respective API route.

NicolasSmit commented 3 years ago

Thanks @malle-pietje 👍 I'm going to give it a try

NicolasSmit commented 3 years ago

I used node-unify to try this, and it's working great :) I suppose this package does the job too

malle-pietje commented 3 years ago

Yes, as long as you make sure to pass the correct payload.