#local #ip #address #web #network


Retrieve system's local IP address and Network Interfaces/Adapters on Linux, macOS and Windows

16 releases

0.5.3 May 7, 2023
0.5.2 Mar 4, 2023
0.5.1 Jan 10, 2023
0.5.0 Dec 30, 2022
0.4.2 Jul 14, 2021

#25 in Network programming

Download history 6783/week @ 2023-02-14 6377/week @ 2023-02-21 7235/week @ 2023-02-28 7394/week @ 2023-03-07 8318/week @ 2023-03-14 15804/week @ 2023-03-21 13774/week @ 2023-03-28 11672/week @ 2023-04-04 15240/week @ 2023-04-11 10388/week @ 2023-04-18 10196/week @ 2023-04-25 15905/week @ 2023-05-02 19162/week @ 2023-05-09 19024/week @ 2023-05-16 17515/week @ 2023-05-23 14620/week @ 2023-05-30

73,314 downloads per month
Used in 46 crates (37 directly)


954 lines


Retrieve system's local IP address and Network Interfaces/Adapters on Linux, Windows, and macOS (and other BSD-based systems).

Crates.io Documentation Build Clippy Formatter


Get the local IP address of your system by executing the local_ip function:

use local_ip_address::local_ip;

fn main() {
    let my_local_ip = local_ip().unwrap();

    println!("This is my local IP address: {:?}", my_local_ip);

Retrieve all the available network interfaces from both, the AF_INET and the AF_INET6 family by executing the list_afinet_netifas function:

use local_ip_address::list_afinet_netifas;

fn main() {
    let network_interfaces = list_afinet_netifas().unwrap();

    for (name, ip) in network_interfaces.iter() {
        println!("{}:\t{:?}", name, ip);

Underlying approach on retrieving network interfaces or the local IP address may differ based on the running operative system.

OS Approach
Linux Establishes a Netlink socket interchange to retrieve network interfaces
BSD-based Uses of getifaddrs to retrieve network interfaces
Windows Consumes Win32 API's to retrieve the network adapters table

Operating System Support

Current supported platforms include:

  • Linux (requires at least v0.1.0);
  • macOS (requires at least v0.1.0);
  • Windows (requires at least v0.3.0);
  • Other BSD-based (requires at least v0.5.0); including:
    • FreeBSD
    • OpenBSD
    • NetBSD
    • DragonFly

Please note that we only test the BSD implementation of this on macOS and FreeBSD, under the assumption that other BSD-based systems will behave similarly. If you have any complications using this library on the other BSD-based, please create an issue.


In order to create a release you must push a Git tag as follows

git tag -a <version> -m <message>


git tag -a v0.1.0 -m "First release"

Tags must follow semver conventions Tags must be prefixed with a lowercase v letter.

Then push tags as follows:

git push origin main --follow-tags


Every contribution to this project is welcome. Feel free to open a pull request, an issue or just by starting this project.


Distributed under the terms of both the MIT license and the Apache License (Version 2.0)


~115K SLoC