Linux command
ifdata 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Get IP address
ifdata -pa [eth0]
Get netmask
ifdata -pn [eth0]
Get broadcast address
ifdata -pb [eth0]
Get MAC address
ifdata -ph [eth0]
Get MTU
ifdata -pm [eth0]
Check if interface exists
ifdata -e [eth0]
Get network address
ifdata -pN [eth0]
说明
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.
参数
- -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.
FAQ
What is the ifdata command used for?
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.
How do I run a basic ifdata example?
Run `ifdata -pa [eth0]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -e do in ifdata?
Test if interface exists (exit code).