Wireless Meshing in UniFi
We are using around 40 Unifi Access Points in our company connected to local switches via cat6 wired. Recently one of the AP got rebooted & came back online shortly but for some reason it was not able to detect the wired uplink, & because the wireless meshing was enabled, this AP wirelessly meshed with its neighbor AP connected to same switch. The problem started when the AP have the wired connection but still it links with other AP & the LOOP was created because it was on TRUNK.
I started seeing access points & switches ping dropping all over the place, and eventually detected the problem to this problematic AP wireless uplink.
It is recommended that you disable the MESHING feature in the Unifi AP settings. Sometime it happens that UniFi AP Wire goes down & the AP will establish Wireless uplink with another AP, this will work theoretically ok, but when the wire connection will be back, it can start looping as well.
Shouldn’t the wireless uplink detect that it has a wired network link and drop the wireless uplink? and if so, how long should this take? Is there anything that i should have configured to prevent the loop?
UNIFI AP Command
Set controller address in UniFi Access Point via SSH putty
- to get information about access point , issue
1 | info |
to set access point controller address, use
- 1
set-inform http://10.0.0.1:8080/inform
whereas 10.0.0.1 is the unifi controller server IP.
1.2- Odd method to acquire total number of active WiFi Clients
Bash script to acquire some info via UniFi controller like active number of WiFi clients connected with different UniFi AP LR in the company.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | #!/bin/bash # Script to query active clients by curl from unifi controller # Syed jahanzaib / aacable . wordpress . com / aacable at hotmail dot com # 2nd-January-2017 #set -x # UniFi Controller IP and Port IP="10.0.0.1" PORT="8443" COOKIE="/tmp/cookies.txt" TMP_HOLDER="/tmp/$IP.active.wifi.clients.txt" # pattern to match to count active clients using string matching PATTERN="hostname" # First Login to controller via CURL curl -s "https://$IP:$PORT/api/login" --data-binary '{"username":"admin","password":"CONTROLLERPASSWORD","strict":true}' --compressed --insecure -c $COOKIE > /dev/null # Download Statistics from controller using CURL curl -s --insecure -b $COOKIE -c $COOKIE "https://$IP:$PORT/api/s/default/stat/sta" > $TMP_HOLDER # Count active users by pattern match, what an odd method, may not work correctly, but so far working for me ACTIVE=`cat $TMP_HOLDER | grep -o $PATTERN | wc -l` echo $ACTIVE echo $ACTIVE |
Result in command …
CFG file for MRTG …
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | # Unifi Controller - WiFi Active WiFi Clients - syed.jahanzaib Target[unifi_wifi_active_users]: `/temp/unifi-client.sh` Title[unifi_wifi_active_users]: Active Wifi Clients via Unifi Controller PageTop[unifi_wifi_active_users]:</pre> <h1>Active Wifi Clients via Unifi Controller</h1> <pre>MaxBytes[unifi_wifi_active_users]: 50000 Colours[unifi_wifi_active_users]: B#8888ff,B#0813B7,B#5398ff,B#0813B7 Options[unifi_wifi_active_users]: growright,nopercent,gauge,integer,nobanner,printrouter,pngdate,noo LegendI[unifi_wifi_active_users]: Active Wifi Users LegendO[unifi_wifi_active_users]: YLegend[unifi_wifi_active_users]: Active Wifi Users Legend1[unifi_wifi_active_users]: Active Wifi Users Legend2[unifi_wifi_active_users]: ShortLegend[unifi_wifi_active_users]: #Unscaled[unifi_wifi_active_users]: dwmy |
MRTG Graph for Active WiFi Clients via UniFi Controller …
- – – – – – – – – –
- – – – – – – – – –
- – – – – – – – – –
- – – – – – – – – –
Following are some snapshots from the UniFi Controller for some comparison that script is working accurate so far … (However it is still under observation to monitor its accuracy result / zaib)
2- Odd method to acquire total number of Active Access Points Vs Down [Registered in UniFi Controller]
Bash script to acquire total number of registered access points (unifi AP-LR) and there status as well to compare Active vs down.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | #!/bin/bash # Script to query active clients by curl from unifi controller #set -x IP="10.0.0.1" PORT="8443" COOKIE="/tmp/cookies.txt" TMP_HOLDER="/tmp/$IP.total.ap.txt" PATTERN="adopted" curl -s "https://$IP:$PORT/api/login" --data-binary '{"username":"admin","password":"CONTROLLERPASSWORD","strict":true}' --compressed --insecure -c $COOKIE > /dev/null curl -s --insecure -b $COOKIE -c $COOKIE "https://$IP:$PORT/api/s/default/stat/device" > $TMP_HOLDER ACTIVE=`cat $TMP_HOLDER | grep -o $PATTERN | wc -l` DOWN=`grep -oP '\"state\" : \K[^ ]*' $TMP_HOLDER | grep 0 | wc -l` echo $DOWN echo $ACTIVE |
Result in command …
[Total access points vs DOWN]
CFG file for MRTG …
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | # Unifi Controller - UniFi AP-LR - Active Access Points vs DOWN Target[unifi_ap_total_vs_down]: `/temp/unifi-devices.sh` Title[unifi_ap_total_vs_down]: UniFi AP-LR - Active Access Points vs DOWN PageTop[unifi_ap_total_vs_down]:</pre> <h1>UniFi AP-LR - Active Access Points vs DOWN</h1> <pre>MaxBytes[unifi_ap_total_vs_down]: 5000 Colours[unifi_ap_total_vs_down]: B#0000FF,R#FF0000,B#0000FF,R#FF0000 Options[unifi_ap_total_vs_down]: growright,nopercent,gauge,integer,nobanner,printrouter,pngdate LegendI[unifi_ap_total_vs_down]: Active AP --> LegendO[unifi_ap_total_vs_down]: Down AP --> YLegend[unifi_ap_total_vs_down]: Active vs Down Legend1[unifi_ap_total_vs_down]: Active Access Points Legend2[unifi_ap_total_vs_down]: Down Access Points ShortLegend[unifi_ap_total_vs_down]: #Unscaled[unifi_ap_total_vs_down]: dwmy |
MRTG Graph for Active WiFi AP DEVICES via UniFi Controller …
3# Upgrade UniFi AP LR Access Point via SSH/CLI
We have few unifi AP-LR Wireless Access Points in our company which are connected with the Unifi Controller ver 5.2.9.0 on windows 2008 r2 / x64 server. For some unknown reasons I was unable to upgrade the access point’s firmware from the controller. Therefore I upgraded all AP’s via SSH method which is posted below …
First download the appropriate firmware and upload it to some web server. (at the time of upgrading the latest firmware version was 3.7.21.5389 , you make sure to download latest one available)
Select your model / download from following link …
[Luckily I had local web server available so I simply put this file into my /var/www folder (for ubuntu)]
Now login in the access point via SSH , and issue this command
upgrade http://101.0.0.1/BZ.ar7240.v3.7.21.5389.161017.0923.bin
Make sure to change the path or ip according to your network. Once its upgraded it rebooted and new Firmware was 3.7.21.5389
# Reboot All access points via BASH script
We have 12 access points in our network, & we want to reboot all of them at 7am daily in morning. there we used following BASH script from our management Linux Pc. Make sure to first install SSHPASS
1 | apt-get -y install sshpass |
Script Name: rebootap.sh
Script Code:
#!/bin/bash
# This is not my script , It is taken from stevejenkins at https://github.com/stevejenkins/unifi-linux-utils/blob/master/uap_reboot.sh
# Reboot All ubiquiti Access Points
username=admin
password=apset4me
known_hosts_file=/dev/null
# Modify below and add remove your Access Points IP’s
uap_list=( 10.0.0.1 10.0.0.2 10.0.0.3 10.0.0.4 )
# SHOULDN’T NEED TO CHANGE ANYTHING PAST HERE
for i in “${uap_list[@]}”
do
echo “Rebooting AGP UniFi access point at $i…”
if sshpass -p $password ssh -oStrictHostKeyChecking=no -oUserKnownHostsFile=$known_hosts_file $username”@$i” reboot; then
echo “Access point at $i rebooted!” 1>&2
else
echo “Could not reboot access point at $i.” 1>&2
fi
done
exit 0