LinuxCommandLibrary

ifdata

Get network interface information

TLDR

[p]rint the whole configuration of the specified interface

$ ifdata -p [eth0]
copy

Indicate the [e]xistence of the specified interface via the exit code
$ ifdata -e [eth0]
copy

[p]rint the IPv4 [a]dress and the [n]etmask of the specified interface
$ ifdata -pa -pn [eth0]
copy

[p]rint the [N]etwork adress, the [b]roadcast adress, and the [m]TU of the specified interface
$ ifdata -pN -pb -pm [eth0]
copy

Display help
$ ifdata
copy

SYNOPSIS

ifdata [-pqt] [-b|-u] [-h] [-V] [-n] [-L|-l] interface [field]

PARAMETERS

-b
    Print value as bytes instead of human-readable

-u
    Print unsigned byte value

-p
    Print only if interface is up

-q
    Quiet mode; exit non-zero if no data

-t
    Print Unix timestamp before value

-n
    Print numeric IP addresses

-L
    Print only link-local addresses

-l
    Print all addresses

-h
    Show help

-V
    Show version

DESCRIPTION

The ifdata command is a utility from the ifupdown package that displays specific data about a network interface, such as IP addresses, MTU, or hardware address, without bringing the interface up. It reads from /run/network/ifstate (generated by ifupdown) or sysfs, making it useful in network configuration hooks (e.g., /etc/network/if-*.d scripts).

It supports querying fields like inet, broadcast, netmask, hwaddress, mtu, and more. By default, it prints human-readable output but can output bytes, unsigned values, or numeric formats. Options allow conditional printing (only if up), quiet mode, timestamps, and listing all/link-local addresses.

Common use: ifdata -n inet eth0 to get the IP numerically. Ideal for scripts needing interface info pre-activation.

CAVEATS

Requires interface configured in ifupdown (/etc/network/interfaces); no data if not. Limited to ifupdown-managed interfaces; doesn't query kernel directly for all fields.

SUPPORTED FIELDS

inet, broadcast, netmask, hwaddress, mtu, metric, mss, dstaddr, encap, media, status, up

EXIT STATUS

0: data found
1: no data or error
2: invalid args

HISTORY

Developed by Bernd Eckenfels for ifupdown (~2002); maintained in Debian's ifupdown2 package since ~2018 for modern features like systemd integration.

SEE ALSO

ifup(8), ifdown(8), ip(8), ifconfig(8)

Copied to clipboard