top of page

Building TubeTimeout: One Parent’s Quest to Tame YouTube

Updated: Aug 6

My goal was simple: create one YouTube timer that applied to all the kids’ screens, not just one. TVs, iPhones, you name it — I wanted them all playing by the same rules.


To do that, I needed to monitor internet traffic across my home network, identify which devices were watching YouTube and block access when their time was up.


It sounded like a big job, and it was, although I enjoy this sort of challenge. That’s how TubeTimeout began!


The First Try: ARP Spoofing (Spoiler: It Didn’t Work)


My first attempt involved ARP spoofing, a networking trick that tries to convince devices that an alternative computer is the gateway to the internet. That way, all the traffic would flow through a device that I controlled, where I could monitor or modify it. No reconfiguring of the network would be required either.


In theory, it sounded promising. In practice, it wasn’t reliable. My router kept announcing itself as the real gateway and the devices on the network trusted it more than my Raspberry Pi. The router’s announcements would take priority and I’d lose visibility of the traffic. That made ARP spoofing a dead end.


Plan B: My Respberry Pi As The Internet Gateway


Next, I configured my Mac to use a Raspberry Pi as its internet gateway. I set a static IP address and enabled IP forwarding on the Pi.


I knew I could control network packets with iptables, which I’d used before. However, I soon realised that iptables had been replaced some time ago by a newer system called nftables. This newer tool offered much more flexibility, including the ability to send selected network packets into user space where custom code could inspect them before deciding whether to allow or block them.


Catching YouTube Traffic with nftables


I found an open-source Go library from Google that made it straightforward to configure nftables rules programmatically. With it, I could define what kind of traffic I wanted to inspect.


To identify YouTube traffic, I used a community-maintained list of YouTube IP host names. There 100s of them, which makes sense, as YouTube is a huge service offering some amazing content that's ever growing!


After I'd written some code to dynamically convert the host names into IP addresses, I started adding rules for each one, though it quickly became clear that hundreds of rules were slowing things down significantly.


Thankfully, nftables includes a feature called IP sets. Instead of one rule per address, I could define a set of addresses and write just a single rule to match any traffic heading to or from any of them. It was much more efficient and solved the performance issue nicely.


Identifying Who’s Watching


Once I could detect YouTube traffic, the next challenge was figuring out which devices were responsible for it.


Devices on a home network are often given different IP addresses each time they reconnect, which is especially common with phones and tablets. Their MAC addresses usually stay the same and are a better identifier over time. More on that later.


I designed TubeTimeout to group devices together by MAC address so, for example, when a phone and tablet both connect, their usage can count towards a shared limit. This makes it easy to set up shared screen time policies for a household.


Keeping Up With Changing IPs


Since MAC addresses aren’t visible in user space, TubeTimeout needs to keep a current mapping of MAC addresses to IP addresses. It does this by scanning the local network using the arp tool, which provides the latest view of who’s who on the network.


Every minute, it updates this map in memory so that when a packet arrives, it can match the IP address to the right device and group.


YouTube In A Browser vs The App


Now that I had everything needed to block YouTube, I wanted to test it working in practice. I configured my rules to block YouTube from my laptop and mobile phone to get a bit of variety.


My laptop behaved as expected and was blocked successfully, but my phone was not.


After using tcpdump to see what traffic was still leaving my mobile phone, I discovered the issue was because IPv6 was being used. The clever YouTube app had found another route to the internet.


So I opted to simplify the problem and disabled IPv6 router advertisements on my home network as a workaround.


The TV That Never Slept


Everything seemed to be working well until I noticed something odd. YouTube usage was increasing even when no one was watching TV.


After a bit of detective work, I found the culprit. Our LG TV was still sending and receiving data from YouTube even in standby mode. I hadn’t enabled any fancy smart features or quick start options, though it was still acting like it had a job to do.


I experimented with tracking packet sizes and patterns to try and distinguish active use from idle background traffic. I built a ring buffer to gather stats every minute and explored whether download activity could be used as a signal of actual viewing. Unfortunately, the TV’s idle traffic looked very similar to its active usage, which made it difficult to tell the difference reliably.


I made a note to revisit this once more important features were complete.


In the end, I moved the LG TV into its own group and blocked YouTube entirely for that device. Since the kids still had access through the Samsung TV or the Xbox, which happened to be plugged into the LG TV anyway, it didn’t cause any problems.


Time For A Proper Interface


With the core logic working, I needed a more user-friendly way to configure everything. I wanted my partner to be able to adjust settings or pause access without needing to touch the command line.


