LinuxCommandLibrary

ifdata

Get network interface information

TLDR

Display 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

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

Display the [N]etwork adress, the [b]roadcast adress, and the MTU of the specified interface
$ ifdata -pN -pb -pm [eth0]
copy

Display help
$ ifdata
copy

SYNOPSIS

ifdata [ -p ] [ -r ] [ -v ] [ ]
ifdata [ -p ] [ -r ] [ -v ] -a [ ]

PARAMETERS


    The name of the network interface to query (e.g., eth0, wlan0, enp0s3). This parameter is ignored if -a is used.


    The specific type of information to retrieve. Common types include IP, NETMASK, BROADCAST, HWADDR, MTU, RX_PACKETS, TX_BYTES, FLAGS, etc. If omitted, IP is often assumed or a default set of values is displayed.

-p
    (primary) When an interface has multiple IP addresses, this option ensures only the first (primary) IP address found is printed.

-r
    (raw) Prints the requested value without an accompanying newline character. This is highly useful for scripting where the output needs to be directly processed.

-v
    (verbose) Prints the type name before the value. For example, IP: 192.168.1.100 instead of just 192.168.1.100.

-a
    (all) Iterates through all active network interfaces and applies the query to each. When used, the parameter is ignored.

DESCRIPTION

ifdata is a command-line utility from the net-tools package designed to retrieve specific configuration information about network interfaces. It allows users to quickly query data points such as IP address, netmask, hardware address (MAC), MTU, and various statistics like packet and byte counts for both received and transmitted traffic. Unlike ifconfig which displays a large block of information, ifdata focuses on extracting a single, specific piece of data, making it particularly useful for scripting and automated tasks where only a particular value is needed. While still functional, ifdata and the broader net-tools suite have largely been superseded by the iproute2 utilities (specifically the ip command) in modern Linux distributions.

CAVEATS

ifdata is part of the net-tools package, which is considered deprecated on many modern Linux distributions in favor of the iproute2 suite. Consequently, it might not be installed by default. Its functionality is largely superseded by the more versatile ip command (e.g., ip addr show or ip -s link show). Users on newer systems are generally encouraged to use ip for network configuration and query tasks.

COMMON DATA TYPES

Some of the most frequently queried data types with ifdata include:

  • IP: IP address
  • NETMASK: Network mask
  • BROADCAST: Broadcast address
  • HWADDR: Hardware address (MAC address)
  • MTU: Maximum Transmission Unit
  • RX_PACKETS: Number of received packets
  • TX_BYTES: Number of transmitted bytes
  • FLAGS: Interface flags (e.g., UP, BROADCAST, RUNNING)

USAGE EXAMPLES

To get the IP address of eth0:
ifdata eth0 IP

To get the MAC address of wlan0 without a newline:
ifdata -r wlan0 HWADDR

To list the IP addresses of all active interfaces:
ifdata -a IP

HISTORY

The ifdata command originates from the net-tools package, which was the standard set of networking utilities for Linux and other Unix-like systems for many years. It provided a simpler, script-friendly way to extract specific network interface details compared to parsing the output of ifconfig. However, starting in the early 2000s, the net-tools suite began to be superseded by iproute2, which offers more advanced capabilities, better support for modern networking features (like multiple routing tables, namespaces, and VLANs), and a more consistent syntax. While ifdata remains functional, its development has largely ceased, and its usage has declined significantly in favor of the ip command.

SEE ALSO

ifconfig(8), ip(8), netstat(8)

Copied to clipboard