{"by":"dangoodmanUT","descendants":7,"id":46754724,"kids":[46756420,46762837,46756630,46757026],"score":58,"text":"To power the firewalling for our agents so that they couldn&#x27;t contact arbitrary services, I build netfence. It&#x27;s like Envoy but for eBPF filters.<p>It allows you to define different DNS-based rules that are resolved in a local daemon to IPs, then pushed to the eBPF filter to allow traffic. By doing it this way, we can still allow DNS-defined rules, but prevent contacting random IPs.<p>There&#x27;s also no network performance penalty, since it&#x27;s just DNS lookups and eBPF filters referencing memory.<p>It also means you don&#x27;t have to tamper with the base image, which the agent could potentially manipulate to remove rules (unless you prevent root maybe).<p>It automatically manages the lifecycle of eBPF filters on cgroups and interfaces, so it works well for both containers and micro VMs (like Firecracker).<p>You implement a control plane, just like Envoy xDS, which you can manage the rules of each cgroup&#x2F;interface. You can even manage DNS through the control plane to dynamically resolve records (which is helpful as a normal DNS server doesn&#x27;t know which interface&#x2F;cgroup a request might be coming from).<p>We specifically use this to allow our agents to only contact S3, pip, apt, and npm.","time":1769354026,"title":"Show HN: Netfence – Like Envoy for eBPF Filters","type":"story","url":"https://github.com/danthegoodman1/netfence"}