ifconfig: Usage, Options & Common CI Errors
ifconfig displays and configures network interfaces (the legacy tool).
ifconfig is the historic interface tool, replaced by ip addr / ip link. It is missing from most modern images, so scripts that read a container IP via ifconfig break - knowing the ip equivalent is essential.
What it does
ifconfig displays the configuration of network interfaces (addresses, MAC, MTU, flags) and can bring them up or down or assign addresses. It belongs to the deprecated net-tools package; iproute2's ip addr and ip link are the modern replacements.
Common usage
ifconfig # all active interfaces
ifconfig eth0 # one interface
ifconfig -a # include down interfaces
ifconfig eth0 up # bring an interface up
# Modern equivalent:
ip addr show eth0Options
| Usage | What it does |
|---|---|
| (none) | Show active interfaces |
| -a | Show all interfaces including down |
| <if> up|down | Bring an interface up or down |
| <if> <addr> | Assign an address |
| <if> mtu <N> | Set the MTU |
Common errors in CI
"ifconfig: command not found" - net-tools is not installed on Alpine/distroless/most slim images; use ip addr show (read) and ip link set (config) instead. Parsing ifconfig output for an IP is fragile across versions; prefer ip -o -4 addr show <if> | awk '{print $4}'. Config changes need NET_ADMIN. ifconfig also truncates or omits secondary addresses that ip addr shows in full, so a container with multiple IPs can look single-homed under ifconfig - another reason to standardize on ip.