ifconfig
Networking
Usage
ifconfig [-a] [<interface>]The old command for looking at and touching network interfaces; on Linux `ip addr` has replaced it, it may not even be installed, and it cannot show every address ip added — on macOS, though, it is still the real tool.
Common flags
| Flag | Meaning |
|---|---|
| -a | Include interfaces that are down; plain ifconfig may hide them on Linux. |
| <if> up / down | Bring one interface up or down. |
| <if> inet <ip> netmask <mask> | Set an address, until the next reboot. |
| en0 / eth0 | The usual names: en0 on macOS, eth0 or ens5 on Linux. |
Examples
ifconfig -aEvery interface, including the ones currently down.
ifconfig en0 | grep "inet "The local IPv4 address on macOS.
sudo ifconfig eth0 downTake an interface offline (Linux, if net-tools is installed).
When a connection fails, these narrow down how far it got — name not resolving, no route, or a blocked port.
How to read this
- Square brackets [ ] mark a part you may leave out.
- An ellipsis … means you can list more than one.
- Flags are case-sensitive — in some commands -r and -R do different things.
Questions
Q. What does ifconfig do?
The old command for looking at and touching network interfaces; on Linux `ip addr` has replaced it, it may not even be installed, and it cannot show every address ip added — on macOS, though, it is still the real tool.
Q. How do I type it?
ifconfig [-a] [<interface>] — square brackets mark the parts you can leave out.
Q. How many flags are worth knowing?
4 are listed here; the full set is in man ifconfig. This command sits under Networking.
Related commands
man page: man ifconfig