netlink

A Go library that wraps Linux netlink sockets with a high-level, iproute2-style API for managing links, addresses, routes, and IPsec.

Library
Go
vv1.3.1
3,300stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
73/100Good
Development Activity60
Maintenance48
Community84
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
67/100Good
Architecture80
Code Quality78
Innovation68
Learning Curve40

netlink provides a Go-native interface to the Linux kernel’s netlink communication protocol, the mechanism user-space programs use to configure networking state such as interfaces, IP addresses, routes, and IPsec transforms. Rather than exposing raw netlink message encoding, it mirrors the command structure of the iproute2 CLI: operations like ip link add map to functions such as AddLink(), making the API approachable for anyone already familiar with Linux network administration.

The project began as a fork of the netlink code inside docker/libcontainer and was substantially rewritten for testability, performance, and broader coverage, including IPsec xfrm handling, traffic control (qdisc/class/filter), network namespaces, and device-link management. Because netlink communication requires elevated kernel privileges, most operations must run as root, and the library is used extensively by container runtimes, CNI plugins, and other low-level Linux networking tooling that needs precise, programmatic control over kernel network state.

What You Get

  • High-level functions for link management (LinkAdd, LinkSetMaster, LinkByName) covering bridges, VLANs, VXLAN, bonds, and other virtual device types
  • Address and route manipulation (AddrAdd, RouteAdd, RuleAdd) modeled directly on iproute2 semantics
  • IPsec xfrm policy and state management for configuring kernel-level IPsec tunnels and transforms
  • Traffic control primitives for qdiscs, classes, and filters to implement shaping and prioritization
  • Network namespace support for creating and manipulating netns-scoped network configuration
  • A lower-level nl subpackage exposing raw netlink message construction for cases the high-level API doesn’t yet cover

Common Use Cases

  • Container runtimes and CNI plugins programmatically wiring up veth pairs, bridges, and namespace networking for containers
  • Building custom network orchestration or SDN control-plane agents that need to reconcile kernel networking state
  • Implementing VPN or IPsec tooling that configures xfrm policies and states directly from Go
  • Writing infrastructure agents that inspect or modify routing tables and traffic-control queues at runtime

Under The Hood

Architecture The library is organized as a flat package exposing per-domain files (link.go, route.go, addr.go, rule.go, qdisc.go, xfrm_.go, conntrack_.go) that each define Go structs mirroring kernel networking objects and a matching set of Add/Del/List functions; a Handle type wraps a netlink socket so callers can either use package-level convenience functions against an implicit default handle or manage explicit handles for namespace-scoped or concurrent use. The real protocol work is isolated in the nl subpackage, which builds and parses raw netlink attribute (nl.RtAttr) and message structures, so the top-level package can stay focused on translating idiomatic Go calls into those low-level messages and decoding kernel responses back into typed structs. Platform variance is handled through Go build tags: _linux.go files contain the real syscall-backed implementation, while _unspecified.go counterparts provide non-Linux stubs, which is what lets the module still go build cleanly on macOS despite being fundamentally a Linux-only library.

Tech Stack Written in Go 1.23 with a deliberately small dependency surface: golang.org/x/sys for raw syscall and unix constants, the companion github.com/vishvananda/netns module for namespace handling, and stretchr/testify for test assertions. There is no external build tooling beyond the standard Go toolchain and a Makefile; CI (GitHub Actions) runs privileged tests against real kernel modules on Ubuntu runners in addition to a macOS build-only job that guards against missing build tags.

Code Quality The project has extensive test coverage — dozens of _test.go files at both the top level and inside nl, generally exercising real kernel behavior (tests run under sudo since netlink operations require root) rather than mocks, which is a meaningful commitment to integration-style correctness for a kernel-facing library. Error handling is explicit and idiomatic Go (returned errors, no panics in the primary API surface), naming follows standard Go conventions, and the CI pipeline enforces that tests pass with real privileged syscalls rather than just compiling. There’s no linter/formatter enforcement visible in CI beyond go vet-style implicit checks and no CONTRIBUTING guide, and comment density on individual files is moderate rather than exhaustive.

What Makes It Unique Most Go netlink implementations either stay at the raw-message level or cover only a narrow slice of kernel functionality; this library’s breadth — link types, routing, rules, qdiscs, xfrm/IPsec, conntrack, devlink, RDMA links, and network namespaces all under one cohesive iproute2-modeled API — combined with its adoption as a foundational dependency inside Docker and countless CNI/container-networking projects, is what distinguishes it. The design choice to keep the high-level API’s shape mirroring iproute2 command names specifically lowers the learning curve for engineers who already think in terms of ip link/ip route commands.

Used by 7 apps in this directory

Go
82%
AGPL 3.0

Beta9

Developer Tools · AI Development · Data Engineering

1,762

Run AI workloads at scale with a Pythonic serverless runtime that handles GPU inference, background jobs, and sandboxes with zero infrastructure overhead.

View details
84
Repo Health
78
Technical
67
Dependency
Built with
Go82%
Python17%
Updated 3 days ago
Go
31%
Apache 2.0

CubeSandbox

Developer Tools · Security · AI Agents

11,386

Instant, concurrent, hardware-isolated MicroVM sandboxes for AI agents — E2B-API compatible, sub-60ms cold starts, and a built-in zero-trust egress proxy, all self-hostable at scale.

View details
82
Repo Health
88
Technical
63
Dependency
Built with
Go31%
Rust28%
C23%
Updated 2 days ago
Go
97%
Apache 2.0

Docker (Moby)

Devops · Developer Tools

72,014

The open-source container engine at the heart of Docker — a modular toolkit of runtime, build, and networking components for assembling container-based systems.

View details
98
Repo Health
86
Technical
68
Dependency
Built with
Go97%
Updated yesterday
Go
83%
Apache 2.0

frp

Networking

109,098

A fast reverse proxy that exposes local servers behind NAT or firewalls to the public internet with multi-protocol support.

View details
95
Repo Health
82
Technical
71
Dependency
Built with
Go83%
Vue12%
Updated yesterday
Go
94%
Other

NetBird

Security

28,735

Replace your VPN with a zero-trust WireGuard overlay network that auto-connects devices, enforces SSO and posture checks, and deploys in under 5 minutes.

View details
92
Repo Health
82
Technical
66
Dependency
Built with
Go94%
Updated today
Go
85%
Apache 2.0

Uncloud

Devops

5,470

Deploy and scale containerised apps across any servers without Kubernetes or Swarm overhead

View details
83
Repo Health
78
Technical
66
Dependency
Built with
Go85%
Updated 2 days ago
Go
55%
AGPL 3.0

Unkey

Developer Tools

5,427

An open-source developer platform for API infrastructure — issue and verify API keys, enforce global rate limits, route traffic through a gateway, and get per-key analytics and audit logs.

View details
91
Repo Health
70
Technical
69
Dependency
Built with
Go55%
TypeScript43%
Updated yesterday

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search