My home network observes bedtime with OpenBSD and pf
This post dives deep into configuring OpenBSD's pf firewall to enforce a 'bedtime' internet cutoff for a home network. It showcases a highly granular, technical solution to a common household challenge, appealing to those who appreciate robust, DIY system administration. The author details using dynamic IP tables, rule anchors, and state table manipulation to achieve precise control over device access.
The Lowdown
The author, an OpenBSD enthusiast, details how they constructed a home network gateway using OpenBSD and its pf packet filter to enforce internet 'bedtime' rules for devices. This setup leverages pf's powerful capabilities to dynamically control network access, ensuring that only specific, exempt devices remain online during designated hours, a practical application for managing family screen time.
- Core
pfphilosophy: The system defaults toblock alltraffic, then selectivelypassapproved connections, ensuring a secure baseline. - Dynamic Rule Switching: Two primary rulesets are used: a 'daytime' rule allowing all
<leased_ips>and a 'bedtime' rule restricting access to only<bedtime_exempt>IPs. - IP Address Tables:
<leased_ips>is automatically populated bydhcpdfor all active devices, while<bedtime_exempt>is a manually maintained list of devices allowed during bedtime, loaded viapfctl. - Protocol Handling: Initial setup primarily focuses on TCP, with UDP/ICMP handled strictly, though the author notes real-world adjustments were needed for applications like Discord and Roblox.
- Anchor-based Rule Management:
pfanchors are used to dynamically swap entire sets of firewall rules on the fly without requiring a fullpfreload, crucial for seamless bedtime transitions. - Killing Active Connections: A significant challenge was terminating existing connections (e.g., streaming video) when bedtime rules activate. The solution involves using
pfctlto kill relevant active connections, though a more granular approach (killing only non-exempt connections) proved difficult. - System Cohesion: The author praises OpenBSD's integrated design, noting how
dhcpdandpfctlseamlessly interact withpf's table system, embodying the 'Unix Philosophy'. - Automation: All these components are integrated into a shell script to automate the bedtime enforcement process.
This detailed guide provides a robust, OpenBSD-centric method for implementing granular network access control, offering a powerful alternative to consumer-grade parental control features for technically-inclined users.