Async Rust library for Linux network configuration via netlink - a modern alternative to iproute2 — mirror of https://git.marcpardo.eu/marcpardo/nlink
// readme
nlink
A Rust library for Linux network configuration via netlink. Async/tokio-native,
type-safe, owns its wire format end-to-end (no rtnetlink / netlink-packet-*
dependency). CLI binaries (nlink-ip, nlink-tc, nlink-ss, nlink-nft,
nlink-wg, nlink-bridge, nlink-devlink, nlink-ethtool, nlink-wifi,
nlink-config) ship as proof-of-concept demonstrations of the library —
each nlink- prefixed so it never shadows the system tool it mirrors.
Install
nlink = "0.31"
Feature flags: sockdiag, tuntap, output, namespace_watcher,
syscall_batch (recvmmsg/sendmmsg batching), serde, schemars (JSON Schema for
NetworkConfig), lab (test harness), wireguard-keys (WireGuard key
generation), full. Full list in the
docs.rs feature table.
MSRV: Rust 1.98, edition 2024.
Quick start
use nlink::netlink::{Connection, Route, RtnetlinkGroup, NetworkEvent};
use tokio_stream::StreamExt;
#[tokio::main]
async fn main() -> nlink::Result<()> {
let conn = Connection::<Route>::new()?;
// Query
for link in conn.get_links().await? {
println!("{}: {} (up={})",…