I am very fortunate to be able to work from home in my new job, but the extra impact of doing so has caused me to exceed my monthly data cap with our ISP. Surprised, I wanted metrics to try and figure out how in the world we exceeded 1.2TB and from which devices. That meant I needed a metric aggregator at a single point, where all of the traffic can pass through it, including IoT devices.
Because many IoT devices do not always have overridable parameters (such as trying to proxy the traffic to a different server), the router needed to be the aggregator. I did a little research and discovered my router supported an open-source firmware by the name of OpenWRT. This essentially turns your router into a linux machine that is capable of installing other packages.
You cn find more information, including firmware downloads, from their website here.
The web interface took some getting used to as there is quite a lot of information to be found here. My router has a 512MB RAM and 256MB flash storage. I also attached a 1TB old hard drive I had laying around to the USB 3.0 port just so I don’t wear out the flash storage if I decide to add extra stuff to it. It’s configured as extra swap as well, just in case the memory comes close to maxing.
The other neat thing is it provides ssh access for further configuration:
I installed a couple things on here as extra such as block-mount, luci-app-sqm, luci-app-upnp, bandwidthd-pgsql and AdGuard Home.
I was using my RaspberryPi to host PiHole originally. However some devices could not have their DNS overridden which meant not all devices could have ad traffic blocked. The brilliant thing about my router now being a linux machine is now I can install software directly to it! After some research, AdGuard Home was highly recommended over the ease of use in install. It’s really just a one stop download and start the binary and we are all set.
Now I can go to port 8080 on the router in order to view and manage my ad blocking network-wide. And with a couple configuration changes in the OpenWRT dashboard, all traffic goes through this port by default so even IoT devices now are blocked from ads, tracking and potential malware.
However the main thing I wanted was a way to track and aggregate how much data was being used per device. I tried several solutions but they didn’t seem to be working correctly. I stumbled upon bandwidthd that allows you to even store all the data in a database and use a php website to display the data.
The bandwidthd package appears to no longer be maintained. As I spent several hours having to mess with PostgreSQL connection string formats and fixing the errors in the PHP code in order for it to load.
I opted to run the PostgreSQL server on the RaspberryPi because I always leave it on, and now that PiHole is gone, the resources have been freed up. Here is what it looks like now!
Now I will be comparing with a desktop tool called Glasswire which is a beautiful network analyzer and firewall for Windows. Hopefully it is fairly accurate running at the router level to be able to pinpoint where the most data is coming from. In this example, our Apple TV was up at the top, which makes sense as it is streaming sometimes 4k video.
I had a lot of fun putting of this together and now I have better insights into my home network! Will be looking further into things I can do with OpenWRT!