ifquery
Query network interface configuration
SYNOPSIS
ifquery [-a|-L] [-i FILE] [-X] [-s] [-t] [-c] [IFACE...] | ifquery -h|-V
PARAMETERS
-a, --all
Print all defined interfaces, including unmapped ones
-i FILE, --interfaces=FILE
Read config from FILE instead of /etc/network/interfaces
-L, --list
Print only interface names, one per line
-X, --exact
Require exact interface name match
-s, --sysfs
Filter interfaces by sysfs 'up' status
-t, --allow
Include hotplug (allow-hotplug) interfaces
-c, --compiled
Output compiled config as ifconfig(5) would parse it
-h, --help
Display usage help
-V, --version
Print version information
IFACE...
One or more specific interface names to query
DESCRIPTION
ifquery is a utility from the ifupdown package in Debian-based Linux distributions. It queries the network interface configuration database, typically /etc/network/interfaces, to display information about configured interfaces.
Primarily used for scripting and debugging, ifquery can list all defined interfaces, show detailed configuration for specific ones, or output parsed settings as they would be seen by ifup or ifdown. It supports filtering by interface name, exact matches, or sysfs status, making it invaluable for automation in network management scripts.
Unlike ifstatus, which checks runtime state, ifquery focuses on static configuration. It reads the interfaces file stanza-by-stanza, handling aliases, virtual interfaces (lo, sit), and hotplug setups. Output mimics the input format for easy parsing, aiding tools that need to inspect configs without runtime dependencies.
Common use cases include generating interface lists for monitoring, validating configs before application, or integrating with configuration management systems like Ansible or Puppet.
CAVEATS
Relies on ifupdown format; incompatible with NetworkManager or systemd-networkd. Does not reflect runtime changes. May miss dynamic interfaces without -t.
EXAMPLES
ifquery -a
List all interfaces.
ifquery eth0
Show config for eth0.
ifquery -L -s
List currently up interfaces.
OUTPUT FORMAT
Outputs key-value pairs like 'iface eth0 inet static', preserving comments and order for scripting.
HISTORY
Developed as part of ifupdown for Debian in the mid-1990s by Anthony Towns and others. Evolved through Debian releases; version 0.8+ introduced options like --sysfs in 2010s for better kernel integration. Maintained in Ubuntu/Debian; superseded in some modern setups by netplan.


