Registry / networking / tun2
library4.0.0rscratesunverified

TUN device creation and handling for Rust, enabling virtual network interfaces.

# Cargo.toml [dependencies] tun2 = "4.0.0"
INSTALL
IMPORT
SIG · TUN2
T
tun2
networkingrustv4.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Tun
use tun2::Tun;

Creates a TUN device and reads a packet from it.

use tun2::Tun; fn main() -> Result<(), Box<dyn std::error::Error>> { let mut tun = Tun::new("tun0")?; let mut buf = [0u8; 1500]; let n = tun.recv(&mut buf)?; println!("Received {} bytes", n); Ok(()) }
Debug
Known issues
gotchaRequires root/administrator privileges to create TUN devices.
fix
Run the application with elevated permissions.
affects: >=4.0.0
Upgrade
Version history
4.0.0latest on crates.io
Audit
Dependencies

No dependency data recorded yet.

Agent activity
16 hits · last 30 days
node
14
OpenAI (training)
1
Resources
tun2 — cargo add tun2 · libregistry