diff --git a/src/linux.rs b/src/linux.rs index dc5a4b5..95f67d3 100644 --- a/src/linux.rs +++ b/src/linux.rs @@ -146,6 +146,13 @@ pub fn list_afinet_netifas() -> Result, Error> { while !(**ifa).ifa_next.is_null() { let ifa_addr = (**ifa).ifa_addr; + // If a tun device is present, no link address is assigned to it and `ifa_addr` is null. + // See https://github.com/EstebanBorai/local-ip-address/issues/24 + if ifa_addr.is_null() { + *ifa = (**ifa).ifa_next; + continue; + } + match (*ifa_addr).sa_family as i32 { // AF_INET IPv4 protocol implementation AF_INET => {