LinuxCommandLibrary

ifdata

retrieves network interface information in a script-friendly format

TLDR

Get IP address

$ ifdata -pa [eth0]
copy
Get netmask
$ ifdata -pn [eth0]
copy
Get broadcast address
$ ifdata -pb [eth0]
copy
Get MAC address
$ ifdata -ph [eth0]
copy
Get MTU
$ ifdata -pm [eth0]
copy
Check if interface exists
$ ifdata -e [eth0]
copy
Get network address
$ ifdata -pN [eth0]
copy

SYNOPSIS

ifdata [options] interface

DESCRIPTION

ifdata retrieves network interface information in a script-friendly format. Part of the moreutils package. Unlike ifconfig or ip, it returns single clean values without parsing. Exit codes indicate success/failure for conditional testing in scripts.

PARAMETERS

-e

Test if interface exists (exit code).
-pa
Print IP address.
-pn
Print netmask.
-pN
Print network address.
-pb
Print broadcast address.
-pm
Print MTU.
-ph
Print hardware (MAC) address.
-pf
Print flags.

SEE ALSO

ip(1), ifconfig(1)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community