if_nametoindex(3p)

if_nametoindex3p

Map a network interface name to its corresponding index

Usage

#include <net/if.h>

unsigned if_nametoindex(const char *ifname);

Prolog

This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux.

Overview

The if_nametoindex() function shall return the interface index corresponding to name ifname.

Return value

The corresponding index if ifname is the name of an interface; otherwise, zero.

Errors

No errors are defined.

The following sections are informative.

Examples

None.

Application usage

None.

Rationale

None.

Future directions

None.

From man-pages 6.19-1 in Arch Linux 2026-11-01. Parsed by carta from the page's man source.