ifconfig
Display and configure network interfaces
By CMD Script Team · 4 min read · Last updated
ifconfig [INTERFACE] [OPTIONS | ADDRESS]Options
| Flag | Description |
|---|---|
-a | Show all interfaces, including those that are currently down |
up | Activate the specified interface, e.g. ifconfig eth0 up |
down | Deactivate the specified interface, e.g. ifconfig eth0 down |
netmask | Set the subnet mask when assigning an address, e.g. netmask 255.255.255.0 |
mtu | Set the interface's Maximum Transmission Unit in bytes, e.g. mtu 1400 |
hw ether | Set the interface's MAC (hardware) address, e.g. hw ether 00:11:22:33:44:55 |
Distribution compatibility
- Ubuntu
- Debian
- Fedora
- Arch
- macOS
What it does
ifconfig displays and configures network interfaces: viewing IP addresses, netmasks,
MAC addresses, and interface statistics (packets sent/received, errors), or changing
them — assigning an address, bringing an interface up or down, adjusting the MTU. It's
part of the older net-tools suite, and while still present and functional on many
systems, it has been formally deprecated on Linux in favor of the ip command from
iproute2. Knowing ifconfig is still valuable because it appears constantly in older
scripts, documentation, and exam material.
Beginner examples
ifconfig— show all currently active (up) interfacesifconfig -a— show every interface, including ones that are downifconfig eth0— show details for a single named interfacesudo ifconfig eth0 up/sudo ifconfig eth0 down— activate or deactivate an interface
ifconfig -a
Advanced examples
- Assign a static IP and netmask directly on the command line (non-persistent, resets on
reboot):
sudo ifconfig eth0 192.168.1.50 netmask 255.255.255.0 - Set a custom MTU to troubleshoot fragmentation issues over a VPN or tunnel interface:
sudo ifconfig tun0 mtu 1400 - Spoof or set a specific MAC address for testing:
sudo ifconfig eth0 hw ether 00:11:22:33:44:55 - Check interface error/drop counters when diagnosing packet loss:
ifconfig eth0 | grep -E "RX packets|TX packets|errors"
sudo ifconfig eth0 down && sudo ifconfig eth0 up
Common mistakes
- Assuming changes made with
ifconfigpersist across reboots — they don't; you need distro-specific network configuration files (netplan, NetworkManager, systemd-networkd) for persistent settings. - Running
ifconfigon a fresh minimal install and getting "command not found" becausenet-toolsisn't installed by default anymore — install it, or switch toip addr. - Forgetting
sudowhen trying to change interface state or address, since these operations require root privileges. - Confusing
ifconfig's "RUNNING" flag (link is actually up) with the interface being administratively "UP" — an interface can be up but not running if there's no carrier (e.g., unplugged cable).
Tips
- Use
ifconfig -awhen troubleshooting to make sure you're not missing an interface that exists but is currently down. - Pipe
ifconfigoutput throughgrepto extract just what you need, e.g.ifconfig eth0 | grep "inet "for the IPv4 address. - If
ifconfigisn't installed,ip addrandip linkcover the same ground and are worth learning alongside it, since they're the actively maintained tool going forward.
Best practices
- For any configuration meant to survive a reboot, use your distro's proper network
configuration mechanism (netplan/NetworkManager/systemd-networkd) rather than
hand-running
ifconfigcommands. - Prefer
ipfor new scripts and automation — it has a more consistent, scriptable output format (andip -jgives JSON), whereasifconfig's text output varies across implementations and is harder to parse reliably. - When documenting runbooks, mention both the
ifconfigandipequivalent commands, since operators may be working on systems where only one is installed.
Try it yourself
A simulated shell with a sample home directory — experiment freely, nothing leaves your browser. Type help to list supported commands.
Real-world use cases
- Quickly checking an interface's IP address and traffic counters on a legacy server during troubleshooting.
- Bringing a flaky network interface down and back up as a first troubleshooting step after a driver hiccup.
- Setting a temporary IP address on a lab or test VM without touching persistent network configuration files.
Common interview questions
- Why is ifconfig considered deprecated on Linux? It's part of the unmaintained
net-toolspackage, replaced byiproute2'sipcommand, which supports newer networking features (namespaces, more interface types) and has a more consistent interface. - What's the ip command equivalent of
ifconfig eth0 up?ip link set eth0 up. - How would you assign a static IP temporarily (non-persistently) to an interface?
sudo ifconfig eth0 192.168.1.50 netmask 255.255.255.0, understanding it won't survive a reboot without additional persistent configuration.
Frequently Asked Questions
Is ifconfig deprecated?
Yes, on modern Linux distributions. It comes from the old net-tools package, which has been officially replaced by iproute2's `ip` command (`ip addr`, `ip link`) for years. Many rolling-release distros like Arch don't install net-tools by default anymore, and even Debian/Ubuntu/Fedora treat it as optional. macOS still ships ifconfig as a first-class, actively used tool (it's BSD-derived), so it remains fully current there.
What's the ip equivalent of ifconfig -a?
`ip addr show` (or `ip a` for short) lists all interfaces and their addresses, including ones that are down — it's the modern replacement.
How do I bring an interface up or down with ifconfig?
`sudo ifconfig eth0 up` activates it; `sudo ifconfig eth0 down` deactivates it. Both require root privileges.
Why doesn't ifconfig show my new virtual/container interface?
ifconfig may simply not be installed, or on some systems it doesn't automatically enumerate interfaces created after boot without `-a`. If the interface truly doesn't appear with `-a` either, check `ip link show` instead, since `ip` is more consistently maintained for newer interface types (veth, bridges, etc.).
Cheat sheet
Download a quick-reference cheat sheet for ifconfig.