Skip to content

Instantly share code, notes, and snippets.

@lukasMega
Last active August 1, 2023 06:40
Show Gist options
  • Save lukasMega/70495a3f5a6f00249476cd38ded38d03 to your computer and use it in GitHub Desktop.
Save lukasMega/70495a3f5a6f00249476cd38ded38d03 to your computer and use it in GitHub Desktop.
Unifi AP useful commands (tested on U6-Lite)

Unifi AP useful commands

tested on U6-Lite using SSH:

  • log in to AP: $ ssh ubnt@<IP>
  • default username & password: ubnt & ubnt

LED

Disable LED:

  • sed -i 's/mgmt.led_enabled=true/mgmt.led_enabled=false/g' /var/etc/persistent/cfg/mgmt (it takes up to ~15 seconds)
  • echo '0' >/proc/gpio/led_pattern (immediately, but not persistent)

Enable LED (blue or default color):

  • sed -i 's/mgmt.led_enabled=false/mgmt.led_enabled=true/g' /var/etc/persistent/cfg/mgmt (it takes up to ~15 seconds)
  • echo '1' >/proc/gpio/led_pattern (immediately, but not persistent)

LED - white color:

  • echo '2' >/proc/gpio/led_pattern

LED - blinking white:

  • echo '02' >/proc/gpio/led_pattern

ℹ️ Note: official LED statuses:


Getting info:

Device info, uptime:

  • info
example output:
  	Model:       U6-Lite
  	Version:     5.60.23.13051
  	MAC Address: 78:45:xx:xx:xx:xx
  	IP Address:  192.168.88.2
  	Hostname:    U6-Lite
  	Uptime:      430867 seconds

  	Status:      unknown
  • cat /var/sysinfo/model
  • uname -a
    • example output: Linux U6-Lite 4.4.198 #0 SMP Thu Aug 30 12:10:54 2018 mips GNU/Linux
  • uptime

CPU info:

  • cat /proc/stat | grep '^cpu '
  • cat /proc/cpuinfo
  • cat /proc/ubnthal/system.info
example output:
  cpu=MT7621
  cpuid=1617657f
  flashSize=33554432
  ramsize=268435456
  vendorid=0777
  systemid=a612
  boardrevision=15
  serialno=7845xxx61xxx
  manufid=0002
  mfgweek=202129
  qrid=WErxxx
  eth0.macaddr=78:45:xx:xx:xx:xx
  radio0.name=MT7603
  radio1.name=MT7915
  device.hashid=10643aexxx2d8xxx
  device.anonid=5429fxxx-d4xx-4fxx-8064-3ae26f2dxxxx
  ra0.macaddr=78:45:xx:xx:xx:21
  rai0.macaddr=78:45:xx:xx:xx:22
  bt0.macaddr=78:45:xx:xx:xx:23
  regdmn[]=0000ffffffffffffffffffffffffffff
  cpu_rev_id=00030103

Memory (RAM) info:

  • free | grep 'Mem:'
  • free

Storage:

  • df -h

    example output:
       Filesystem                Size      Used Available Use% Mounted on
       tmpfs                   123.9M    856.0K    123.1M   1% /tmp
       tmpfs                   512.0K         0    512.0K   0% /dev
    

Log:

  • cat /var/log/messages

Get connected clients (MACs):

  • CLIENTS=`mca-dump |grep \"mac\" | grep -v "<AP MAC>"` && echo "$CLIENTS"

Some configs:

  • cat /var/running.cfg
  • cat /var/system.cfg

Network: IP

  • netstat -rt -n (cisco: show ip route)

Show interfaces:

  • ifconfig (cisco: show interfaces)

Show config:

  • cat /mnt/data/udapi-config/unifi
  • cat /tmp/system.cfg

tcpdump:

  • tcpdump

⚠️ Reset & potentially dangerous commands

Reset device to factory defaults:

  • syswrapper.sh restore-default or
  • set-default

Enter CLI:

  • mca-cli

Adopt a UniFi device into a controller device:

  • set-inform http://<IP.your.unifi.controller>:8080/inform

Set password:

  • passwd

Reboot, shutdown AP:

  • reboot
  • poweroff
  • /usr/etc/rc.d/rc.softrestart save (not tested)

Manually Upgrade AP:

  • syswrapper.sh upgrade http://ip-of-controller:8080/dl/firmware/BZ2/xxxxx/firmware.bin

Upgrade AP (online):


Show other commands:

  • ubntbox

Sources:


PoE switch - useful commands

  • (tested on USW-Lite-8-PoE, Version: 6.5.59.14777, 2023-07-27)

PoE ⚡️

⚡️ show PoE info (summary):

  • swctrl poe show
  • example output:
    USW-Lite-8-PoE-UM.6.5.59# swctrl poe show
     Total Power Limit(mW): 52000
    
     Port  OpMode      HpMode    PwrLimit   Class   PoEPwr  PwrGood  Power(W)  Voltage(V)  Current(mA)
                                   (mW)                                                               
     ----  ------  ------------  --------  -------  ------  -------  --------  ----------  -----------
        1    Auto        Dot3at     32262  Class 4      On     Good     15.73       52.98       297.00
        2    Auto        Dot3at     32115  Unknown     Off      Bad      0.00        0.00         0.00
        3    Auto        Dot3at     32125  Unknown     Off      Bad      0.00        0.00         0.00
        4    Auto        Dot3at     32115  Unknown     Off      Bad      0.00        0.00         0.00

⚡️ turn off PoE port #1

  • swctrl poe set off id 1

⚡️ turn on PoE port #1

  • swctrl poe set auto id 1

⚡️ control ALL PoE ports:

  • swctrl poe set off
    swctrl poe set auto
    

⚡️ restart PoE port(s):

  • swctrl poe restart id 1-2
  • output:
    swctrl[4221]: [info ] libubnt._ubnt_set_port_poe_power_cycle(): port 1: power cycled
    swctrl[4221]: [info ] libubnt._ubnt_set_port_poe_power_cycle(): port 2: power cycled
    

example running one command via ssh:

  • ssh admin@usw-lite -p 22 -f 'swctrl poe set off id 1'
  • ssh x@192.168.88.1 -p 22 -f 'swctrl poe show ; swctrl port show' - show info about all ports (first PoE, then others)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment