Some Bits: Nelson's log

30 posts about ubiquiti

Rewiring my network (gear, tiedowns)

I cleaned up all the networking gear in my garage in Grass Valley and tied it all down to a nice little cart. It’s a little more complicated than the usual because I have two separate ISPs and two routers. (The second is a backup, but available all the time on the same LAN.)

The main layout here is networking boxes on the top shelf, A/C power connections on the bottom, and various PoE, USB, and proprietary DC power cables going from bottom to top. Everything comes in and out of the patch panel at back left.

Hardware

The main connection is Starlink plugged into a brand-new Ubiquiti UX7 router with a Ubiquiti Lite-8-PoE switch. That’s the Starlink power supply with the red PoE cable at right, it goes to a dish on the roof. The Ubiquiti boxes are the two white boxes top middle and their USB power supplies at back bottom.

The backup connection is my local WISP. The router is a the blue box at left, an OpenWRT One. There’s a PoE module for the antenna on the bottom. That cable goes to a 400 foot run with a coupler in it before it gets to the antenna in a tree, it’s a miracle it works.

The big black box in lower middle is a Cyberpower UPS. It has a white power strip plugged into the battery backup side.

Tie-downs and physical layout

This is the first time I’ve ever intentionally organized this much network gear. I’m glad I did it!

The patch panel is at upper left, the black box. That was Claude’s idea. It’s a goofy little thing that takes regular keystone jacks in the back instead of a punchdown. It’s basically six couplers in a block, entirely passive. I like it! Makes it much simpler to understand the organization of everything that comes in and out of the network.

All of the boxes are velcro-tied to the wire shelves. This isn’t very good, they slide around and twist and generally aren’t very esccure.

All of the power cables are bundled and zip-tied. The network cables are not. I left them free. I also chose not to tie any cables at all to the wire shelves. I was originally but it seems unnecessary, and you can’t run right angles with any of these wires anyway.

Ubiquiti router swap: backup restore

I’m upgrading my home router hardware. I’m not sure Unifi has a clear path for doing this at home scale, it’s a bit tricky.

The path I’ve chosen is to configure the new router by restoring a backup from the old one, then swapping the hardware. Simple enough as long as you’re careful to not put both devices on the ethernet at the same time. Otherwise they’ll both try to use the same IP and both be serving DHCP). The one real wrinkle is Wi-Fi, when you restore to the new device it will have Wi-Fi turned on with your SSID and unless you have a Faraday cage you can’t easily isolate it. I just chose to live with it for the minute or two until I could get in and pause the WiFi.

However: UnifiOS has a serious flaw. You can’t restore from a backup for a site other than the Default site. See the notes here. I don’t know why but my old router was set up with some other site, Default was unconfigured with a stock 192.168.1.1 setup.

Claude to the rescue: it offered to edit the backup file after it was generated and swizzle in the Default site name. This worked fine. There’s one more wrinkle, the .unf backup file is encrypted but the password is well known. Claude just decrypted it, edited it, and re-encrypted it for me. What a bro. (No thanks to you, BC Yang.)

Anyway that all done and now my new router acts like the old one. It’s got the same LAN config, the same static routes, the same hostnames for MAC addresses, etc. Phew.

Another example of the kind of thing I could have figured out on my own but would have been several frustrating days of tinkering. Claude had it done in half an hour.

Giving Claude the keys (Proxmox, Unifi router)

Claude Code is awfully effective if you give it full root access to a Proxmox server and/or a Unifi router. Or any Linux server. It’s scary and not a good idea for high value systems but for my low stakes homelab stuff it’s nice.

The safe way

I continue to get a lot of mileage out of using Claude Code to do sysadmin for me, particularly creating and managing containers in Proxmox. I have migrated or created some 25 containers to NixOS that Claude builds now and it’s been a great experience.

Up until last week I was doing this manually. I gave Claude limited access to Proxmox and my existing old containers, basically read-only. I did give it full root access on the containers it created. It’s been entirely responsible and effective with this access. It’s gotten old being the meat agent for Claude, pasting in commands to copy files and create containers. My eyes glazed over and I stopped reviewing the scripts it was telling me to run.

Proxmox YOLO

So I gave Claude root access to my Proxmox server. Not the important one in San Francisco where my life is hosted, just the little one I use for playing media in Grass Valley. And it’s magic. Claude is very good at doing Proxmox. It doesn’t need a skill or anything, it knows the Proxmox command line tools and APIs well.

The big surprise is Claude is quite facile with using pct enter to gain access to containers and inspect what’s going on inside them. A little alarming! But also very helpful. It also has a detailed understanding of Proxmox configurations including networking and system options I barely understand.

A small example of magic was this instruction to migrate a container:

I want to move 102 upsnap to a new nixos container you build and manage. I htink we have an upsnap container in sfpve so you can borrow from that, but you should pull the config from the new machine. there’s only one computer in it, gvld, see screenshot. I’d love it if the same password and tailscale identity and hostname were used in the new nixos system. I’m fine shutting down upsnap for some minutes while you make the new container. give it a 400s ctid.

It’s a simple task. Claude Opus 5.5 Medium handled it like a champ. It took less than ten minutes to oneshot the new system and shut off the old one. Total outage time was 46 seconds. It worked the first time. It helped that I’d trusted Claude to set up this exact same thing before and it was able to use some of its old notes. We’ve gotten good at doing NixOS containers together.

Router YOLO

The big example of magic was my network reboot that went poorly. I asked Claude “figure out what happened” and it did a good job at it. The main thing it did was use all the access I’d given to reach into systems and pull log files. Then cross-correlate timestamps to figure out what happened on my LAN. It’s all stuff I could imagine doing but it’d take me frustrating hours. Claude did it in a few minutes.

So far I haven’t let Claude make changes to my router or other network devices. I’m still just telling it what I want and then applying changes by hand. I wonder how long I’ll keep doing that.

The next big test will be in about five days when I replace my Ubiquiti router and a switch with new Ubiquiti gear. I’m going to do that process by hand, having Claude tell me what to do in the GUI. But I am wistfully thinking how nice it’d be to trust Claude to do all the work for me.

Safety

As I said above, these systems are pretty low stakes. If Claude screws up it’s not a big deal.

I have backups. Proxmox does nightly images of all containers so if something were to go wrong, I have an easy restore path. Proxmox can also take ZFS snapshots but I haven’t been using that. I am sure I could teach Claude to create snapshots when appropriate. NixOS has its own rollback too, Claude has used that a couple of times when a live system upgrade didn’t go right.

One key thing here is I’m trusting Claude not to be malicious. It would be very easy for the agent to use its access to subvert my systems, delete my backups, subtly corrupt things in ways I wouldn’t notice. But Claude doesn’t do that, it’s a tame text elemental. It only wants to help me. There’s still the risk of a mistake. Some sort of safety net is essential but it’s not as scary as I first thought.

Effect on me

I have mostly been using LLMs as partners in thinking, I’m much more comfortable collaborating with Claude to do stuff. But here I’m turning over the job entirely. I still have some influence in the way I frame requests and work on designs and requirements. But I’ve given up a lot of control. Also a lot of understanding, I really don’t understand how these systems it built work. I mean I think I know but it’s nothing like the understanding I’d have if I built them myself.

On the other hand building little containers for services like Upsnap is boring AF. Nice to not have to do the scut work.

GV network reboot: Unifi meshing, Emporia power

I rebooted my network boxes in Grass Valley today and it was a bit rough, took nearly 8 minutes for everything to come back. I rebooted by pulling the power from all the passive switches and routers I care about, also the Starlink dish. It did all eventually come back correctly.

I gave Claude access to all the systems I could and had it do a postmortem. This is my own writeup of what I learned from talking to it.

WiFi mesh loop

When the network switches went down I left the Unifi WiFi access points back up. They were configured in mesh mode, so they started building a mesh network. When the network switches came back up that created a network loop and there was a brief mess as packets flooded everywhere. The APs detected the loop after 12 seconds and turned off meshing. I’ve since disabled meshing in the network config, I never want it.

Proxmox server reboot

My little Proxmox server rebooted itself. I’m not sure why. But I did hear a power relay click. The Proxmox server is plugged into an Emporia smart network switch, so my best guess is it decided to toggle the power for some unknown and unlogged reason. Maybe it reacted badly to the network loop or just being offline for awhile? I dunno, it’s a bad failure mode! Fortunately it did turn on again. This power switch and one other fell off the wireless network and then rejoined it. Three others were fine.

Small stuff

It took my Unifi Security Gateway 3 or more minutes to boot, that was a big delay.

With the USG down nothing was answering DHCP. That wouldn’t ordinarily matter but after unplugging and replugging the switches my Linux box wanted a new DHCP lease. NetworkManager only tried to get a DHCP lease for like 45 seconds and didn’t fall back to just using the old address it had (with a valid lease). Supposedly it will retry again in minutes, but by then I’d unplugged and replugged the ethernet cable forcing a new lease.

I had to put my phone in airplane mode and back to connect to WiFi. Other wireless devices were fine.

IPv6 for first time (Ubiquiti USG, Starlink)

I finally decided to enable IPv6 on my Starlink network. And it seems to work? Ran into a lot of confusion with Ubiquiti Unifi OS, maybe also my Windows client. Still tinkering but some notes. Highlights of things I learned:

  • Prefix Delegation Size: 56
  • Prefix Delegation ID: 1
  • Try an Android phone first as a test client
  • Reboot Windows before it will work with IPv6

The big question is: what’s going to break now that I’ve enabled this? I think all my devices are now magically IPv6 and I just can’t wait to find out what changes. I enabled this because Starlink’s CGNAT means I often get blamed as if I’m a bot, maybe the IPv6 sites will work better. Already anticipating Youtube TV or Netflix or something pitching a fit though.

Starlink ISP

Starlink operates DHCPv6 and hands out /56 addresses. These are rumored to be dynamic and changing at least occasionally: Starlink doesn’t promise fixed IPs for residential users. Given they move me between Seattle and Los Angeles POPs with some regularity I’m not entirely surprised they aren’t maintaining a dynamic routing infrastructure for all users. (There’s a business level service with static IPs.)

Starlink didn’t initially offer IPv6. And for awhile they did but had some problems with their DHCP implementation. Internet searches often find old out of date info. Starlink does now document they offer IPv6. Also more info in this FAQ.

Unifi OS router

I had a hell of a time making sense of what my Ubiquiti Security Gateway (USG-3P) was doing. Some notes.

USG Internet configuration

The first part is getting the USG router to talk to the IPv6 Internet. The main configuration for this is in Settings / Internet / Primary (WAN1). You have to set “Advanced” to “Manual” and then enable “DHCPv6”. Also you have to type in a “Prefix Delegation Size”. 56 works for Starlink and most ISPs, that means you get a /56 address allocation from DHCP. That’s a very large address space.

There’s no indication this configuration works when you do it. The Unifi web UI still shows “IPv6 Address” as blank. If you log in to the USG command line and run ip a or ip 6 a, nothing will show up, it looks like there is no IPv6 address assigned to eth0 (the WAN). Well not entirely: you’ll find an address like fe80::e263:daff:fec4:19ff/64 which is the link-local address, but not an routable Internet address.

The way I realized it was working was running grep dhcp6c /var/log/messages on the USG shell. That shows me a message about IA_PD prefix which contains the actual IPv6 lease assignment from Starlink. Yay! Starlink’s block seems to be 2605:59C0::/28, customers are getting a /56 block from there.

The other way I realized it was working was running ping6 2001:4860:4860::8888 in the USG shell to ping Google DNS via IPv6. Actual IPv6 packets! There’s a traceroute6 that is fun to try too.

The confusing thing is my router still has no IPv6 address assigned to the WAN. Apparently this is expected. ip route is no help for how things are working either. But ip -6 route does show a route for default via fe80::200:5eff:fe00:101. I presume that fe80 address identifies the Starlink dish or the ethernet port it’s plugged in to. I can’t ping6 it, maybe it doesn’t make sense to ping a link local address.

Anyway, the router is on the IPv6 Internet. Now what about the rest of my clients on my LAN?

USG LAN configuration

Once the router is talking to the IPv6 Internet, the other part is convincing the DHCP server the router is running to give out IPv6 addresses to clients. This setting is in Settings / Networks / Default. There’s an IPv6 button. You set the radio button to “Prefix Delegation” to enable it. You’re also forced to set a “Prefix Delegation ID”, a decimal number. I still have no idea what this really means but the number “1” seems to work. Update: this explanation seems right. I’m given a /56 block from the ISP but internally I’m using a /64 subset. The extra 8 bits are the prefix deligation ID: I chose 01. That probably explains why my IPv6 address block given by Starlink has a :de00 in it but my machines have :de01: in the address, the 01 I picked was ORed in.

Note there’s an “Advanced” box. I left that to Auto which means it does SLAAC address assignment which is the simple thing you probably want.

After this is configured there is no indication in the Unifi web UI that it worked. But clients doing DHCP will now get v6 addresses if they ask for them. See below for testing clients.

The part of IPv6 I don’t understand is exactly how exposed my network is. AFAICT every device on my LAN is now potentially globally routable with a unique IPv6 address. So what’s keeping me safe? I think the answer is the default IPv6 firewall rules that Ubiquiti has but I really ought to learn more about that. (Update: yes, default firewall rules are “allow inbound traffic associated with existing connections that were made outbound” followed by “drop everything else”. That’s similar to the implicit firewall of IPv4 NAT routing. This port scanner plausibly confirms that my LAN machines have all their inbound ports filtered.)

Client: Android

My Pixel phone seems to work with IPv6 with no effort at all. https://test-ipv6.com/ shows 10/10 everything working. Various “what is my IP” services all show an IPv6 address. All just happened automatically, no reboot or reconfiguration required. Sadly this was the last client I tried but I should have tried it first.

Client: Alpine Linux

I fired up a quick Alpine VM to manually test IPv6. The default installer doesn’t enable IPv6, you have to add it with iface eth0 inet6 auto to the networking config. But doing that everything else works flawlessly. I can ping Google DNS via IPv6. curl https://api6.ipify.org shows me my IPv6 address. Nice!

Client: Windows

So those two clients were easy. Unfortunately the very first client I tried was my Windows 11 desktop. Once I enabled IPv6 the networking interface picked up an IPv6 address via DHCP. Two of them actually, both in 2605:59c8. One of them actually works! From a DOS command line I can ping my router’s IPv6 address. And from the router I can ping6 the one working Windows address.

However nothing else worked. I couldn’t ping Google DNS via IPv6. The browser test at https://test-ipv6.com/ didn’t work, shows nothing at all. Neither did the test at https://whatismyv6.com/.

I finally gave up and rebooted. And presto, now IPv6 is working fully on my Windows machine.

Client: Ubuntu 23.04 VM

An existing workhorse Linux box I had just started working fine on IPv6, no reconfiguration required. May have not started working until I happened to reboot it.

Client: Proxmox Virtual Environment

My Proxmox server does not seem to have IPv6 enabled by default. The docs indicate IPv6 is supported so it’s probably something with how I configured the server with a static IPv4 address at setup. Guest VMs can access IPv6 no problem (see above), not sure about containers. The default bridge (vmbr0) has some IPv6 stuff I didn’t configure so it probably won’t work. Actually a little confused, since that bridge is also used for the VM networking.

The yearly Ubiquiti UnifiOS disaster

About once a year my Ubiquiti routers give me trouble. I’ve long since stopped asking anything complicated of them like reliable failover or a VPN. I just want it routing packets. This week’s problem is my Unifi Dream Machine, my router/access point in San Francisco. I installed in in late 2020 and to its credit haven’t thought much about it since. Including not doing software updates. (Oops).

Yesterday I tried to upgrade it from version 1.0.10. It went badly, I ended up having to factory reset and rebuild the network configuration from memory. Some notes on that:

Being safer next time

First, how to prevent the mess I found myself in. The main problem is I had no backup of the Network application config. I did have one for the UDM console itself but that doesn’t contain the useful network stuff like wifi SSID, subnet, port forwarding, ... I should have made a backup before doing anything. Modern Unifi systems are backing up to the cloud, maybe automatically, but mine was so old I think I had to have done a manual backup and downloaded it. By the time I thought to do that it was too late.

What went wrong

The update process sucked. It wanted to upgrade itself like six times as it hauled itself forward through versions. Each update took at least 5 minutes, one said it’d take 20 and was more like 45. Each time the Internet connection would go down for a few seconds, twice. Mostly though it looked like things were working.

Until I got to UnifiOS v4.0.6, the current version. That time when it booted the “Network” app that’s most of what I really care about never started. Just spinning, hung in starting. I logged in via ssh to see what was up and couldn’t really figure it out. The mongod was spinning around 100% CPU though. Why Ubiqiuti chose such a weird and unreliable database for this simple application is beyond me.

The Internet is full of advice on how to manually repair corrupted Unifi mongo databases. But I decided to cut my losses and do a factory reset. The appliance said it had a full cloud backup, should be easy right? ha, joke’s on me. That was just a backup of the host OS itself, not the network. After the reset and restore the network was default settings.

I had no network backup. I’m a little confused; the updated Network 8.2.93 app has a manual backup option that downloads a file, but then implies the cloud backup of the console should cover the network too. That didn’t work for me, maybe because the crucial update failed? I was able to do one manual backup of 8.2.93 after configuration. A second one never completed. A third fails immediately. That does not inspire confidence. After a reboot a backup worked.

(I also can’t figure out how to backup the network config on a self-hosted Unifi linux environment running Network 8.0.7. The backup button does not appear under Settings > System. A comment I read online suggests this may be a user permissions problem but I can visually inspect all the settings I want to back up so that seems wrong or dumb. I was finally able to make a backup using the managed utility at https://unifi.ui.com/. I also saw a hint monthly backups were happening and being stored locally, not synced to cloud.)

Rebuilding the network

So I rebuilt the network. Over the years I’ve learned my lesson and keep the router as simple as possible. But I use the non-default 192.168.0.* subnet. Also am forwarding ports for ssh, web servers, tailscale, plex, and syncthing. There’s a lot of fun looking other settings for things like the WiFi radio I didn’t touch.

I had to re-adopt my UAP-AC-Pro access point. In theory my restore for the UDM should have taken care of that. Getting the impression that backup did absolutely nothing useful. At least that’s relatively simple since there’s no significant device configuration. Hold down the reset button on the hardware, then click the “Adopt” button in the webapp.

Some observations

Complaints and disaster aside the latest Network webapp on the UDM is pretty snappy. The old bugs where you’d change something in the config and it wouldn’t take until a reboot seem gone. The app shows lots of interesting things like a visualization of how all your wifi clients are doing. There’s also a neat NetMan mobile app for more wifi testing.

The Unifi network webapp itself is some overgrown dynamic Javascript architecture where page loads aren’t really page loads. It’s perfectly possible to click the “Dashboard” button and see a working new dashboard page even though the router is actually down. Just old data and no immediate confirmation that the router is even up. Really bad choice for a router, as snappy as it may be.

The Dynamic DNS configuration for Afraid has you storing your account password in plaintext. Afraid has long-had a token based authentication mechanism they should be using instead.

By default port 443 is captured by the router itself to get to its own admin page. That’s probably secure, and I think but am not certain it’s not available over the Internet by default. Also you can port forward 443 somewhere else on your LAN if you need. Ubiquiti has a whole remote management API with mobile apps and stuff you’re supposed to use instead of the web server. It’s pretty nice, TBH.

Ubiquiti routers: garbage bandwidth stats

My Ubiquiti routers continue to vex me, Unifi OS has lots of problems. My latest complaint is it’s not even able to give me a basic accounting of how much bandwidth each device (IP address) on my LAN is using.

For instance, here’s what I think is a graph of the last month’s traffic for my Playstation. I downloaded a 60GB game on Nov 17. I also probably downloaded at least one other > 30GB game that month but I’m not positive.

In upper right it says 66.7GB download for the month. That is a plausible number but I think is low But then in the graph it shows an average of 0.8Mbps for the day of November 17. Also plausible? 0.8*86400 = 69GB. In the graph tooltip it says “Total Traffic” (for the day) is 9GB. That doesn’t agree with the graph data! And then in the chart below it says “All Traffic: 6GB” for the whole month. On a different screen for the device it says “Traffic Activity: 1.66GB”. It’s like they’re picking random numbers.

The displays are utter nonsense. This problem has been going on for years. (Before, they didn’t even have any traffic stats.) I’m not the only one complaining: see here or here or here or any of these.

Unifi also has a more ambitious “Traffic Identification” display where they try to show you bandwidth by application: Youtube, etc. Doing that reliably is hard, I would expect some inaccuracy. But counting by device IP should be really simple. Failing that makes me wonder what else is wrong in the router that is less visible. (BTW, that screenshot above may actually be what it thinks for my whole network, although in context it doesn’t seem to be. If I explicitly choose PS5 I get another graph that shows that same 1.66GB total and otherwise obviously wrong small numbers.)

Every time I see a product fail this badly I always wonder, do the engineers who work there give a shit? Do they use their own software?

Ubiquiti, RFC3442, and Starlink routes

I’m still trying to find a solution for the problem I have with a router bug and Starlink. First, a meta commentary. A friend teased me for all this writing about Starlink and routers. Let me just say it sucks. Trying to understand a broken Internet connection without the means to really fix it is intensely frustrating. The router is a bit more in my control and I’ve come to the conclusion Ubiquiti’s newer routers just have bad software. Next time I work on this I’m going to try an OpenWRT router again, maybe the SmoothWAN variant with channel bonding.

I have a USG 3P router. Ubiquiti has a router bug where static routes don’t work with WAN failover. Starlink looks like a normal ISP gateway, with DHCP advertising a route to the internet. But it also has a special hidden route for 192.168.100.1 so you can access Dishy’s stats. The easy thing to do is add a static route. This works fine on the Ubiquiti router unless you have WAN failover enabled (a backup Internet). Then the static route breaks. This is a known bug discussed for many years now.

(An added complication; Starlink’s dish also listens at http://34.120.255.244/. Not sure why but I’d hoped maybe this would work even without a special route for it, since it’s a public IP address. No such luck.)

My reader Daniel Y wrote in to suggest an interesting fix: install this rfc3442-classless-routes script to run as a DHCP exit hook. Starlink advertises the extra routes via a DHCP option. Which Ubiquiti apparently ignores? It’s apparently necessary for some European ISPs, and it’d sure be handy for Starlink. This script will set them. As a side effect Daniel said this also fixed the other bug I was talking about, where the router just ignores the DHCP lease in certain scenarios. I worked around that bug by inserting an ethernet switch between Dishy and the router so the ethernet link stopped going down.

Anyway, I tried the RFC 3442 script and it didn’t work for me. I did some debugging... First, it looks like my USG 3P has the RFC3442 routes even without this script. Maybe Ubiquiti did implement it afterall? (Daniel has the older EdgeRouter, most discussion is about those.) Second, the script gets invoked in a way it doesn’t seem to be expecting; there’s no $reason environment variable set so it doesn’t work. I hacked around this and tried adding routes with ip route add like the script would and nothing worked.

It’s a weird failure. Here’s the routing table according to ip route or Ubiquiti’s show ip route

default via 100.64.0.1 dev eth0  proto zebra
10.33.1.0/24 dev eth2  proto kernel  scope link  src 10.33.1.31
34.120.255.244 dev eth0  scope link
100.64.0.0/10 dev eth0  proto kernel  scope link  src 100.103.201.245
127.0.0.0/8 dev lo  proto kernel  scope link  src 127.0.0.1
192.168.3.0/24 dev eth1  proto kernel  scope link  src 192.168.3.1
192.168.100.1 dev eth0  scope link

That sure looks good to me! So why can’t I reach 192.168.100.1? Even explicitly doing ping -I eth0 192.168.100.1 doesn’t work.

My suspicion, without evidence, is that failover on the USG 3P is implemented in some complicated way that totally bypasses normal IP routing. That the routing table I see there doesn’t work. That doesn’t explain why the explicit ping-through-an-interface also fails. Honestly it’s all just such a black box. A broken black box. Ugh.

Random other Ubiquiti bug: their UI only supports RSA ssh keys. Can’t use Ed25519 or the other newer key types. Crap like that makes me cranky.

Starlink vs Ubiquiti OS: outages with WAN failover

I’ve got a problem that’s recently gotten worse on my LAN. Starlink will stop working and my Ubiquiti router fails over to the backup. But then it never switches back even though it looks like Starlink is up. It appears to be a DHCP failure; my router can’t get an address for the Dishy interface.

Sometimes rebooting the router fixes it; that suggests it’s a UnifiOS problem. Sometimes I have to turn Dishy off for 10+ minutes and then it starts working again, suggesting it’s a Starlink problem. Or maybe it’s more complicated. Today when this happen I rebooted the router but not Dishy. It started working after a minute or three.

This problem has occurred off and on for two years but is now happening about once a day. Rebooting the router seems the best way to get it working again. But I think the problem has fixed itself at least once (after several hours). I may also have had to turn Dishy off entirely for awhile to get things working.

I know from other sources that Starlink’s ground infrastructure has some sort of reset that happens if Dishy is offline for a few minutes, so often unplugging for awhile fixes things. I also know DHCP has to go all the way through the satellite to the Starlink ground station, so if the network is overloaded it’s not as reliable. But this big failure happens at quiet times too, like just now at 7am.. Finally I know UnifiOS also has bugs in its failover system. So many bugs; I probably won’t buy another Ubiquiti product.

An idea for a fix.

I’m trying a fix right now, putting a Netgear ethernet switch between my router and the Dishy PoE injector. I’ve seen signs in the logs that maybe the ethernet link is failing. And coming back, but maybe that’s not working right? I’ve heard other folks suggest a switch may help smooth out problems.

DHCP Logs

I’ve got logs from the router. They are spammy so I’m narrowing in on just the DHCP part like this. grep DHCP *.1.log | grep -v eth1. Here’s what it looks like when things are going well:

2023-01-22T15:02:21,354 <30>Jan 22 07:02:21 ubnt dhclient: DHCPREQUEST on eth0 to 100.64.0.1 port 67
2023-01-22T15:02:21,440 <30>Jan 22 07:02:21 ubnt dhclient: DHCPACK from 100.64.0.1

2023-01-22T15:04:34,843 <30>Jan 22 07:04:34 ubnt dhclient: DHCPREQUEST on eth0 to 100.64.0.1 port 67
2023-01-22T15:04:34,918 <30>Jan 22 07:04:34 ubnt dhclient: DHCPACK from 100.64.0.1

2023-01-22T15:07:03,124 <30>Jan 22 07:07:03 ubnt dhclient: DHCPREQUEST on eth0 to 100.64.0.1 port 67
2023-01-22T15:07:03,208 <30>Jan 22 07:07:03 ubnt dhclient: DHCPACK from 100.64.0.1

Starlink leases are 5 minutes. So the router requests a new address from the 100.64.0.1 endpoint it knows about every 2.5 minutes and all is well.

Here’s what it looks like when it fails:

2023-01-22T15:07:03,124 <30>Jan 22 07:07:03 ubnt dhclient: DHCPREQUEST on eth0 to 100.64.0.1 port 67
2023-01-22T15:07:03,208 <30>Jan 22 07:07:03 ubnt dhclient: DHCPACK from 100.64.0.1

2023-01-22T15:08:37,364 <30>Jan 22 07:08:37 ubnt dhclient: DHCPRELEASE on eth0 to 100.64.0.1 port 67

2023-01-22T15:08:45,935 <30>Jan 22 07:08:45 ubnt dhclient: DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 7
2023-01-22T15:08:45,988 <30>Jan 22 07:08:45 ubnt dhclient: DHCPREQUEST on eth0 to 255.255.255.255 port 67
2023-01-22T15:08:45,988 <30>Jan 22 07:08:45 ubnt dhclient: DHCPOFFER from 100.64.0.1

2023-01-22T15:08:52,524 <30>Jan 22 07:08:52 ubnt dhclient: DHCPREQUEST on eth0 to 255.255.255.255 port 67

2023-01-22T15:09:07,104 <30>Jan 22 07:09:07 ubnt dhclient: DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 8
2023-01-22T15:09:07,171 <30>Jan 22 07:09:07 ubnt dhclient: DHCPREQUEST on eth0 to 255.255.255.255 port 67
2023-01-22T15:09:07,171 <30>Jan 22 07:09:07 ubnt dhclient: DHCPOFFER from 100.64.0.1

2023-01-22T15:09:14,163 <30>Jan 22 07:09:14 ubnt dhclient: DHCPREQUEST on eth0 to 255.255.255.255 port 67

2023-01-22T15:09:25,674 <30>Jan 22 07:09:25 ubnt dhclient: DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 4
2023-01-22T15:09:25,766 <30>Jan 22 07:09:25 ubnt dhclient: DHCPREQUEST on eth0 to 255.255.255.255 port 67
2023-01-22T15:09:25,767 <30>Jan 22 07:09:25 ubnt dhclient: DHCPOFFER from 100.64.0.1

The log starts with one working exchange. Then 1.5 minutes later my router spontaneously sent a DHCPRELEASE out to Starlink. Um, why? After that my router starts DHCP from ground zero, broadcasting DHCPDISCOVER and DHCPREQUEST on the link to 255.255.255.255. It’s lost all DHCP state. It logs that it got a DHCPOFFER from 100.64.0.1 and that’s good, right? But apparently Ubiquiti didn’t like the offer or ignored it because it just tries again in a few seconds. It gets stuck in this state, sending DISCOVER several times a minute, getting offers, and never working.

Here’s what happens after I reboot the router. Starlink didn’t come back right away after the reboot but did start working pretty quickly, within a minute or so.

2023-01-22T16:10:58,089 <13>Jan 22 08:10:58 ubnt shutdown[3967]: shutting down for system reboot

2023-01-22T16:13:28,518 <86>Jan 22 08:13:01 ubnt sudo: pam_unix(sudo:session): session closed for user root
2023-01-22T16:13:28,567 <86>Jan 22 08:13:01 ubnt sudo:     root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/bin/sh -c echo \"LAN\" >/sys/class/net/eth1/ifalias

...

2023-01-22T16:13:34,806 <30>Jan 22 08:13:08 ubnt dhclient: DHCPDISCOVER on eth2 to 255.255.255.255 port 67 interval 6
2023-01-22T16:13:34,809 <30>Jan 22 08:13:08 ubnt dhclient: DHCPREQUEST on eth2 to 255.255.255.255 port 67
2023-01-22T16:13:34,809 <30>Jan 22 08:13:08 ubnt dhclient: DHCPOFFER from 10.33.1.1
2023-01-22T16:13:34,811 <30>Jan 22 08:13:08 ubnt dhclient: DHCPACK from 10.33.1.1

2023-01-22T16:14:16,367 <30>Jan 22 08:13:49 ubnt dhclient: DHCPREQUEST on eth2 to 255.255.255.255 port 67
2023-01-22T16:14:16,381 <30>Jan 22 08:13:49 ubnt dhclient: DHCPACK from 10.33.1.1

2023-01-22T16:14:16,408 <30>Jan 22 08:13:49 ubnt dhclient: DHCPREQUEST on eth0 to 255.255.255.255 port 67
2023-01-22T16:14:16,470 <30>Jan 22 08:13:49 ubnt dhclient: DHCPACK from 100.64.0.1

2023-01-22T16:16:14,856 <30>Jan 22 08:16:14 ubnt dhclient: DHCPREQUEST on eth0 to 100.64.0.1 port 67
2023-01-22T16:16:14,912 <30>Jan 22 08:16:14 ubnt dhclient: DHCPACK from 100.64.0.1

So the system requests reboot at 08:10:58 and finally reboots at 08:13:01. 7 seconds later it makes a DHCP request on eth2; that’s my backup WAN. It works. No hint of anything on eth0, the primary WAN which Dishy is plugged into. Why? But it gets around to asking for eth0 at 08:13:49, 41 seconds later, and it works. Another routine request succeeds at 08:16:14. We’re back online with Starlink.

More logs

Those samples above are all logs filtered on “DHCP”, but maybe important stuff is hiding in the other log spam. Here’s more detailed logs of the failure around 07:08:37 when the mystery DHCPRELEASE happened. Still doing a bit of filtering egrep -v 'mcad|ipsec|pam_unix' *.1.log

2023-01-22T15:07:03,124 <30>Jan 22 07:07:03 ubnt dhclient: DHCPREQUEST on eth0 to 100.64.0.1 port 67
2023-01-22T15:07:03,208 <30>Jan 22 07:07:03 ubnt dhclient: DHCPACK from 100.64.0.1
2023-01-22T15:07:07,613 <30>Jan 22 07:07:07 ubnt dhclient: bound to 100.103.201.245 -- renewal in 115 seconds.

2023-01-22T15:08:35,284 <30>Jan 22 07:08:35 ubnt netplugd[3542]: eth0: state ACTIVE flags 0x00011043 UP,BROADCAST,RUNNING,MULTICAST,10000 -> 0x00001003 UP,BROADCAST,MULTICAST
2023-01-22T15:08:35,284 <190>Jan 22 07:08:35 ubnt zebra[753]: interface eth0 index 2 changed <UP,BROADCAST,MULTICAST>.
2023-01-22T15:08:35,284 <30>Jan 22 07:08:35 ubnt netplugd[25603]: /etc/netplug/netplug eth0 out -> pid 25603
2023-01-22T15:08:35,293 <5>Jan 22 07:08:35 ubnt kernel: eth0: Link down

2023-01-22T15:08:35,951 <181>Jan 22 07:08:35 ubnt wlb: wlb-wan_failover-eth0 wlb-wan_failover-eth0 reachability failed, failover
2023-01-22T15:08:35,951 <181>Jan 22 07:08:35 ubnt wlb: group wan_failover, interface eth0 going Inactive
2023-01-22T15:08:36,211 <181>Jan 22 07:08:36 ubnt wlb: group wan_failover, interface eth2 going Active
2023-01-22T15:08:36,258 <13>Jan 22 07:08:36 ubnt wan-event: [WAN Transition] eth0 to state inactive
2023-01-22T15:08:36,659 <13>Jan 22 07:08:36 ubnt wan-event: [WAN Transition] eth2 to state active
2023-01-22T15:08:36,671 <86>Jan 22 07:08:36 ubnt sudo:     root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/usr/sbin/conntrack -F

2023-01-22T15:08:37,260 <86>Jan 22 07:08:37 ubnt sudo:     root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/sbin/dhclient -q -cf /var/run/dhclient_eth0.conf -pf /var/run/dhclient_eth0.pid -lf /var/run/dhclient_eth0.leases -r eth0
2023-01-22T15:08:37,324 <30>Jan 22 07:08:37 ubnt netplugd[3542]: eth0: state OUTING flags 0x00001003 UP,BROADCAST,MULTICAST -> 0x00011043 UP,BROADCAST,RUNNING,MULTICAST,10000
2023-01-22T15:08:37,324 <190>Jan 22 07:08:37 ubnt zebra[753]: interface eth0 index 2 changed <UP,BROADCAST,RUNNING,MULTICAST>.
2023-01-22T15:08:37,333 <5>Jan 22 07:08:37 ubnt kernel: eth0: 1000 Mbps Full duplex, port 0
2023-01-22T15:08:37,364 <30>Jan 22 07:08:37 ubnt dhclient: DHCPRELEASE on eth0 to 100.64.0.1 port 67

2023-01-22T15:08:38,875 <86>Jan 22 07:08:38 ubnt sudo:     root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/sbin/ip route add 0.0.0.0/0 via 100.64.0.1 table 201
2023-01-22T15:08:38,965 <86>Jan 22 07:08:38 ubnt sudo:     root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/sbin/ip route add blackhole 0.0.0.0/0 table 201 metric 256
2023-01-22T15:08:39,707 <30>Jan 22 07:08:39 ubnt ntpd[2874]: Deleting interface #36 eth0, 100.103.201.245#123, interface stats: received=58, sent=58, dropped=0, active_time=6861 secs
2023-01-22T15:08:39,708 <30>Jan 22 07:08:39 ubnt ntpd[2874]: 65.108.121.104 interface 100.103.201.245 -> (null)
2023-01-22T15:08:39,708 <30>Jan 22 07:08:39 ubnt ntpd[2874]: 205.206.70.42 interface 100.103.201.245 -> (null)
2023-01-22T15:08:39,708 <30>Jan 22 07:08:39 ubnt ntpd[2874]: 103.242.68.69 interface 100.103.201.245 -> (null)
2023-01-22T15:08:39,708 <30>Jan 22 07:08:39 ubnt ntpd[2874]: 144.76.76.107 interface 100.103.201.245 -> (null)

2023-01-22T15:08:41,079 <86>Jan 22 07:08:41 ubnt sudo:     root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/usr/sbin/ubnt-add-connected.pl
2023-01-22T15:08:41,610 <86>Jan 22 07:08:41 ubnt sudo:     root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/bin/rm -f /var/run/dhclient_eth0.pid
2023-01-22T15:08:42,643 <86>Jan 22 07:08:42 ubnt sudo:     root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/opt/vyatta/sbin/vyatta-interfaces.pl --dev eth0 --restore-ipv6
2023-01-22T15:08:44,308 <30>Jan 22 07:08:44 ubnt netplugd[3542]: eth0: state OUTING pid 25603 exited status 0
2023-01-22T15:08:44,309 <30>Jan 22 07:08:44 ubnt netplugd[25761]: /etc/netplug/netplug eth0 in -> pid 25761
2023-01-22T15:08:45,718 <86>Jan 22 07:08:45 ubnt sudo:     root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/bin/sh -c /sbin/dhclient -q -nw -cf /var/run/dhclient_eth0.conf -pf /var/run/dhclient_eth0.pid  -lf /var/run/dhclient_eth0.leases eth0  2> /dev/null &
2023-01-22T15:08:45,935 <30>Jan 22 07:08:45 ubnt dhclient: DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 7
2023-01-22T15:08:45,988 <30>Jan 22 07:08:45 ubnt dhclient: DHCPREQUEST on eth0 to 255.255.255.255 port 67
2023-01-22T15:08:45,988 <30>Jan 22 07:08:45 ubnt dhclient: DHCPOFFER from 100.64.0.1

I’ve put line breaks in logical groupings. Group 1 is a normal good DHCP exchange. Group 2 is 90 seconds later and looks like eth0 spontaneously went down. There’s nothing in the logs to explain why that might have happened. Group 3 is the failover system correctly realizing eth0 isn’t working and switching me to my backup WAN, eth2. Group 4 is eth0 coming back up just about 2 seconds after it went down. Note that the router sends the DHCPRELEASE at the end of this little group.

It then takes a good 7 seconds until the last group when the router sends a DHCPDISCOVER out the Dishy interface. Why so long? And even though it gets a DHCPOFFER reply immediately the router doesn’t seem to use it. And then we’re back to the logfile above; there’s no extra info in the extended logs to shed light on why it’s not accepting the offer.

So my guess of what’s going on based on these logs is..

  • Hardware gremlins cause eth0 to fail
  • The router correctly shuts down the eth0 interface and fails over
  • eth0 comes back up 2 seconds later
  • The router correctly releases the DHCP lease, then tries to get a new one
  • Starlink ?correctly? sends a DHCP offer as soon as asked
  • The router bugs out and fails to use the lease. It keeps trying several times a minute.
  • I have to reboot the router to fix it, or it magically fixes itself after minutes / hours.

These are all pretty rough guesses though. I’m poking at two black boxes with one crappy logfile as my only evidence. Anyway I put a switch in the path to maybe help defend against hardware gremlins. We’ll see. Update: so far so good, 7 days without a disconnect. OTOH the old setup used to go a week+ without a problem too so not certain. I’ve seen other failovers but nothing related to eth0 going down.

eth0 goes down a lot

I should note that eth0 seems to go down a lot; several times a day. But not every day? There’s a gap of a whole week where it never once went down, then another gap of a day+. Super weird. Anyway the DHCP failure doesn’t happen every single time eth0 goes down.

# grep -h 'eth0: Link down' *.1.log* | sort -n

2023-01-10T11:27:19,663 <5>Jan 10 03:27:19 ubnt kernel: eth0: Link down
2023-01-10T11:27:36,793 <5>Jan 10 03:27:36 ubnt kernel: eth0: Link down
2023-01-10T13:22:33,664 <5>Jan 10 05:22:33 ubnt kernel: eth0: Link down
2023-01-10T15:17:28,666 <5>Jan 10 07:17:28 ubnt kernel: eth0: Link down
2023-01-10T17:12:23,981 <5>Jan 10 09:12:23 ubnt kernel: eth0: Link down

2023-01-18T02:22:33,753 <5>Jan 17 18:22:33 ubnt kernel: eth0: Link down
2023-01-18T04:52:05,885 <5>Jan 17 20:52:05 ubnt kernel: eth0: Link down
2023-01-18T05:02:24,905 <5>Jan 17 21:02:24 ubnt kernel: eth0: Link down
2023-01-18T07:48:57,901 <5>Jan 17 23:48:57 ubnt kernel: eth0: Link down
2023-01-18T09:43:53,337 <5>Jan 18 01:43:53 ubnt kernel: eth0: Link down
2023-01-18T11:38:48,875 <5>Jan 18 03:38:48 ubnt kernel: eth0: Link down
2023-01-18T13:33:44,726 <5>Jan 18 05:33:44 ubnt kernel: eth0: Link down
2023-01-18T14:58:30,367 <5>Jan 18 06:58:30 ubnt kernel: eth0: Link down
2023-01-18T14:59:01,387 <5>Jan 18 06:59:01 ubnt kernel: eth0: Link down
2023-01-18T16:53:56,208 <5>Jan 18 08:53:56 ubnt kernel: eth0: Link down
2023-01-18T17:02:20,938 <5>Jan 18 09:02:20 ubnt kernel: eth0: Link down
2023-01-18T19:29:46,174 <5>Jan 18 11:29:46 ubnt kernel: eth0: Link down
2023-01-18T21:24:42,410 <5>Jan 18 13:24:42 ubnt kernel: eth0: Link down
2023-01-18T23:19:38,480 <5>Jan 18 15:19:38 ubnt kernel: eth0: Link down
2023-01-19T01:14:34,209 <5>Jan 18 17:14:34 ubnt kernel: eth0: Link down
2023-01-19T03:09:29,842 <5>Jan 18 19:09:29 ubnt kernel: eth0: Link down
2023-01-19T05:04:25,189 <5>Jan 18 21:04:25 ubnt kernel: eth0: Link down
2023-01-19T06:59:19,270 <5>Jan 18 22:59:19 ubnt kernel: eth0: Link down
2023-01-19T08:54:14,486 <5>Jan 19 00:54:14 ubnt kernel: eth0: Link down
2023-01-19T10:49:11,733 <5>Jan 19 02:49:11 ubnt kernel: eth0: Link down
2023-01-19T12:44:05,754 <5>Jan 19 04:44:05 ubnt kernel: eth0: Link down
2023-01-19T14:39:02,849 <5>Jan 19 06:39:02 ubnt kernel: eth0: Link down

2023-01-21T11:04:04,617 <5>Jan 21 03:04:04 ubnt kernel: eth0: Link down
2023-01-21T12:59:17,757 <5>Jan 21 04:59:17 ubnt kernel: eth0: Link down
2023-01-21T14:54:11,780 <5>Jan 21 06:54:11 ubnt kernel: eth0: Link down
2023-01-21T16:49:09,336 <5>Jan 21 08:49:09 ubnt kernel: eth0: Link down
2023-01-22T11:18:27,227 <5>Jan 22 03:18:27 ubnt kernel: eth0: Link down
2023-01-22T11:18:44,227 <5>Jan 22 03:18:44 ubnt kernel: eth0: Link down
2023-01-22T13:13:40,293 <5>Jan 22 05:13:40 ubnt kernel: eth0: Link down
2023-01-22T15:08:35,293 <5>Jan 22 07:08:35 ubnt kernel: eth0: Link down
2023-01-22T15:59:57,613 <5>Jan 22 07:59:57 ubnt kernel: eth0: Link down

Starlink DHCP vs UnifiOS

My Starlink connection will work for days, then get in a mode where every 5 minutes the connection will fail for 30 seconds before it comes back. Long story short it looks like Starlink has a problem where it’s not responding to DHCP address renewals sometime.

Complicating matters; this is a Ubiquiti USG-3P router running UnifiOS and I have a backup WAN configured. Ubiquiti’s backup WAN stuff is a bit flaky, and also the failover does tend to both hide connection problems (when it fails over) and cause some (the failover itself breaks existing sessions.)

I’ve opened a support ticket for this, TIK-213261-55007-82. And I got two replies!

Apr 12: our engineering team is aware of cases where customers are having WAN DHCP renewal issues and the 5 minute lease expires. Our DHCP server engineers are actively working on this and I did send a link to the blog post to the lead engineer, appreciate the write up. Apologies for the issues and please bear with us.

Apr 15: our network software team deployed two fixes last night to hopefully resolve the DHCP renew issue

I finally got some DHCP logging set up to understand what’s going on at the router when the problem happens. Details below, mostly for my own troubleshooting.

The USG-3P has three ethernet ports. They are

  • Starlink, the primary WAN: on eth0, typically at an IP like 100.74.162.37.
  • My LAN: on eth1, 192.168.3.1
  • SmarterBroadband, the backup WAN2: on eth2, 10.33.1.1

My understanding of the DHCP behavior is that when connected, Starlink gives out an IP address in the CGNAT block 100.64.0.0/10 with an expiration of 5 minutes. Ubiquiti’s DHCP client accepts this address and binds to it. It also renews it every 2.5 minutes, half the lease time. If the renewal doesn’t happen in that 2.5 minutes then the link is effectively dead, packets to it fail, and the WAN failover process starts. (DHCP clients are not allowed to keep using an address past the lease expiration!) I’m not certain how the DHCP request is answered by Starlink, but my guess is the DHCP request goes up to the satellite and down to a ground station in Seattle where Starlink answers it. My working theory is those DHCP requests aren’t getting answered.

Update: there are reports that Starlink is starting to serve 1 hour DHCP leases. (Later they say it went back to 5 minutes; maybe a temporary change?)

Observed

When things are going well, every 2-3 minutes there’s an entry like this in the log:

2022-04-09T20:30:07,108 <30>Apr  9 13:30:07 ubnt dhclient: bound to 100.74.162.37 -- renewal in 138 seconds.
2022-04-09T20:32:25,233 <30>Apr  9 13:32:25 ubnt dhclient: DHCPREQUEST on eth0 to 100.64.0.1 port 67
2022-04-09T20:32:25,292 <30>Apr  9 13:32:25 ubnt dhclient: DHCPACK from 100.64.0.1
2022-04-09T20:32:29,566 <30>Apr  9 13:32:29 ubnt dhclient: bound to 100.74.162.37 -- renewal in 142 seconds.

I believe this is an ordinary DHCP renewal process. The router has an address so it just sends a DHCPREQUEST to request the address again. The server answers back with a DHCPACK and everyone continues along.

When things are going badly, it looks like this:

2022-04-12T15:22:11,377 <30>Apr 12 08:22:11 ubnt dhclient: bound to 100.74.162.37 -- renewal in 117 seconds.
2022-04-12T15:24:08,373 <30>Apr 12 08:24:08 ubnt dhclient: DHCPREQUEST on eth0 to 100.64.0.1 port 67
2022-04-12T15:24:19,743 <30>Apr 12 08:24:12 ubnt dhclient: DHCPREQUEST on eth0 to 100.64.0.1 port 67
2022-04-12T15:24:20,862 <30>Apr 12 08:24:20 ubnt dhclient: DHCPREQUEST on eth0 to 100.64.0.1 port 67
2022-04-12T15:24:39,539 <30>Apr 12 08:24:27 ubnt dhclient: DHCPREQUEST on eth0 to 100.64.0.1 port 67
2022-04-12T15:24:47,472 <30>Apr 12 08:24:47 ubnt dhclient: DHCPREQUEST on eth0 to 100.64.0.1 port 67
2022-04-12T15:24:59,338 <30>Apr 12 08:24:57 ubnt dhclient: DHCPREQUEST on eth0 to 100.64.0.1 port 67
2022-04-12T15:25:07,502 <30>Apr 12 08:25:07 ubnt dhclient: DHCPREQUEST on eth0 to 100.64.0.1 port 67
2022-04-12T15:25:23,323 <30>Apr 12 08:25:23 ubnt dhclient: DHCPREQUEST on eth0 to 100.64.0.1 port 67
2022-04-12T15:25:43,693 <30>Apr 12 08:25:43 ubnt dhclient: DHCPREQUEST on eth0 to 100.64.0.1 port 67
2022-04-12T15:25:57,522 <30>Apr 12 08:25:57 ubnt dhclient: DHCPREQUEST on eth0 to 100.64.0.1 port 67
2022-04-12T15:26:12,669 <30>Apr 12 08:26:07 ubnt dhclient: DHCPREQUEST on eth0 to 100.64.0.1 port 67
2022-04-12T15:26:17,713 <30>Apr 12 08:26:17 ubnt dhclient: DHCPREQUEST on eth0 to 100.64.0.1 port 67
2022-04-12T15:26:28,982 <30>Apr 12 08:26:28 ubnt dhclient: DHCPREQUEST on eth0 to 255.255.255.255 port 67
2022-04-12T15:26:39,022 <30>Apr 12 08:26:39 ubnt dhclient: DHCPREQUEST on eth0 to 255.255.255.255 port 67
2022-04-12T15:26:56,422 <30>Apr 12 08:26:56 ubnt dhclient: DHCPREQUEST on eth0 to 255.255.255.255 port 67
2022-04-12T15:27:10,770 <30>Apr 12 08:27:10 ubnt dhclient: DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 3
2022-04-12T15:27:10,835 <30>Apr 12 08:27:10 ubnt dhclient: DHCPREQUEST on eth0 to 255.255.255.255 port 67
2022-04-12T15:27:10,835 <30>Apr 12 08:27:10 ubnt dhclient: DHCPOFFER from 100.64.0.1
2022-04-12T15:27:10,910 <30>Apr 12 08:27:10 ubnt dhclient: DHCPACK from 100.64.0.1
2022-04-12T15:27:16,963 <30>Apr 12 08:27:16 ubnt dhclient: bound to 100.74.162.37 -- renewal in 134 seconds.

That sure looks to me like Starlink is just not answering the DHCP request. An abbreviated timeline:

  • 15:22:11,377: the router thinks it has a valid address. It should have an expiration of 300 seconds and therefore be renewed in 150 seconds. But it takes awhile for it to arrive, so the actual renewal is scheduled for 117 seconds. (This delay seems normal.) The router should send a DHCPREQUEST to renew the address at 15:24:08. The address will expire around 15:26:38 or maybe a little earlier.
  • 15:24:08,373: the router sends the first DHCPREQUEST to renew its address. It sends it to 100.64.0.1, presumably the IP address at the other end of the Starlink connection.
  • 15:24:08,373 to 15:26:17,713: the router hasn’t gotten a DHCPACK reply. So it keeps sending requests every 10-20 seconds.
  • 15:26:28,982 to 15:26:56,422: still no reply. Now the router starts sending DHCPREQUEST to 255.255.255.255. I think that’s likely because the 100.74.162.37 lease expired and so the router now has no idea what address is at the other end and it’s starting over with a broadcast.
  • 15:27:10,770: the router sends a DHCPDISCOVER. I’m not certain but I think this means the router has given up on the old address entirely and is starting over as if it has never heard of the network.
  • 15:27:10,835: the router receives a DHCPOFFER from Starlink. We’re back in contact! This took 65ms, or just about one round trip on the satellite link.
  • 15:27:10,835: the router sends a DHCPREQUEST, presumably securing the address it was just offered. (Note the log has the request coming before the offer, but I think the log messages just got swapped. They have the same millisecond timestamp.)
  • 15:27:10,910: the router receives a DHCPACK from Starlink, 75ms after the request. We’re connected again!
  • 15:27:16,963: the router logs that the IP address is bound. Not sure why this takes 6 seconds to announce, but that’s all happening inside UnifiOS.

I should note that in all 6 failures I’ve had this morning (once every 5 minutes), only one DHCPDISCOVER has been needed to get the connection going again. Each time one is sent it gets immediately answered. There’s a different kind of outage I’ve seen on previous days, where the router eventually does a DHCPDISCOVER and gets back the address 192.168.100.100 with a very short 5 second lease. That’s Dishy’s internal DHCP server answering with a local only address, a mode it gets into when it loses its link to Starlink’s ground station entirely. That’s a very old behavior I’ve discussed on this blog before. This every-5-minutes outage is relatively new, a few months old.

Interpretation

My interpretation of this is Starlink’s DHCP server has forgotten we had a lease. My router keeps trying to renew the lease with DHCPREQUEST and gets no answer. Finally the router starts over wtih a DHCPDISCOVER and Starlink responds immediately. That’s consistent with the satellite link basically working but Starlink’s DHCP server failing to renew my address. But I’m guessing here.

What I do know is it’s really annoying having your connection drop every 5 minutes. The WAN failover is kind of making things worse; it takes UnifiOS about 30 seconds to decide to failover. By the time it’s done that Starlink has come back up and so the router switches back to it. Basically every 5 minutes the network is down for about 30 seconds. Any TCP sessions with activity during the failover period get reset.

But the failover isn’t causing the problem, the lack of DHCP response is the real problem.

Updates / notes

A useful command for checking the logs for Starlink-related DHCP stuff

grep dhclient 192.168.3.1.log | grep -v eth2 | fgrep -v 10.33.1.1

Just saw a bizarre failure that I think must be a Unifi OS bug.

2022-04-12T23:54:16,623 <30>Apr 12 16:54:16 ubnt dhclient: bound to 100.74.162.37 -- renewal in 117 seconds.
2022-04-12T23:55:40,224 <86>Apr 12 16:55:40 ubnt sudo:     root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/sbin/dhclient -q -cf /var/run/dhclient_eth0.conf -pf /var/run/dhclient_eth0.pid -lf /var/run/dhclient_eth0.leases -r eth0
2022-04-12T23:55:40,292 <30>Apr 12 16:55:40 ubnt dhclient: DHCPRELEASE on eth0 to 100.64.0.1 port 67
2022-04-12T23:55:44,280 <86>Apr 12 16:55:44 ubnt sudo:     root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/bin/rm -f /var/run/dhclient_eth0.pid
2022-04-12T23:55:48,006 <86>Apr 12 16:55:47 ubnt sudo:     root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/bin/sh -c /sbin/dhclient -q -nw -cf /var/run/dhclient_eth0.conf -pf /var/run/dhclient_eth0.pid  -lf /var/run/dhclient_eth0.leases eth0  2> /dev/null &
2022-04-12T23:55:48,213 <30>Apr 12 16:55:48 ubnt dhclient: DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 3
2022-04-12T23:55:48,242 <30>Apr 12 16:55:48 ubnt dhclient: DHCPREQUEST on eth0 to 255.255.255.255 port 67
2022-04-12T23:55:48,242 <30>Apr 12 16:55:48 ubnt dhclient: DHCPOFFER from 100.64.0.1
2022-04-12T23:55:55,691 <30>Apr 12 16:55:55 ubnt dhclient: DHCPREQUEST on eth0 to 255.255.255.255 port 67
2022-04-12T23:56:04,640 <30>Apr 12 16:56:04 ubnt dhclient: DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 7
2022-04-12T23:56:11,101 <30>Apr 12 16:56:11 ubnt dhclient: DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 13
2022-04-12T23:56:11,164 <30>Apr 12 16:56:11 ubnt dhclient: DHCPREQUEST on eth0 to 255.255.255.255 port 67
2022-04-12T23:56:11,164 <30>Apr 12 16:56:11 ubnt dhclient: DHCPOFFER from 100.64.0.1
2022-04-12T23:56:11,219 <30>Apr 12 16:56:11 ubnt dhclient: DHCPACK from 100.64.0.1
2022-04-12T23:56:17,169 <30>Apr 12 16:56:17 ubnt dhclient: bound to 100.74.162.37 -- renewal in 134 seconds.

This looks like the router just decided to restart dhclient. And the first thing it did was a DHCPRELEASE, breaking my connection. I have no idea why the router did this but it looks like Starlink responded quickly to the requests the router was making.

Home LAN disaster mystery

I truly b0rked my home network yesterday. It took more than an hour to fix. I still don’t understand what went wrong but I’m wondering if my ethernet switches got in a bad state.

It started when I tried swapping my Ubiquiti router out for an OpenWRT router. The new router was working OK, the whole network was fine. I installed a few packages to OpenWRT (including wireguard, unconfigured) and rebooted it and then my network was down. No DHCP, couldn’t even connect with a static IP, OK I figured OpenWRT somehow broke and so swapped back to the old Ubiquiti router.

That’s when the mystery started. Nothing worked with the old router plugged back in. Again no DHCP, static IPs not working. Lots of blinking lights on the switches though, suggesting maybe some networking was still happening. I tried power cycling the router and the switches in the path between my computer and the router. No luck.

So then I began a tedious process of getting the network working starting from the router. Unplugged everything but one laptop. Still no DHCP. But static IP worked. That’s when I learned the router’s DHCP server wasn’t running. It was before! Not sure if UnifiOS “lost” the DHCP server setting? The Unifi controller was offline but my understanding is the router should keep its last config, which should have included DHCP service. Weird. So that’s one mystery, why did my router stop doing DHCP?

Fortunately the minimal configuration UI on the router itself does let you turn DHCP on. Turning that on and I had one router working with one laptop. And soon after that, one switch plugged into the router. But the Unifi access point plugged into the switch still didn’t seem to be working; connecting via WiFi got no DHCP. Weird.

But it got weirder when I went to the second switch, the big one at the center of my LAN and plugged into the first switch near the router. Nothing plugged into it worked. The ethernet cable coming to that switch worked on the laptop, but plug that into the switch and then the laptop into the switch and boom, no working ethernet. I finally just replaced the switch entirely and suddenly everything started working. Including the Unifi access points.

Today I tested the suspect switch and it seems fine. Also the router seems fine. So that’s another mystery, why did this equipment look like it wasn’t working after rebooting a router and works fine today?

One possible explanation for all of this is that somehow my ethernet switching got in a bad state. And that state was somehow polluting the network so nothing was working. I don’t think this is a very good theory. The switches are simple unmanaged Netgear GS108s, pretty bulletproof. No persistent state at all and nearly stateless entirely. I did try power cycling the switches a few times to no effect.

There is a bit of state in ethernet switches though: the spanning tree protocol. Also some sort of memory of which ethernet devices are plugged in to which port. Could that somehow have gotten corrupted?

My network is pretty simple. There’s no physical loops in the network topology (other than that implied by wifi). I’m not using VLANs at all, although I do note OpenWRT has some default VLAN configuration that I don’t understand and didn’t alter. There’s a total of maybe 5 unmanaged switches and 60 devices.

Honestly I’m just speculating about magical explanations. I don’t really know. I do know I’m scared to try swapping routers again.

Update: I tried the OpenWRT router again and failed, although not as catastrophically. It worked fine on first setup, then I rebooted it to test it and suddenly not only did I not have Internet, but the router wasn’t answering anything at all. No idea what’s going on. One guess is installing the wireguard packages with opkg somehow caused a problem, even though I didn’t configure wireguard. It also looks like Starlink’s Dishy terminal is not immediately answering DHCP requests from the router the moment it asks, so that’s not great. That doesn’t explain why I couldn’t even talk to the router at all though.

Ubiquiti failover problems

On the back of my problems with a flaky WAN link I’ve had a different problem with my Ubiquiti router: it would fail over from the WAN link (when it was down) to my LTE backup, but then not return once the WAN link came back up. Not every time, only three or four times in several months. But that’s obviously no good.

More details are documented in this public post and this private support ticket.

Long stort sort, I got escalated to tier 3 support. I’ve made two changes at their suggestion. One was to switch the watchdog ping address from ping.ubnt.com to 1.1.1.1, mostly to skip DNS resolution in the “is the network up?” test. The other was to turn on smart queuing, which apparently might magically fix the routing problems I was seeing.

I changed the ping address Nov 21, and the smart queueing was enabled Dec 9. Meanwhile I haven’t seen my WAN link flake out once since Dec 1. No explanation for that new stability, the router was last rebooted Nov 29 or so and there was flakiness after that. But with the WAN link behaving solidly there’s no chance of the routing failover messing up.

So.. still confused as to what caused the problems I saw. I suspect they’ll come back.

Update: the came back. WAN started flaking out today, Dec 20, at 11:59am local. No hint the failover isn’t working though.

Ubiquiti Security Gateway failures

Trying to diagnose a problem with my Grass Valley network where the Internet goes down 20-120 seconds every few hours. I think this is an old problem that dates back to my old router (Ubiquiti EdgeMAX) but it may be related to the new USG or the LTE failover device I recently installed, even though it’s now disabled.

The symptom is the whole Internet goes down. My router logs this message:

WAN iface [eth0] transition to state [active] 11:33 am 2020-10-05
WAN iface [eth0] transition to state [inactive] 11:32 am 2020-10-0

I’m able to reproduce that the Internet is really down with a simple looping ping script. But that just tells me the Internet is down, not why. My question is why is the router logging that message?

Related: this webpage has excellent docs on how Ubiquiti’s failure detection and failover works.

Theories

My first theory was that my WISP is just flaky and that’s to be expected. I swear I’ve had problems like this for years. But I had a long chat with them yesterday and they assured me that’s not expected behavior. Also that my device had a clear strong signal for at least a week. But their monitoring is only good to 5 minutes, so wouldn’t catch a 30 second outage.

My second theory is that my WAN device, a Cambium ePMP 1000, is genuinely just failing. That the device loses power or for some other reason reboots. Unfortunately it’s up in a tree and I don’t have the access to read any stats or SNMP data from it, so I don’t know. But that’d surely explain why the router decided eth0 was inactive, if it lost ethernet link.

The third theory is that it’s Ubiquiti’s watchdog itself that’s failing. If you configure a WAN2 failover (say, my LTE device) they run a watchdog process that tries to ping ping.ubnt.com every 10 seconds. If that fails 3 times in a row it decides the WAN1 interface is down, sets it inactive, and fails over to WAN2.

Evidence

But would they still be running this failover algorithm even if WAN2 is disabled and not running? I fear maybe so. Logging in as root on the USG and running show load-balance watchdog I see some evidence that the failover stuff is still happening.

Group wan_failover
eth0
status: Running
pings: 2457
fails: 0
run fails: 0/3
route drops: 7
ping gateway: ping.ubnt.com - REACHABLE
last route drop : Tue Oct 6 02:53:08 2020
last route recover: Tue Oct 6 02:53:59 2020

That timestamp corresponds to my latest failure and suggests the watchdog apparatus is still running. show load-balance status also has some interesting info in it.

There’s more information in /var/log/messages on the router:

Oct 6 02:52:38 ubnt zebra[753]: interface eth0 index 2 changed .
Oct 6 02:52:38 ubnt kernel: eth0: Link down
Oct 6 02:52:39 ubnt zebra[753]: interface eth0 index 2 changed .
Oct 6 02:52:39 ubnt kernel: eth0: 100 Mbps Full duplex, port 0
Oct 6 02:53:08 ubnt wlb: wlb-wan_failover-eth0 wlb-wan_failover-eth0 reachability failed, failover
Oct 6 02:53:08 ubnt wlb: group wan_failover, interface eth0 going Inactive
Oct 6 02:53:08 ubnt wan-event: [WAN Transition] eth0 to state inactive
Oct 6 02:53:59 ubnt wlb: group wan_failover, interface eth0 going Active
Oct 6 02:53:59 ubnt wan-event: [WAN Transition] eth0 to state active

In this log, the ethernet interface goes down first, before the watchdog is involved. That’s consistent with theory #2: the connection to the WISP antenna is flaking out. Looking back in the logs that’s the same pattern for many failures. The ethernet link goes down for about 2 seconds, then comes back. Then about 30 seconds later the failover system kicks in and marks the WAN inactive. Then some period of time later (51 seconds in this instance) the failover marks the link active again.

My local ping to the WISP antenna shows a shorter outage. Clocks are both NTP synchronized, but 7 hours off because of timezones.

Ping 35446 failed Tue Oct 6 09:52:42 2020.
Ping 35447 failed Tue Oct 6 09:52:47 2020
Ping 35448 failed Tue Oct 6 09:52:52 2020
Ping 35449 failed Tue Oct 6 09:52:57 2020
Outage for 21 seconds started Tue Oct 6 09:52:36 2020

I also have a different monitor pinging ping.ubnt.com from my own Linux box

Ping 197355 failed Tue Oct 6 09:52:42 2020
Ping 197356 failed Tue Oct 6 09:53:12 2020
Ping 197357 failed Tue Oct 6 09:53:22 2020
Ping 197358 failed Tue Oct 6 09:53:27 2020
Ping 197359 failed Tue Oct 6 09:53:32 2020
Ping 197360 failed Tue Oct 6 09:53:37 2020
Ping 197361 failed Tue Oct 6 09:53:42 2020
Ping 197362 failed Tue Oct 6 09:53:52 2020
Ping 197363 failed Tue Oct 6 09:53:57 2020
Ping 197364 failed Tue Oct 6 09:54:02 2020
Outage for 90 seconds started Tue Oct 6 09:52:32 2020

Putting that all together, the timeline:

  • 02:52:38 to 02:52:39 router notices WISP ethernet is down
  • 02:52:42 to 02:52:57 (approx) can’t ping the antenna IP address
  • 02:53:08 to 02:53:59 router marks WAN interface inactive
  • 02:52:42 to 02:54:02 (approx) can’t ping an Internet host

Note that even though the ethernet is down for 1 second, the whole Internet is down for 90 seconds. But the WISP antenna is only down for about 20 seconds.

My guess is the ethernet connection to the WISP antenna, including its power, failed. Or else the WISP antenna rebooted itself. The ethernet link comes back very fast on reboot on that device, like 1 second. But it takes 20 seconds to get up and running enough it’ll respond to pings. And in this case, 90 seconds to fully recover and be online again reliably. Not all the outages are this long; most are more like 60 seconds.

Next steps

So that’s all consistent with theory #2: the connection to the WISP antenna is flaking out. I mean it’s right there in the “link down” message. I’m still confused as to how a momentary break in ethernet signal makes for a 60 second outage.

I’ve asked my ISP whether it can give me more information about what’s happening to WISP antenna device. At least, its uptime.

I’ve got a pretty marginal wiring solution for the antenna; the ethernet cable is 350+ feet long and the PoE injector is at far end from the antenna. I’ve also got a simple passive cable joiner about 50 feet from the antenna. I should split it there and put the PoE injector and maybe an ethernet switch nearer the antenna and see if that makes it more reliable.

Update

Well damn, a theory shut down. My ISP got back to me:

I logged into the antenna, and it is showing an up time of 6 days and 7 hours at the time of this email. I also looked at the signal history for the last 3 days and found no breaks or loss of the signal between the antenna and the radio tower. That antenna has a reboot time of about 1 to 2 minutes.

So much for my theory that the antenna was losing power and rebooting.

However I’m still convinced that the ethernet link between the router and the antenna is failing. I mean, the router says so in its logs! That could still be a result of the long ethernet run through a coupler, so there may be still be an advantage to putting a switch in the middle of that long run; it may never have been PoE, but data / link failure. I also wonder if it’s possible the WAN1 port on the USG itself is broken. Seems unlikely but...

I had no outages at all for nearly 36 hours, then today I’ve had 10 outages in 5 hours (mostly overnight). Really confusing.

Update 2

It’s been bugging me that the local antenna seems to go down for 21 seconds, but then the whole WAN goes down for a minute+. I think we’ve got an unfortunate coincidence of timings. The watchdog default is (I think) 3 pings in 10 seconds failing for a failure, and 3 pings in 10 seconds working for a success. With my antenna link outages 3 pings just barely fail in a row. The 4th would work but the router has already decided the link is not working. Then it waits for 3 more pings before re-activating the link. I can sort of verify this behavior; I had the antenna fail a ping once for 6 seconds (don’t know why), and the router didn’t detect that as a real outage.

So for now I’m testing changing the config to need 6 bad pings in a row to detect WAN failover. Once the LTE device is back working it’ll be a longer wait for it to come online, but it might hide these ethernet link outages or at least make them less severe.

$configure
ubnt@ubnt# set load-balance group wan_failover interface eth0 route-test count failure 6
[edit]
ubnt@ubnt# set load-balance group wan_failover interface eth0 route-test count success 3
[edit]
ubnt@ubnt# show load-balance group wan_failover
flush-on-active enable
interface eth0 {
route-test {
count {
failure 6
success 3
}
initial-delay 20
interval 10
}
}
interface tun900 {
failover-only
route-test {
initial-delay 60
interval 600
}
}
sticky {
dest-addr enable
dest-port enable
source-addr enable
}
transition-script /config/scripts/wan-event-report.sh
[edit]
ubnt@ubnt# commit
[edit]
ubnt@ubnt# save
Saving configuration to '/config/config.boot'…
Done
[edit]

These changes aren’t persistent; next time the controller reprovisions the router they’ll be wiped out. The linked docs talk about how to make them persist through that too but I’m told these only work through a USG, not a Dream Machine. Fortunately I have the USG.

Update 3

Those changes may have made things worse; outages seem to be even longer. Honestly I can’t really understand what’s happening. Since making those changes:

Outage for 60 seconds started Mon Oct 12 14:19:03 2020
Outage for 90 seconds started Tue Oct 13 16:13:22 2020
Outage for 75 seconds started Tue Oct 13 16:18:27 2020
Outage for 51 seconds started Tue Oct 13 16:29:32 2020
Outage for 75 seconds started Wed Oct 14 08:37:20 2020
Outage for 16 seconds started Wed Oct 14 08:38:35 2020
Outage for 14 seconds started Wed Oct 14 19:08:41 2020
Outage for 55 seconds started Wed Oct 14 21:09:21 2020
Outage for 121 seconds started Thu Oct 15 01:40:31 2020
Outage for 90 seconds started Thu Oct 15 18:25:41 2020
Outage for 90 seconds started Fri Oct 16 19:50:06 2020

I’ve tried setting the “success” timer from 3 consecutive pings (ie: 30 seconds) to just one. Not ideal if there’s a working failover, but in the absence of one I think this is better than waiting?

UniFi Dream Machine first thoughts

I liked the UniFi Security Gateway experience in Grass Valley so much I decided to replace my EdgeMAX with a UniFi router in San Francisco, too. I also wanted to add another WiFi access point and it’s nice to have a dedicated controller so I bought the home consumer UniFi Dream Machine, aka the UDM.

First impression: it all works out of the box! This is the first Ubiquiti device I’d be comfortable giving a random ordinary person and have them set it up. It was a bit daunting at first; there’s literally no instructions in the box, not even a single page “getting started”. That is dumb. But if you plug the device in and plug your laptop into one of the switch ports and open a browser window, it will grab you and direct you to setup (via a captive portal). The setup is very simple, too, setting up the basic home router folks need.

Too simple though; I really wanted to configure it before turning it on. No such luck. It demands an Internet connection, a remote access login(*), etc to even set up. I gave in and disconnected the old router and just lived with some downtime until I got the new one set up.

Really there wasn’t much to configure. I have my usual few tweaks: a static IP address for one host, a couple of forwarded ports. Fewer and fewer over time though and it was quite easy to get everything shifted over.

Except once again.. Ubiquiti fails to deliver local DNS. The various hacks for adding it to a USG all don’t seem to work either. I dunno, in Grass Valley the local DNS server at least started returning client names it had learned via DHCP after a few hours. I’ll give this time; I’ve seen some evidence it might be working.

More broadly the Dream Machine is lacking a bunch of features. Some of these are pretty fiddly / psecific things but a lot are fairly basic. It’s not clear if the OS can’t do it or if it’s just the UI doesn’t allow you to configure it yet. And the Dream Machine seems to lack a single config.gateway.json for advanced users to edit, the old back door way to enabling some features in UniFi routers. It’s a significant step back in flexibility. So far I’ve only run into one case where I’d want it, but...

(*) I’ve conceded to UniFi’s remote login. The selling point for me was installing the controller software on my mobile phone and being able to remotely look at my network even when not on site. Super handy. What’s weird about this UDM is it doesn’t even seem to support local login; I think it’s cached my cloud login credentials locally for when the network is down but I’m not sure. You can still log in as root too but that doesn’t even use the normal UniFi credentials, instead the login is username root and your cloud login password for the local password. Spooky.

We’ll see how the device is doing after a couple days’ use. I do like UniFi’s platform in general. Also impressed with the WiFi hardware here, a 4x4 antenna setup is nothing to sneeze at. It’s so good I may never bother setting up my old access point as a secondary in San Francisco.

Also I have an advanced project, creating a VPN tunnel between my two houses. Been wanting to do that for years, looks like Ubiquiti has a shortcut method for that. You can also set up a VPN server which would be a big help for me when travelling; I need to look into exactly what that gets you.

Unifi LTE notes

Update (Dec 2021): do not buy this product. It does not work well; there are numerous problems with the failover. And at least in my case, the cell service was terrible. Worse, Ubiquiti’s management of it is terrible. The web UI for cancelling the subscription is broken. And once my Unifi network saw the Unifi LTE once it will not let go of it. I keep finding vestiges of it in the management console (including a popup message every single page load) and cannot figure out how to remove it. (If this happens to you try the classic console. Apparently this is yet another missing feature in the new UI.) UniFi LTE is a bad product.

I finally have a home network cellular backup option; I bought a UniFi LTE. This integrates with the rest of a Ubiquiti home network via their UniFi platform to give seamless failover to an AT&T cell tower when your main ISP is down. Price is $200, $15/mo, $10/GB. Right now there’s a sale where it’s $5/mo and $5/GB until May 2021; kinda hoping they keep it that way, we’ll see.

The bad

I’ll get the bad out of the way first. The LTE device is AT&T only, with a hardcoded SIM. You cannot use any other network provider and you must buy your contract via Ubiquiti on AT&T. Their network is high quality, but if you’re using a lot of LTE data, AT&T is expensive. My intention is to only use this as failover, hopefully never more than a few GB a month, so I’m willing to accept this limit. It’s a dumb limit though. If you want more flexibility there are a variety of LTE modems sold as hotspots. Also a bunch of routers have LTE failover built in, particularly things meant for installation in trucks and RVs.

The other bad is the UniFi LTE is definitely a Ubiquiti proprietary product. It will only work if you have one of their USG or Dream Machine routers. Many routers (including those two) support a more generic WAN failover, where you have a second WAN port and load balancing or failover rules to use it. The UniFi LTE is not that. In fact you don’t plug it into your router at all, it can go anywhere on your LAN and looks like a local ethernet device. (The docs say the router “makes a tunnel” to the LTE when it needs to route that way.)

One final bad: the numbskulls at Ubiquiti failed to include a power adapter. $200 and there was no way to turn the thing on. The docs are cryptic saying “use a UniFi switch to power it”. Digging deeper and I see the UniFi LTE is an 802.3at device; most UniFi switches that supply POE are 802.3af, a lower power standard. What’s weird is the LTE device only needs 8.5W, well within the capabilities of 802.3af, and some reports are that the device works on 802.3af. I didn’t chance it. (It does have the ability to pass another 8.5W through to a second POE port, that’d require more power than 802.3af requires, but it’s optional.)

Anyway this $110 8 port switch is the cheapest thing I could find that Ubiquiti sells that provides 802.3at. I was stubborn and didn’t want to buy a switch, particularly since I’m not sure where I’m going to locate the LTE modem, so I bought a $20 Shenzen special 802.3at injector instead. It seems to work.

The good

The reason I put up with the bad is I wanted a no nonsense device with no confusion, something that would Just Work. And so far so good. I plugged it in and had it up and running within 5 minutes, including buying the contract service. The only fiddling I had to do is I was required to enable “remote management” on my USG; that’s some scary thing where your router state is accessible via the Internet with a password. I don’t love that idea but I relented.

I’m grateful for this simplicity. Doing it myself with an LTE modem would require researching a suitable modem, picking a carrier, picking a data plan for that carrier. Then getting it all working first on a laptop (for testing). And only then, plugging it in to the WAN port on my router and seeing if the failover actually worked. Probably in a way that violated the data contract I signed up for. Yuck. I’m happy I just bought my way out of all that effort.

Another bit of good; judging by the device’s shape and performance it has a pretty serious antenna in it. Ubiquiti got their start making excellent WiFi antennas and I’m hoping that extends to LTE. There’s also a coax connector for an external antenna but I think I’m unlikely to do better unless I put up a mast.

In practice

Like I said, I got it running with no stress at all. It seems to work.

There’s very little configuration on the device. About your only choice is the max data cap (3 GB / month by default) so you don’t get hit with an ugly bill if something goes wrong. I think I saw some reference to being able to set policy so some devices don’t get to use the cellular backup, probably involving a VLAN. Need to look into that.

I simulated a failure by unplugging my normal ISP (the simplest possible failure; detecting a flaky ISP is harder). The failover happened in under 15 seconds. The LTE connection was OK for this area: 14/1 Mbps and somewhat reliable and with lower latency than expected. (My experiments with a phone as hotspot are all over the place but often much worse). It switched back to the ISP when I plugged it back in, but took a minute or two. I did get email alerts about the outage but there was no obvious view on the Controller dashboard about the failover (there is one hidden status message). Anyway, it basically worked.

I’ve also had two unplanned failovers, both lasting less than a minute. I was away from the computer at the time so I didn’t notice. My ISP sometimes has hiccups where all my sessions are terminated and it’s out for a few seconds, I wonder if that triggered the failover? I don’t know that I mind exactly, but it’s something to keep an eye on.

I’ve read some complaints that networks were failing over to LTE, maybe on false pretenses, and then never recovering back to the preferred ISP. I don’t think I’ve seen that behavior yet. I did get a failure where I unplugged the LTE while I’d failed over to it. I then plugged my regular ISP back in expecting the network to go back to it. But it never did. I finally powered the router off and on and after 5 minutes (!) my network came back.

More generally I just wish the LTE failover state were much more prominent in the dashboard. Also that there be a big toggle switch I could hit manually to swap WANs.

Antenna placement

What I really want is a tool to help me better situate the LTE antenna. I can’t find one; I’ve asked here. There are some diagnostics, including enough signal strength readings that I can probably experiment with different placements but there’s no live tool guiding me which direction to point in or anything. I think their long distance WiFi link utilities do have that.

I’m astonished at that “Good signal strength” measurement; we have terrible reception here at my house. Phones get 0 or 1 bars. All I did was put the antenna in a window pointed roughly towards where I think a tower is.

What do all those numbers mean? This article was helpful. The key number there is the RSRQ or “Reference Signal Received Quality”; it’s sort of like SNR but for multi-channel connections. That -11dB qualifies for “good”. The RSRP number is also useful, it’s the raw signal strength for a single channel and -115 is not so good. Band B12 is a 700MHz frequency.

Annoyingly, I can’t find a time series graph of the history of these readings. The Performance graph shows dropped packets, etc so that may be helpful but there’s no simple graph of RSRQ.

As for where the towers are, this article has lots of useful advice. Looking on CellMapper I think I found out which cell tower I’m connected to; there’s a A3E49 on the map north of me and the cell ID (blanked above) I have is 0A3E4911. The 11 stands for the cell to the south so that makes sense too. That tower is further away from me than I’d like but is way up high on a hill. Most of the other AT&T towers are lower, along the highway, which seems dumb. I need to do further experimentation with my phone as a signal tester.

I tried various locations in my house for the antenna. Some not very reliable data:

  • Office window: 0A3E4911, B12 RSRQ -12, RSRP -112 to -115
  • Office closet: 0A3E4911, B12, RSRQ -9 to -13, RSRP -114 to -125
  • Garage pointing north: 0A3E490A, B2, RSRQ -13 to -14, RSRP -119 to -120.
  • Garage point north after use: 0A3E4911, B12, RSRQ -10

Interesting the garage location uses a different cell (same tower) and band. The B12 bands are in the 700MHz spectrum, B2 is in 1900. I think that means the B2 option could be higher bandwidth. However it only stayed connected on B2 until I tried to use it, at which point it switched over to the other cell on B12. I don’t have a clear line of sight (including a metal garage door, among other things) so I suspect 700MHz is the better choice.

Conclusion

I’m pretty happy with the UniFi LTE, particularly at the current $5/GB sale price. It worked right out of the box once I found a power adapter for it. Now I need to run it for a few months and see what happens in practice.

Configuring failover behavior

Some extra notes written after the main piece.

After 48 hours I’m annoyed that the LTE is being failed over to for 5-15 seconds at a time. It’s happened maybe 8 times. These all might be legitimate primary failures, my ISP is flaky, but then it seems disruptive to fully change the routes since that terminates all active TCP connections. I’d rather the thing not respond to failures so quickly.

There’s very little docs on failover and no config options. I did find this discussion thread which says

It tests whether it can ping out via that interface to ping.ubnt.com. So it will detect a failure upstream. It takes a little longer to failover to not be overly-touchy, it’s immediate when you lose link, 3 failed monitoring checks when link is still present (which is, at most, 40 seconds from failure to failover).

Create an upstream failure, and watch “show load-balance watchdog” via SSH to USG. After 10 seconds you should see “run fails” increment to 1/3, then later 2/3, later 3/3 and it’ll fail over at 3/3.

I wonder if that’s still true (this was late 2019). It’s a reasonable heuristic! And that show command shows “run fails: 0/3” which suggests 3 is still the threshold.

Group wan_failover
eth0
status: Running
pings: 3160
fails: 1
run fails: 0/3
route drops: 4
ping gateway: ping.ubnt.com - REACHABLE
last route drop : Sat Sep 19 22:52:34 2020
last route recover: Sat Sep 19 22:53:07 2020

tun900
status: Running
failover-only mode
pings: 120
fails: 1
run fails: 0/3
route drops: 0
ping gateway: ping.ubnt.com - REACHABLE

This gives me a way to monitor and/or simulate their own failover algorithm too, I can at least verify it’s doing what it thinks it’s doing.

I think I found the config JSON on the USG router that controls this too. Following these instructions about config files I ran mca-ctrl -t dump-cfg to inspect the config. Among other things I found this block:

"load-balance": {
  "group": {
    "wan_failover": {
      "flush-on-active": "enable",
      "interface": {
        "eth0": {
          "route-test": {
            "initial-delay": "20",
            "interval": "10"
          }
        },
        "tun900": {
          "failover-only": "''",
          "route-test": {
            "initial-delay": "60",
            "interval": "600"
          }
        }
     },
     "lb-local": "enable",
     "lb-local-metric-change": "enable",
     "sticky": {
        "dest-addr": "enable",
        "dest-port": "enable",
        "source-addr": "enable"
     },
     "transition-script": "/config/scripts/wan-event-report.sh"

Updates and failures

Last night, after a couple of days of installation, we had the failure mode I was afraid of. The network failed over to the LTE at 9:30pm and didn’t switch back. Something else happened at 2:10am and again at 2:30am but it didn’t switch back to the ISP. Usually these last just a few seconds and it switches back to my ISP. This morning we were still on the LTE even though the ISP link was fine. Had to unplug the LTE and then reboot the router to get the thing back.

The main thing I’m seeing are clusters of 4 events; I’m thinking of these as failovers in response to a temporary short ISP outage.

  1. 15:48:06 LTE to state active
  2. 15:48:06 ISP to state inactive
  3. 15:48:40 LTE to state failover
  4. 15:48:40 ISP to state active

That’s what a normal working failover looks like. Not thrilled about having so many of them, but it seems to work. Here’s what happened last night

  1. 21:33:09 ISP to state inactive
  2. 21:33:10 LTE to state active
  3. 21:33:43 LTE to state failover
  4. 21:33:43 ISP to state active
  5. 02:09:39 LTE to state active
  6. 02:09:39 ISP to state inactive
  7. 02:30:21 LTE to state failover

That’s the event report.

First thing to note is that it was the 21:33 failover that actually started the problem. Even though events 3 and 4 make it look like the ISP should be active (not the LTE), I have independent logs of IP addresses that show me my home network was on LTE since 21:33. So that’s weird. The other weird thing about the 21:33 logs is that the events are backwards from normal; ISP to inactive first, then LTE to active. I don’t know how Unifi publishes events though so I’m not sure event ordering is strictly guaranteed. I suspect it is though and that timestamp difference (:09 vs :10) is evocative.

Then there’s the 02:09 events. No idea what those are about, it looks incomplete. I wonder if the router was using LTE but the watchdog infrastructure thought it was on the ISP? Whatever the case it’s a failure.

Ubiquiti is usually more reliable than this. I’m annoyed.

USG notes, GV LAN configuration

Setting up yet another new router, a Unifi USG. I’m finally buying fully into the Unifi platform. I like the concept; one central management process that configures and monitors all your network equipment. Proprietary of course, but I’m willing to bet on Ubiquiti.

Setting up the USG is awkward since it’s the backbone of your network. These docs helped. My catch is my LAN is configured to be 192.168.3.* but the default network is 192.168.1.*. And even though the Unifi Controller could see the USG when I plugged it in (via LAN port) and send it a firmware upgrade, it wasn’t able to actually provision (configure) it. So I had to follow their instructions; plug in a laptop to the WAN port, use the minimal web config to change the subnet, then use the Controller to configure the rest. Annoyingly the Internet access on the laptop worked fine on the 192.168.1.* subnet but not 3.*; I suspect that minimal config on the USG itself doesn’t even set the DHCP router address right when switching. Anyway once I’d switched the USG’s network to 3.* the Controller was able to send the full configuration and everything works.

Yet another router configuration system with its quirks to learn. Most of the defaults seem fine. The only thing I’m missing is static DNS entries for local static IPs, something Ubiquiti has never been great at. Turning on dnsmasq didn’t help. It may not be possible at all, or require editing a config file. Update I waited a day and now /etc/hosts on the router has a bunch of entries from DHCP, which it will also serve via DNS. I do not have dnsmasq enabled. They are FQDNs only, ie hostname.nelson.monkey.org and not the naked hostname. That’s reasonable but it does mean your host doing the query needs to be configured to search that domain.

One annoying thing in the USG: it does not have a switch. It has 3 ports: LAN1, WAN1, and then LAN2/WAN2. That last port can not be switched or bridged to LAN1, it is treated as a third network with its own subnet and routing. You could probably kludge it so it works like LAN1 but the router will be doing extra work. (Hilariously there’s a 4th RJ45 on the thing labelled “console”. It is literally a serial port.)

Another annoying thing in the USG: it’s slow. Not routing, that’s fast. But it takes 45+ seconds for the thing to boot. And re-provisioning takes a long time, although at least it’s conveniently orchestrated.

LAN Configuration

Figured it was time to document my LAN configuration for the next time I have to do this. Not that stuff doesn’t change.

  • 192.168.3.1/24
  • domain name: nelson.monkey.org
  • WAN configured via DHCP, NAT mode
  • Static LAN DHCP entries
    Printer 84:25:19:0e:7b:0b 192.168.3.67
    Axiscam ac:cc:8e:20:47:8f 192.168.3.53
    gvl 94:c6:91:1e:c8:38 192.168.3.75
  • Static DNS entries for gvl and axiscam
  • SNMP enable community string “public” (for Munin on gvl)
  • Port forwarding: none
  • DDNS: none
  • UPnP disabled

The network is pretty closed off; the only way in from outside is via an autossh tunnel I have set up somewhere on a cloud server.

I would like to add a VPN configuration between my two houses though. Every time I’ve looked into that it was complicated, particularly getting it working while only in one place at the time.

Unifi Network Controller on Ubuntu 20

Ubiquiti’s Network Controller comes in an apt installable version for Ubuntu. For the most part their instructions just work. The one wrinkle I ran into with my Ubuntu 20 system is that the service wouldn’t start with systemctl having an error “Cannot locate Java Home”.

The solution for this was to manually install an older Java.
apt install openjdk-8-jre-headless
Their controller seems to require Java 8. The apt page has some confusing instructions about preventing Java 11 from being installed with apt-mark, but at this point we’ve moved on to openjdk-14 in Ubuntu land. Anyway Ubuntu lets you have multiple JREs installed with no drama.

The network controller is running as an HTTP interface on port 8080. Terrible choice of port (this is changeable). Once you do initial setup though it seems to start redirecting you to port 8443 instead.

I needed to migrate the devices from the previous network controller I’d installed. This all seems to be anticipated in the UniFi system, there’s instructions here on “adopting” the device on the new controller. I had to stop the old controller from running for the new controller to see the devices before adoption.

I also set it up to email me alerts for important things on the network. That requires an SMTP server. I grudgingly gave it a Gmail password, but only after creating a specific app password at Google only for this device.

Why am I doing all this? I’m upgrading some parts of my home network (finally installing a cellular backup for the ISP) and am finally fully embracing UniFi, Ubiquiti’s current platform for their networking equipment. I have UniFi access points and ran their controller software once, grudgingly, to install them. But I still have an old EdgeMAX router that predates UniFi. Or rather will for one more day.

The UniFi Network Controller has turned into a pretty good piece of software, btw. I was impressed when it helped me diagnose a WiFi performance problem I had with an old 802.11n device.

Backup cell ISP notes

My Internet in Grass Valley is flaky enough that I’m looking at getting a permanent mobile service as a whole-house backup. Right now I just use my phone as a hotspot and switch my computer to it when necessary. That works OK but it only gets my own computer, I’m curious about switching the whole house. (Also dreading it; what if one of the devices decides to download a 10 GB update while on mobile?)

Ethernet / router options

The Ubiquiti EdgeMAX EdgeOS router I uses supports having a second WLAN connection as either load balancing or pure failover. Obviously I’d want failover. The trick is that you need to plug the mobile device into an ethernet port on the router. So the usual wireless hotspot doesn’t work.

The one device that looks exactly right is the Netgear 4G LTE Modem. $110 for a SIM card in, ethernet out. Perfect! See review here. Except it explicitly says it does not support Verizon, my carrier of choice. Some of the user comments suggest it does work on Verizon but my guess is only the LTE works and if you have to fall back to 3G it can’t do CDMA. Not ideal. I could use it with AT&T. Also it does not support LTE Advanced.

This review site’s roundup of ethernet-out devices is discouraging. Only Netgear makes the simple ethernet-out product. There’s a couple of things that are also wireless hotspots or routers that have an ethernet port, maybe they could be adopted. Or something really expensive like this new 5G hotspot. One final option would be to get a USB device and use a Raspberry Pi to output ethernet, assuming it’s possible.

Another option that looks slick is the Ubiquiti Redundant WAN over LTE. $200 for some solid-looking LTE hardware that plugs into your ethernet. Also has a setup with AT&T for service already, $15/mo plus $10/GB. The only point of confusion for me is how the failover happens. The device says it’s for UniFi networks, so I imagine it does some Ubiquiti-proprietary coordination with the router (UniFi Security Gateway) to act as a failover. If so then it probably won’t work with my old EdgeOS device.

Back to hotspots

So maybe using a hotspot is the right idea and I should just get a dedicated hotspot device and service. It’s manual failover and won’t cover my whole house, but there’s lots of product choices. The Inseego MiFi 8800L Jetpack (aka Verizon Jetpack) looks terrific. It even supports LTE Advanced! It doesn’t support Verizon 3G which is weird for a product Verizon is explicitly selling. Maybe that’s OK though, 3G is on the way out in the US.

OTOH just using my phone works well enough for the few times I need to do this. Never been sure I really needed a dedicated device. I’m using a Pixel 3 and it supports LTE Advanced.

Mobile data providers

If I get a dedicated device I need a data contract and SIM for it.

I can add a second line to my Verizon account. $10/mo and then $10/GB. I’m unclear but I think this will share my phone’s data balance? I always have way more data than I need, so that seems like a good choice.

I took a quick look at AT&T prepaid MVNOs, as something I could use with that Netgear modem. The best I could find in the US was Red Pocket Mobile. $10/mo for 1GB, and then $10/GB for topups. Or $25/mo for 5GB if you know you’re going to use it a lot. I did not look at getting a proper monthly account with AT&T, or adding a line to existing AT&T service. I suspect the pricing is the same as Verizon.

Conclusion

Three options

  1. Stick with using phone as my backup. A hassle, and manual, but it’s paid for already.
  2. Get a Jetpack mobile hotspot and switch to it manually. More convenient, but still a hassle. Small extra monthly fee.
  3. Get the Netgear LTE Modem and an AT&T MVNO. Give me proper failover, although there’s the risk we then blow through the data thanks to some ignorant device. Have to buy a new contract, so can’t use existing data on the Verizon account.

Option 1 sure is the least demanding up-front.

802.11 bad signal diagnostics (Ubiquiti)

Ken’s computer was having a bad time connecting to our wifi network via 802.11n. I finally figured out it was mostly a problem with signal strength in his room, a second computer displayed the same symptoms with that same 802.11n adapter. We solved the problem by upgrading him to a 802.11ac adapter. Along the way I learned some things about WiFi signal reliability. Usual caveats applied: I’m just learning this stuff myself and am an amateur

802.11 link layer reliability

WiFi’s link layer has its own set of complex reliability stuff built in, sort of analogous to TCP but solving a different problem. That makes WiFi quite different from ethernet, which AFAIK doesn’t have any link layer stuff for handling a lost packet other than the basic collision detection logic (nearly irrelevant in modern switched networks). There’s also some rate negotiation in modern ethernet; if 1000Base-T isn’t working reliably it’ll step down to 100Base-T. But that’s about it. I think ethernet makes the assumption its link layer is basically reliable and figures it’s the upper layers’ problem (ie TCP) to deal with lost packets.

WiFi is an inherently flaky medium though. It’s expected that not all packets will get through the radio æther unmolested by gremlins. So the 802.11 link layer has a couple of mechanisms built into it for reliability.

One tool is forward error correction. The codewords broadcast on 802.11 aren’t just the bits; they’re error correcting codes capable of fixing single bit errors at varying rates. I believe in practice wifi sends anywhere from 2 bits for every 1 bit of user data to 6 bits for every 5.

A second tool is link layer retries, something a little like TCP’s retry and ACK protocol. This is called “ARQ (Automatic Repeat Request)” in what I’ve read, and basically amounts to tracking sequence numbers and resending packets when not acknowledged. I don’t know how many retries are attempted or whether retries stall the link, this article has details that suggest it’s 4 or 7 retries. But note all this retry is happening on one local wireless link, in under a millisecond. Very different from TCP’s waiting a full round trip for a retransmit.

A final important tool is speed negotiation. Much like TCP uses lost packets and ACK clocking to figure out the maximum speed, WiFi gear monitors error rates and if it sees too many, steps down to a less aggressive data rate. There’s a bunch of choices here summed up by “MCS index”; you might up the error coding from 3 in 4 to 1 in 2, or use 16-QAM instead of 64-QAM, or whatever. I don’t know much about how this works in WiFi but I imagine it’s quite subtle and different from TCP’s algorithms. This paper (I haven’t read) has a description of some of them in practice.

I enjoyed reading this paper about 802.11 reliability. A couple of tidbits I picked up.. Up to half the theoretical bandwidth on an 802.11 connection is consumed by reliability mechanisms, particularly ACKs. Also there’s a paradox that faster links seem to be more reliable. There’s a lot of potential reasons for that, from the tautology that the link is faster because it is more reliable to odd things like faster data transmits mean less time spent flying through the æther and exposed to gremlins.

So that’s the theory. WiFi is designed with a lot of tools to deal with inherently unreliable radio communication. Error correction, retries, rate negotiation, it’s doing a lot.

802.11 diagnostic tools

Despite all that magic Ken was seeing speeds of like 500 kbps on his wireless link, truly awful. The most useful tool I found for measuring this on Ken’s client was simply DSL Reports speed test. That’s testing throughput all the way to an Internet site so is not really a very good test of a local wifi link. But I verified once or twice he was seeing the same slow speed internally, and he was getting a link much slower than our Internet connection. The nice thing about the consumer speed test tool is it shows you momentary bandwidth so you can get a feel for jitter, packet loss, etc. There are many better specialist tools for testing link throughput on your local WLAN; I took the one easiest to put my hands on.

On the server side, I have a fancy UniFi network with a complex bunch of network control software I never use. Turns out it has useful reports though! See Identifying Wi-Fi Issues with Debugging Metrics.

Well that’s your problem right there. According to my UniFi access point, Ken’s computer is receiving at a rate of 1 Mbps. That’d explain the 528 Kbps throughput. Yuck! I never could figure out why it was that low though. Or why it never seemed to increase again, the adapter went to lowest common denominator and got stuck there.

Another useful set of graphs buried in UniFi’s tool are time series charts of the AP’s performance. Graphs like this:

Note that’s a graph from when things are mostly going OK, I don’t have a picture of the problem. But at the time it was not working well the 2Ghz band was showing 80% channel utilization; all for Ken’s crappy 1 Mbps stream. And also lots of dropped and retried packets. Bad news.

I did very the same 802.11n adapter on a second computer also sucked in the same room; so it seemed to be the adapter, not the computer. But 802.11ac was fine. So the solution was simple, spend $25 on a decent wifi adapter and be done with it.

Monitoring EdgeOS bandwidth with Munin

Ubquiti’s routers are reliable and flexible, but they lack a certain.. consumer polish. One thing missing from the graph is any sort of historical bandwidth tracking or graphs. There’s no way to see what bandwidth you used in the last 5 minutes, much less the last year.

But EdgeOS does support SNMP. So you can collect the SNMP data on a Munin node running on another computer and graph it.

Step 1: turn on SNMP following something like these instructions. I did this via the router GUI instead using the Config Tree wizard. The two settings that are important are

snmp {
     community public {
         authorization ro
     }
     listen-address 192.168.0.1 {
         port 161
     }
}

Note there’s no real security in this kind of SNMP, anyone with access to that listen-address will be able to read a bunch of state off your router.

I was able to test SNMP was working with snmpwalk but I forget exactly what command worked. SNMP is a mystery to me.

Step 2: configure your Munin node to read the SNMP data. I used this guide. It basically has you use munin-node-configure to detect what SNMP data is available and then symlink a bunch of plugins. Then you add a “virtual node” for the router to your munin.conf.

The resulting config is overkill; I’m not sure I need to measure my router’s disk usage, thank you. Also there’s like 8 graphs for the network and I haven’t quite figured out which opaquely numbered interface is the WAN I care about monitoring. I figure after a day’s data is collected it’ll be clear what’s useful to keep.

Update: here’s what I kept

snmp_192.168.0.1_cpuload
snmp_192.168.0.1_if_2
snmp_192.168.0.1_load
snmp_192.168.0.1_netstat
snmp_192.168.0.1_uptime

The graph shows a big upload I did out of my network maxing out at ~10Mbps. Incoming bandwidth maxes out at 250Mbps so if I ever saturate that the scale on this graph is going to go to hell.

Fixing bufferbloat in Ubiquiti EdgeOS

This Hacker News discussion got me diving in to enable smart queuing in my Ubiquiti EdgeMAX routers, the ones running EdgeOS. There’s a quick-and-dirty explanation of how to set it up in these release notes, search for “smart queue”.

Long story short, under the QOS tab I created a new policy for eth0 and set bandwidth numbers a little higher than the 100/5Mbps my ISP says it sells me. Then tested with DSLReports speed test

  • No smart queue: I get about 105/5.5 with an F for bufferbloat. 300ms+
  • Smart queue at 100/5: I get 90/4.5 with an A+ for bufferbloat.
  • Smart queue at 110/6: I get about 100/5.3 with an A for bufferbloat.

Update: several folks have pointed out to me that smart queuing causes problems if you have a gigabit Internet connection. The CPU in a Ubiquiti router can only shape 80-400MBps of traffic depending on how new/expensive a router you bought. If you enable smart queueing on a gigabit Internet connection you will probably lose a lot of bandwidth.

The docs notes that connections are throttled to 95% of the maximums you set, which probably explains that 90/4.5 reading. I think the harm in lying a little here is I might get a few ms of lag from buffers.

The Hacker News discussion has a bunch of other stuff in it too. Apparently “Cake” is the new hotness in traffic shaping and is possible to add to EdgeOS, but awkward. Also it’s apparently hard to buy a consumer router that can really do Gigabit speeds, particularly if you want traffic shaping. Huh.

Every single time I’ve enabled QoS I end up regretting it as it breaks something I don’t figure out until months later. I wonder what it will be this time? I hate I have to statically configure the bandwidth throttles.

 

Screenshot_1.png

Ubiquiti EdgeMAX / EdgeOS local DNS

Ubiquiti makes nice routers with good firmware. But one missing feature; it doesn’t generate local hostnames in DNS for clients on DHCP. Ie, my Linux server registers itself with the name “gvl”. But I can’t then “ssh gvl” on my network because gvl isn’t a valid DNS name, not even in the Ubiquiti.

The right solution for this is to enable dnsmasq to be your DHCP server. dnsmasq is already running as a DNS server in the router; all this does is let it also be the DHCP server. As a side effect you now have nice DNS service. The downside here is it requires some slight tomfoolery to enable and then you end up with a less-than-standard router. See the discussion here.

Another possible solution is to enable the “hostfile-update” option. This tells the stock DHCP server to write entries in /etc/hosts. There’s some possible bugs with this.

The hacky solution for this is to leave DHCP alone and just create a static IP address and DNS name for your host. I’m too lazy to post screenshots, but basically...

  1. Boot your DHCP client that you want to give a DNS name to. Let it take an automatic address.
  2. In the web GUI for the router, go to Services / DHCP Server. Click the little “Actions” dropdown button and select “View Leases”.
  3. Find your DHCP client and click “Map Static IP”. This computer (well, MAC address) will now get a static IP every time it boots.
  4. Go to Config Tree. Open system / static-host-mapping / host-name.
  5. Click “Add”. Type a hostname. Click update list.
  6. In the config tree look under host-name for your new name. Click it, then under “inet” add a field which is the IP address you set up in step 3.
  7. Click “Preview” to verify the config is right. It should be something like this. If it looks right, Apply it.
    set system static-host-mapping host-name gvl inet 192.168.3.75
  8. Test DNS on another system. dig @192.168.0.1 gvl any

Steps 4-8 can also be done via the command line configurator, which is probably less clumsy than the config-tree GUI.

Now that I’ve typed all this out I think perhaps switching to dnsmasq for DHCP is the better solution. But this works as a one-off.

Ubiquiti EdgeMAX EdgeOS router notes

I’m setting up a new Ubiquiti router, an EdgeRouter X SFP using firmware v1.9.7+hotfix.4. Some notes on doing this:

Out of the box the router only works on ethernet port 0 (eth0). It does not run DHCP. You have to manually configure a computer to talk to it on 192.168.1.1.

The router will redirect you to HTTPS when you connect. However they of course don’t have an SSL certificate for 192.168.1.1 so your browser will refuse to connect. You can override this in Chrome and Firefox by looking for “Advanced” mode on the error screen.

The first thing to do with a new Ubiquiti router is upgrade the firmware. The stock firmware is old and missing important features. (My memory is upgrading UniFi access points is also necessary, the shipping version had a crippling bug.)

Once you flash it the first thing to do is run the “Basic Setup” Wizard. (Note, this is not available in the shipping firmware.) This will set the router up to do What You Expect from a consumer router; NAT routing for eth0 (the WAN port) and DHCP for the rest. For a simple home network that is probably all you need to do.

1.9.7 and other versions have a bug where if you manually configure some static IP addresses along with DHCP, then dhcpd won’t start when you reboot the router. The fix for this is to remove all static entries. I was able to add one static entry later via the DHCP control panel and rebooting still works. Not sure if I can manually add an entry or not. This is all probably a bug in vyatta, their GUI config system.

DNS is not enabled for DHCP entries or static hosts. That’s a thing the dnsmasq used by many routers does for you. I can’t figure out how hard this would be to enable. The obvious wizard reportedly only adds your entries to /etc/hosts on the router itself which is not propagated by its DNS server. I didn’t try very hard.

UPnP is not enabled by default. You can add it via a feature wizard; internal is “switch0” and external is “eth0” (or whatever your WAN port is).

For my own notes, a network setup idiosyncratic to me, I added a static interface route to 192.168.1.0/24 going out eth0. Hoping to reach my invisible wireless ethernet bridge boxes on 192.168.1.110 and .111. No luck, but I think that may be because they’re configured to think the network is 192.168.0.0/23 and so can’t talk to my 192.168.3.* addresses. Oops.

 

RF scan in San Francisco

My fancy Ubiquiti access point has an RF scan tool. Here’s what it found in my house in San Francisco, Noe Valley.

Capture.PNG

Capture2.PNG

 

Not a great visualization; the yellow bar fills up the trapezoid. Mouseover tells me the 2.4GHz channels are about 20-30% “utilized” with “interference” of -95 dBm (noise floor?). 5.0GHz channels are mostly 0% utilized except for 112 and 136, which are about 20%. Interference there is -91 dBm for most, -96 for a couple.

My iPhone sitting nearby can see about 4 neighbor’s WiFi networks. Also probably a lot of 2.4GHz cordless phones, including mine. In practice 2.4GHz barely works through the house and 5.0GHz is terribly unreliable, probably because the walls are lath and plaster faraday cages.

 

Ubiquiti cranky customer

Very happy with my Ubiquiti network hardware. Unimpressed with the software experience. Just sent this cranky email to their support, where I’m sure I will get a canned “thanks for the note” reply and nothing will improve.

Your products have three problems that harm the perception of security. Y’all make excellent network hardware, but your software should be as excellent. I’ve already worked around these problems, just registering a complaint.

The Unifi Controller Mac application is not signed. MacOS refuses to launch it until I disable Gatekeeper security.

The Unifi Controller does not come with a valid SSL certificate. I realize this is complicated, but it’s a bad experience to require users to disable Chrome SSL checks to use the product.

Your reset password links from ZenDesk are being flagged as spam by Gmail. They say “Why is this message in Spam? It has a from address in ubnt.com but has failed ubnt.com’s required tests for authentication. Learn more”.

Thanks for listening,
Nelson

Ubiquiti Unifi access points

Boy, bad first impression of a product. I got a Ubiquiti wireless access point. Figured I could set it up in 10 minutes and go; what could be easier? Lol, joke’s on me. They now require a 200 megabyte “Unifi Controller” running on some machine on your network to configure the devices; no more simple web interface. Instead the controller talks some magic protocol to the devices and then runs its own web server on port 8843 with a fancy web UI. Did I mention the Mac binary is not signed, so it won’t even run without working around Mac’s security system? And the SSL certificate doesn’t work? Awesome.

The software itself seems useful but complex. The manual is 154 pages. It provides group management of all Ubiquiti devices on my network. This seems like it would be great if I had a complicated network with a bunch of Ubiquiti devices. Maybe that’s their market. I just have one device, though, and it better play nice with the rest of my network. Fortunately this is just an AP, and stumbling through I got it working without much effort.

I think it was as simple as going through the basic config of the controller software (username, password, wifi settings), then choosing the Devices tab and clicking “adopt” on the access point.

Sitting 6 feet from the AP I’m getting a full 100Mbps according to DSLReports’ speed test. (Link layer claims 216Mbps). Putting the AP where my old one was gives more like 20Mbps, but I think it’s still better WiFi than the Asus RT-AC66U that I use. But the whole point of this is I want a second AP for upstairs, so I’ll end up running both.

Not a fan of the Power-over-Ethernet brick they provide. I’m confused about POE, there seems to be multiple standards for voltages and which pins are hot. I have no idea if it’s feasible for me to run POE for my whole house, particularly since this punchdown board everything goes through is some Levitron piece of crap that can’t even reliably do gigabit.

Networking complication

I’m in over my head with this wireless ethernet bridge thing. Story isn’t complete, but collecting my notes. There are further writeups of this question in forum posts I’ve made: on OpenWRT forums and on Ubiquiti forums.

The real problem is I don’t understand Linux networking any more. Ethernet address aliases are new to me, and I’m confusing routing and bridging, and my knowledge feels too outdated to diagnose this properly. Honestly if it hadn’t all Just Worked on my old Tomato box I’d never have believed this was possible.

I have three subnets:

  1. My home LAN, managed by my OpenWRT box, running 192.168.0.1/24.
  2. My ISP’s network, managed by their gear, running at 10.33.1.1/24.
  3. My management IP addresses for the Ubiquiti wireless bridge, mostly invisible, but running at 192.168.1.110/24 and 192.168.1.111/24.

The challenge is getting my OpenWRT router to be able to talk to the boxes at 192.168.1.*. With Tomato I just added a static route and all was done. I tried that with OpenWRT and no luck.

A lightbulb went off thanks to an answer on the Ubiquiti forums. The WAN port on my OpenWRT boxes now has two addresses: 10.33.1.50/24, assigned by the ISP via DHCP. And also 192.168.1.1/24, assigned manually by me to talk to the Ubiquiti gear. I managed to make that actually work by manually running “ip addr add 192.168.1.1/24 dev eth0”. And now I can talk to the Ubiquiti boxes!

BTW, this whole “ip addr” thing is new to me. In my day we used ifconfig and every interface had one address, thankyouverymuch. Kids these days with their multihoming and aliases and VLAN tagging and stuff. Just don’t understand it.

Update: I added this IP address alias permanently to the routers config by following these docs, which led me to add this block at the end of /etc/config/network

config interface 'ubiqnet'
    option 'ifname' 'eth0'
    option 'proto' 'static'
    option 'ipaddr' '192.168.1.1'
    option 'netmask' '255.255.255.0'

Those same docs have a worrying warning “On openwrt 12.09, a lan interface that is first defined as dhcp interface and then has aliases with static ip address could cause problems in routing the lan traffic through the wan zone”. I think that’s exactly what I’m doing but I’m running 15.05; maybe it’s no longer a problem?

Ubiquiti: less LoL lag

One nice change from with the new network, less lag playing League of Legends.

With my old hacky setup with triple nat and routers acting as a bridge, I had a lag pattern like thishacky lag

Now with the Ubiquiti gear I have a lag pattern like this:

Lag after

Note the lack of spikes! I have no idea what those were, something was getting buffered or something weird before.

I don’t think median latency or packet loss really changed, but I’m glad not to see those ping spikes. Although TBH they didn’t affect my gameplay much.

Ubiquiti success, sort of

Running a wire at my house isn’t working out, so I’m stuck needing a wireless link to get the 200′ outdoors to the base of a tree. Fortunately there’s power there! Today I replaced the hacky leftover router wireless link with a more permanent setup involving Ubiquiti hardware. So far so good, some things to improve.

The Ubiquiti equipment is interesting. In a lot of ways it’s just like a WiFi router with flexible firmware like DD-WRT on it. It has a wifi network interface and a wired network interface and various routing and bridging capabilities. But it’s more prosumer. Ubiqiuti has pretty solid firmware (airOS) and I’m impressed with details like the web-based discovery tool and the way it reconfigures itself quickly without rebooting. Also the wireless implementation seems much more solid than consumer gear. And the hardware is designed for outdoor use with directional antennas, and supports distances of 5 miles out of the box. Pretty impressive.

One massive caveat: the wireless link startup time is slow. Like 30+ seconds, maybe 5 minutes the first time. It appears to be scanning the spectrum for the right channel to use. Not sure why that takes so long, or why you can’t just rely on normal 802.11 frequency hopping for the 5GHz links.

I set up a Nano M5 and a Nano Loco M5 paired together as a transparent ethernet bridge. That configuration means those devices are invisible to the rest of my network. My router sits at the other end and gets DHCP from my ISP’s equipment. The wireless network SSID for the nanos isn’t even visible (and anyway it’s not standard 802.11). I think this is the right configuration for my purposes.

The configuration is like this:

  • A WISP POP a mile away with IP 173.195.173.1
  •    ... via a wireless link to ...
  • ISP hardware in my tree, acts as a DHCP server and NAT router.
    The WAN side is at 173.195.173.xxx
    The LAN side is at 10.33.1.1 and provides DHCP and NAT to my house
  •   ... via an ethernet cable to ...
  • Nano M5 in Access Point mode. WDS is enabled for bridging. This device has an IP address of 192.168.0.111 but that’s mostly invisible.
  •   ... via a 5GHz airMax link to ...
  • Nano Local M5 in Station mode. WDS is enabled for bridging. This device has an IP address if 192.168.0.110 but that’s mostly invisible
  •    ... via an ethernet cable to ...
  • My home router, an ASUS RT-N16 running as full AP + Router.
    The WAN side gets its IP address via DHCP from the ISP (via the Nanos). It happens to be 10.33.1.23 at the moment.
    The LAN side is 192.168.0.1 with subnet 255.255.255.0. Also provides DHCP and all the other home network services you’d expect
  •    ... via an ethernet cable or 2.4GHz 802.11 link to ...
  • Desktop computers, mobile devices, etc in 192.168.0.*

The good news is I’m not doing triple-NAT anymore. My router is doing all the real NAT work for my house. The ISP’s hardware is also NAT but I’ve taken pains to only have the one device connecting to it.

The main problem with this configuration is from my house network I can’t access the Nano status pages at 192.168.0.110/111. My router and the rest of my house’s devices think all of 192.168.0.* is on the LAN interface so won’t send packets out the WAN interface where they are. I could hack around this with static routes but that’s dumb. I should reconfigure the Nanos to a different subnet like 192.168.25.*. Then I add a single static route for that subnet in my router and I think I’m done. (I could set them to 10.33.1.* but that’s a bit funky, I definitely don’t want to risk those devices being visible to the wider Internet.)

The other small problem I have is the secondary PoE port on the Nano M5 isn’t working. In theory this should provide power to the ISP equipment in the tree. Power passthrough isn’t enabled by default but I fixed that, still not working. More tinkering required, for now I just use a second PoE injector.

This Ubiquiti firmware is pretty powerful and I feel like there’s some simpler configuration where I get rid of my house router entirely, use one of the two Nanos to be the router too. I’m not sure that really simplifies anything though, I’d probably still want the third box acting as an access point inside the house.

Update

I renumbered the Ubiquiti bridge devices to 192.168.1.110 / 192.168.1.111 and added a static route for them in my router. Works great. Next project; some sort of monitoring for them. They have SNMP and I find references to Munin plugins.

I also figured out the secondary PoE problem. I thought maybe it was total power; the Ubiquiti device wants 8W, the Cambium radio in the tree wants as much as 7W. So 15W total and the PoE injector only puts out 12W. But then I read more closely and discovered that the Cambium PoE implementation is reversed from the usual passive setup. Cambium puts positive voltage on pins 7 & 8, not 4 & 5 like everyone else. How stupid! Really dangerous, I’m lucky the magic smoke stayed inside the Cambium gear when I plugged it in. Maybe they engineered in some safety to overcome the perversity of using reverse polarity from what is common. (I hesitate to say standard, because there is no standard for passive PoE, although the 802.3af standard has a mode B that looks an awful lot like the passive PoE everyone but Cambium does.)

I’ve also discovered the radio in my house works in a closet, behind a relatively thick wall. Signal strength is degraded; airMAX quality is 78% compared to 95% with a clear view through the window, and max speed is about 200Mbps instead of 300Mbps. Still well above what I need for the 12Mbps Internet link though. Going to test it out, would be nice to not have to mount that thing outdoors or in the window.

Outdoor wiring

(Some very boring notes so someone else can wire this up)

Conceptually, we’re connecting a wire from the antenna in the tree to the Ubiquiti NSM5, one long straight wire. But it’s complicated because we need separate PoE injectors to provide power to both devices.

The black wire from the tree goes to the Phihong PoE module. It goes to the port on the left, labelled “Data + Power”. Very important to use the right module; the Cambium tree antenna uses non-standard PoE and this Phihong PoE module is special. The word “PHIHONG” is in the upper left of the label, beneath a spiral P logo. It’s the longer module, that does not say “Ubiquiti” in the upper right. The top one in this photo.

An ordinary short ethernet patch cable goes from the “Data” port on the right side of the Phihong PoE module to the “LAN” port on the right side of the Ubiquiti PoE module. This cable is currently a 3′ coil of white wire (would be nice to replace with a 1′ cable). This cable is not powered, not PoE, it just carries data between the devices.

Another ordinary ethernet cable goes from the “PoE” port on the left side of the Ubiquiti module to the Ubiquiti NSM5 antenna. It goes to the port on the right labelled “Main”. The port labelled “Secondary” is not used.

Finally, plug both PoE modules into AC power. There’s an LED on the back of the Ubiquiti radio to confirm it’s powered, but it’s pretty hard to see in bright sunlight. Once the devices have power they both take about ~60 seconds to establish wireless links.

Fixed wireless Internet: Cambium, Ubiquiti

I don’t believe in wireless communications. Too spooky. Also too unreliable, and slow. And 2.4GHz wifi is particularly bad in San Francisco, between the crowding, the lack of distinct channels in 802.11a/b/g, and the faraday cages surrounding all our lathe-and-plaster rooms.

But in Grass Valley wireless is the only option. AT&T and Comcast refuse to provide wired service to rural homes and PUC and the FCC are not regulating their monopolies effectively. My ISP is SmarterBroadband, a wireless ISP that works by establishing fixed wireless links from house to house to regional distribution point to central office and then down to fast fiber backhaul. It works surprisingly well and reliably, the main limiting factor has been speeds and the challenges of getting clear line-of-sight in a hilly area covered with trees.

My link for the last couple of years has been a 900 MHz link through oak trees to a house 1.4 miles north of me. The key thing about 900 MHz is it works OK through tree cover, something higher frequencies has a harder time with. Cambium Networks hardware running Canopy, which I think dates back to the old Motorola Canopy days. It’s been pretty reliable; the only time my point to point link has failed has been in heavy snow, and then only because snow accumulated on the antenna. Also low latency (20ms?) and low jitter. The problem has been speed. The max link speed is 2600kbits/s, and the product they sell me only bursts that fast before throttling me down to 1000kbit/s. That’s 300 megabytes / hour, and it sucks.

Yesterday they upgraded me. Sent a guy 70 feet up a tree with a Cambium ePMP 1000, a 5Ghz antenna. Pointed at the same house but that far up we’re above the trees, clear line of sight. I’m told the link is good to 25 Mbit/s but I’m being sold 12/2 Mbps. Which is still pretty great and I’m grateful for the upgrade. I’m surprised how cheap the antennas are. They offered me an upgrade for a very low cost, and it looks like you can buy your own antenna for about $140. Of course you need the service!

In addition to 900MHz and 5GHz my ISP sells two other types of wireless links. There’s a 2.4GHz product they mostly don’t sell any more. It also requires clear line of sight, but is slower than 5GHz. And they have a new 3.4GHz product they label “4G”, I think because it’s based on cellular technology. It’s pretty fast too (their product offers 70% the bandwidth of 5GHz) and is able to handle a little multipath, so works with a small amount of tree cover. Didn’t work at my house though, and once we were committed to going up a tree we might as well use the 5GHz gear.

The other half of the problem I have now is getting the Internet connection from the tree 200′ from my house inside. I’m intending to run cable, but that may get complicated depending on the status of existing conduits and the challenge of trenching. Right now I have a shitty old Linksys WRT54GL sitting outside and it works surprisingly well. That’s making me think I should try a wireless link instead, even though I don’t believe in wireless.

I asked on Metafilter and got a clear consensus answer on the product I need: a Ubiquiti Nanostation M. These are consumer grade point to point wireless links. There’s a variety of frequencies and antenna sizes. They’re rated for 5+ miles so are way overkill for my 200 ft needs. But then I can probably use the tiny 9″ x 3″ antennas and be done with it. It looks like I can get a pair for about $150. Need mounting hardware and a bit of wiring work at both ends to install it right, but still that’s got to be cheaper than digging a trench.

The big question is how reliable this kind of link is. Reports are promising! I’m also curious to know what’s going on at a protocol level. They call their protocol “airMAX” which is apparently not 802.11, it’s some TDMA thing. OK, I’m fine with proprietary. But then does the link work as an ethernet bridge? Or is it working at an IP level and messing with my packets? More to learn.

Wireless; maybe not as scary as I have believed! Still nothing beats a clean run of Cat5e. Except a pickup truck full of hard drives, of course.

Update: Ubiquiti answered a tweet I made asking for advice, with a suggestion to use the Nanostation locoM5 and a suggested wireless bridge configuration. That sure makes it easy!