So I built a simple web interface. It lets you:


  • Create named groups (called “usage trackers”, but I'm undecided on the name)

  • Assign time limits and define when the limits should reset

  • Add devices by MAC address

  • Give devices friendly names


Since I already had a clean HTTP API for TubeTimeout, I asked ChatGPT to help me build the frontend in plain JavaScript and HTML. I didn’t want to rely on any third party libraries, so it all runs as static content served by the Golang backend that handles packet processing.


With a bit of trial and error and several good conversations with AI, I ended up with a simple UI that does the job. It’s not fancy, though it works well enough and runs happily on a Raspberry Pi Zero.


Adding “Block” and “Allow” Modes


Sometimes we needed a quick way to pause (block) YouTube access, like when we were calling the kids for dinner and they weren’t responding. So I added a way to block a group of devices temporarily.


You can pause access for 15 minutes, an hour or until midnight, for example. Once that time is up, TubeTimeout resumes tracking as normal.


I also added an “allow” mode, which lets you temporarily permit YouTube without counting it against the group’s time limit. These features are handy for special occasions or rewards and they fit neatly into the three usage modes:


  • Monitor (track the kids' usage)

  • Allow

  • Deny (block)


Letting TubeTimeout Handle DHCP


To be the true gateway for other devices on the network, TubeTimeout needs to manage DHCP by issuing IP addresses to devices unless there’s already another DHCP server running on the network, which is normally the job of the router.


I wrote some code that listens for DHCP replies. If another device, like a router, responds then TubeTimeout knows not to start its own server, since we don't want a clash. If there’s no reply, TubeTimeout can offer DHCP settings itself.


It can infer the necessary DHCP configuration from the router, including IP range, subnet mask, and the real gateway to the internet. Then it suggests these settings in the web interface. All the user has to do is confirm them by ticking a box.


TubeTimeout won’t leave your network without DHCP and it is designed to back off automatically if another server takes over again.


A Quick Word on MAC Address Privacy


As I mentioned earlier, modern devices, especially phones and tablets, often use rotating MAC addresses to protect user privacy. This can cause problems for TubeTimeout, because it needs to identify each device consistently.


At home, it’s safe to disable this feature and give devices a static MAC address. For example, on iPhones you can go to:


Settings → Wi-Fi → [Your Network] → Private Wi-Fi Address → Off


Other options on the iPhone include:


  • "Fixed" which changes if the device forgets the network and rejoins

  • "Rotating" which changes them more frequently based on logic baked into iOS


Choose "Off" to ensure TubeTimeout can correctly associate the device with its group and apply the right time limits.


What Can TubeTimeout Do?


With TubeTimeout running on a Raspberry Pi, you can:


  • Set up shared YouTube time limits for groups of devices based on their MAC address

  • Instantly block or resume access (there's a gotcha here; more on that below)

  • Track usage across groups of different screens

  • Configure and manage everything from your phone, laptop or anything with a modern Internet browser


It’s been a great addition to our home, helping keep screen time in check without needing daily reminders or arguments. The kids understand the limits and we have tools that let us step in when needed.


A Few Things to Keep in Mind


Like any clever workaround, TubeTimeout comes with a couple of quirks worth knowing about:


  • Blocking YouTube might affect other Google services


Since YouTube shares infrastructure with services like Google Docs, blocking access can sometimes interfere with those too. This usually isn’t a problem for TVs or tablets, though it might get in the way if older kids are using a laptop for schoolwork. Just something to bear in mind when setting up groups and rules. There are buttons in the UI to quickly "allow" access if this becomes a problem.

  • YouTube videos can keep playing a bit after time runs out


YouTube is designed to buffer videos in advance so playback in uninterrupted. That means when a group hits its time limit, the current video might continue playing until it reaches the end. TubeTimeout stops further content from loading, but it doesn’t cut the stream mid-video — so expect a little grace period after the time runs out.


Ready to Try It Out?


Whether you’re a parent looking for more control over screen time, someone who enjoys a good DIY tech project or are just curious about how home networks work, TubeTimeout is ready to help.


If you have time and some tech smarts, you can get started with just a Raspberry Pi Zero and build & install TubeTimeout manually. It's open-source too, so the community can verify how it works.


Alternatively, you can buy a device a pre-configured device with TubeTimeout ready to go. This way it helps support the project and fund its further development.


Visit the links above to try it out for yourself. I’d love to hear your feedback and ideas for future improvements.


Best wishes,

Richard


Comments


bottom of page