#local #ip #address #web #network


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

8 unstable releases (3 breaking)

0.4.4 Aug 17, 2021
0.4.3 Aug 10, 2021
0.4.2 Jul 14, 2021
0.4.0 Jun 30, 2021
0.1.0 Jun 15, 2021

#228 in Web programming

Download history 84/week @ 2021-09-26 289/week @ 2021-10-03 83/week @ 2021-10-10 92/week @ 2021-10-17 213/week @ 2021-10-24 735/week @ 2021-10-31 1179/week @ 2021-11-07 188/week @ 2021-11-14 419/week @ 2021-11-21 481/week @ 2021-11-28 1025/week @ 2021-12-05 453/week @ 2021-12-12 377/week @ 2021-12-19 318/week @ 2021-12-26 246/week @ 2022-01-02 462/week @ 2022-01-09

1,429 downloads per month
Used in 9 crates (4 directly)


398 lines


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

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
macOS Uses of getifaddrs to retrieve network interfaces
Windows Consumes Win32 API's to retrieve the network adapters table


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)


~801K SLoC