Configure Down Alerts for UniFi networks
/UniFi has become an industry standard network platform and a popular choice among Apple Consultants. Surely you’ve heard us discuss our UniFi experiences on the podcast. In fact, we discussed the topic of down alerts for UniFi networks on episode #538: Welcome All Pings.
Why is this necessary?
UniFi offers solid options for built-in push notifications delivered to your mobile device or email, including for important events like when your network switches to backup internet or backup power, hits an LTE Data Limit, or detects a rogue client or access point for example.
But one very obvious omission is the ability to alert an admin when the network goes down. This prompts an equally obvious question: how is the network supposed to alert you that it’s down – when it’s down? That’s a fair question for a locally-hosted controller, but with Remote Access enabled, this shouldn’t be an issue since the UniFi controller shows in the UniFi Site Manager at unifi.ui.com. In fact, the Site Manager will indicate if a network is down and when it last reported online. So why doesn’t it have an option to alert the admin?
In this post, I’ll provide instructions on how to configure down alerts to be sent by push notification and/or email when your UniFi network goes offline, using NameCheap for Dynamic DNS and UptimeRobot for monitoring.
Special thanks to Ryan Grimes on the MacAdmins Slack for this recommendation.
Instructions
Register a new domain at NameCheap.com to use for this purpose, e.g. downtimealertexample.live.
Configure a subdomain (host) to represent your initial test client, e.g. testclient.downtimealertexample.live, and enable Dynamic DNS (DDNS) in NameCheap on your domain.
Host Record Type: A + Dynamic DNS Record
Host: <your subdomain> e.g. testclient
IP Address: 127.0.0.1 (will be updated by your UniFi controller in the next step)
Turn on Dynamic DNS in NameCheap > Advanced DNS > Dynamic DNS, and note the Dynamic DNS Password which you will need in the next step.
Configure your UniFi Gateway to update your Dynamic DNS service in Network > Settings > Internet > WAN > Dynamic DNS > Create New Dynamic DNS.
Service: namecheap
Hostname: <your subdomain> e.g. testclient
Username: <your domain> e.g. downtimealertexample.live
Password: <the “Dynamic DNS Password” found in your NameCheap account under Advanced DNS>
Server: <blank>
Configure an IP Group in your UniFi controller > Network > Settings > Profiles > IP Groups and add the 5 main UptimeRobot IP ranges to it.
Profile Name: UptimeRobot
Type: IPv4 Address/Subnet
Address: IPv4 Address/Subnet
Add the following IP address ranges:
69.162.124.224/28
63.143.42.240/28
216.245.221.80/28
208.115.199.16/28
216.144.248.16/28
Add a Firewall Rule to allow ping (ICMP) in your UniFi controller > Network > Security > Firewall Rules > Internet.
Type: Internet Local
Name: Allow UptimeRobot Ping
Action: Accept
Protocol: ICMP
IPv4 ICMP Type Name: Any
Source Type: Port/IP Group
Address Group: UptimeRobot
Port Group: Any
Destination Type: Port/IP Group
Address Group: Any
Port Group: Any
Advanced: Auto
Sign up for a free UptimeRobot account and add a new monitor.
Monitor Type: Ping
IP/Host: testclient.downtimealertexample.live
Select "Alert Contacts To Notify"
Sign into UptimeRobot on your iPhone to enable push notifications there.
Wait about 5-10 minutes and see if your network is online!
For faster alerts, you can sign up for an UptimeRobot Pro plan.
Repeat the above steps 2-7 to create individual subdomains and monitors for each of the UniFi sites that you want to monitor.
NameCheap allows up to 150 subdomains per domain name.
UptimeRobot allows up to 50 monitors on their free plan.
Bonus Tip
UniFi only updates the Dynamic DNS service when the IP address changes, so if for some reason the previous update didn’t work or you want to test your configuration, you can use the following command to manually update Dynamic DNS:
/usr/sbin/inadyn -n -s -C -f /run/ddns-eth4-inadyn.conf -1 -l debug --foreground --force
To run the command, first enable Device SSH Authentication on your UniFi controller in Network > Settings > System > Advanced. Enable Debug Tools on the same page, and then go to Network > UniFi Devices > select your Gateway > Settings > Debug.
You may need to modify the “ddns-eth4-inadyn.conf” part of the command depending on the number of ports on your gateway, which port is the WAN port, and whether you’re using a PPPoE connection, etc. To find the correct “.conf” file, use this command and look for any file that starts with “ddns-” e.g. “ddns-eth9-inadyn.conf” or “ddns-ppp0-inadyn.conf”, and replace that part of the manual update command above:
ls /run
If you appreciate this post, please support us on Patreon!