Command by command
| Legacy Linux (net-tools) | Linux | What it gives you |
|---|---|---|
ifconfig | ip addr show | All interfaces (ifconfig hides down ones) |
ifconfig -a | ip addr show | Including down interfaces |
ifconfig eth0 | ip addr show dev eth0 | One interface |
ifconfig eth0 up | ip link set eth0 up | Bring the link up |
ifconfig eth0 10.0.0.1/24 | ip addr add 10.0.0.1/24 dev eth0 | Add — not replace — an address |
What the output looks like
$ ip addr show dev ge0
2: ge0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 state UP
link/ether 02:42:0a:00:01:01 brd ff:ff:ff:ff:ff:ff
inet 10.0.1.1/24 scope global ge0
valid_lft forever preferred_lft forever
Why the two differ
The real reason to move is not style. The kernel keeps a flat list of equal addresses on each interface, and ip addr shows the whole list. ifconfig shows one address per interface name: the first, plus any extra address that was given a label such as eth0:1, which it lists as though it were a separate interface. An address added with ip addr add and no label does not appear in ifconfig output at all. Its IPv6 support is also incomplete.
The trap
ifconfig eth0 10.0.0.1 replaces the interface's address. ip addr add adds one, keeping what was already there. People migrating from the old command are frequently surprised to end up with two addresses on an interface. To change an address, remove the old one with ip addr del (or clear the interface with ip addr flush dev eth0) and then add the new one.
Common questions
Is ifconfig removed, or just discouraged?
Neither exactly. The command still works where net-tools is installed, and nothing in the kernel has dropped support for it. But it is not installed by default on current Debian, Ubuntu, Fedora, RHEL or Arch, so a script that calls it will fail on a clean system. Treat it as unavailable rather than deprecated.
Why does ifconfig show fewer interfaces than ip addr?
By default ifconfig lists only interfaces that are up. ip addr show lists everything. Use ifconfig -a to match.
Stop reading, start running
Open the lab, go live, and run ip addr show against real Linux networking in your browser. No install, no signup.