Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^2: Getting list of network interfaces

by Anonymous Monk
on Mar 27, 2026 at 08:46 UTC ( [id://11167481]=note: print w/replies, xml ) Need Help??


in reply to Re: Getting list of network interfaces
in thread Getting list of network interfaces

IO::Interface and Net::Interface both use getifaddrs, but it isn't part of the POSIX spec. From the linux manpage:
This function first appeared in BSDi and is present on the BSD systems, but with slightly different semantics documented— returning one entry per interface, not per address. This means ifa_addr and other fields can actually be NULL if the interface has no address, and no link-level address is returned if the interface has an IP address assigned. Also, the way of choosing either ifa_broadaddr or ifa_dstaddr differs on various systems.

getifaddrs() first appeared in glibc 2.3, but before glibc 2.3.3, the implementation supported only IPv4 addresses; IPv6 support was added in glibc 2.3.3. Support of address families other than IPv4 is available only on kernels that support netlink.

  • Comment on Re^2: Getting list of network interfaces

Replies are listed 'Best First'.
Re^3: Getting list of network interfaces
by Marshall (Canon) on Apr 03, 2026 at 12:48 UTC
    yes, you are right, further investigation:

    The getifaddrs function is not part of the POSIX standard. It is a common extension used to retrieve a linked list of network interface addresses on the local system.

    POSIX Status and Portability
    Non-Standard: As of the latest POSIX versions (such as POSIX.1-2001 and 2008), getifaddrs remains an extension rather than a standardized interface. Origin: The function first appeared in BSDi and has since been adopted by most BSD-derived systems (FreeBSD, macOS, OpenBSD) and Linux (via glibc 2.3 and later).

    Implementation Differences: Because it is not standardized, behavior can vary across platforms. For example:
    BSD: Often returns one entry per interface.
    Linux: Typically returns one entry per address assigned to an interface (e.g., separate entries for IPv4 and IPv6).

    POSIX Alternative: For strictly POSIX-compliant code, developers often use the ioctl system call with the SIOCGIFCONF request to enumerate interfaces, though this method is more cumbersome and has limitations regarding IPv6 support.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11167481]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2026-05-08 11:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.