#ip-address #ip #local #address #networking

localip

A simple library to find the local IP address of the machine

3 unstable releases

new 0.2.1 Dec 14, 2024
0.2.0 Dec 14, 2024
0.1.0 Dec 13, 2024

#2086 in Network programming

Download history 335/week @ 2024-12-09

335 downloads per month

MIT license

3KB

localip

A lightweight Rust library for discovering the local IP address of your machine. It uses a simple, connectionless UDP-based approach to reliably determine the local IP address without requiring internet connectivity or third-party dependencies.

Installation

Run this command in your terminal:

cargo add localip

Example:

use localip::get_local_ip;

fn main() {
    match get_local_ip() {
        Ok(ip) => println!("Local IP address: {}", ip),
        Err(e) => eprintln!("Error: {}", e),
    }
}

No runtime deps