190

With the servers that mount Infiniband cards, when I use the ifconfig command, I get this warning:

Ifconfig uses the ioctl access method to get the full address 
information, which limits hardware addresses to 8 bytes.
Because Infiniband address has 20 bytes, only the first 8 bytes 
are displayed correctly.
Ifconfig is obsolete! For replacement check ip.

Should I quit using ifconfig? Is it deprecated in favor of the ip command? Or will it be updated in the near future?

Note: This question and answers are in regards to GNU/Linux's "major" distributions. It should not be assumed that the information applies to all distributions, and especially not other OSes.

Totor
  • 2,916
  • 3
  • 23
  • 31
Zhen
  • 2,159
  • 4
  • 19
  • 31
  • 25
    The sooner you switch, the better. It took me *months* to replace the muscle-memory of `ifconfig`. It does make operations on Windows even more fun though. "`ip add`-no, wait, that's not it, `ifcon`-NO, argh `ipconfig`" – Charles Dec 17 '12 at 10:09
  • 8
    Maybe an alias will help: `alias ipconfig='echo ipconfig is deprecated, use ip instead'`. Of course you set up more senseful aliases. – ott-- Dec 17 '12 at 10:13
  • 102
    `ifconfig` is deprecated? I must have been living in a cave – wim Dec 17 '12 at 14:00
  • 31
    I find it curious that a command called "ip" has the capability to do link-level operations. – James O'Gorman Dec 17 '12 at 20:34
  • 12
    It's only deprecated on certain operating systems. If you use stuff outside of Linux, I believe that ifconfig is still in use. I see no such warning on FreeBSD, for example. – Stefan Lasiewski Dec 18 '12 at 02:58
  • 1
    ifconfig's latest version on Linux dates back from 1999. I consider that "obsolete". – BatchyX Dec 18 '12 at 17:31
  • 4
    As of Fedora 18, `ifconfig`, `netstat` etc. are no longer shipped with the OS by default. Among other things, this means that RHEL 7 probably won't have them. They can still be installed from the `net-tools` package if you _really_ need them (though you probably don't). – Michael Hampton Dec 19 '12 at 05:40
  • 1
    Sure it strange if "ip" also manage other protocol than the IP Protocol... Like Infiniband here – Kedare Dec 31 '12 at 12:37
  • Per what @ott said, I add this at the bottom of my `.bashrc` file: `alias ifconfig='echo -e "\nifconfig is deprecated, use \033[31;1mip -brief addr show\033[0m instead\n" && ip -brief addr show' `. – Luke Sheppard Oct 20 '19 at 00:10
  • Because ubuntu 2004 drop ifconfig and ping in docker . I think openwrt or busybox is better than ubuntu. – bronze man Jun 30 '22 at 05:28

4 Answers4

169

Quoting Thomas Pircher's website (cc-by-sa):

ifconfig vs ip

The command /bin/ip has been around for some time now. But people continue using the older command /sbin/ifconfig. Let's be clear: ifconfig will not quickly go away, but its newer version, ip, is more powerful and will eventually replace it.

The man page of ip may look intimidating at first, but once you get familiar with the command syntax, it is an easy read. This page will not introduce the new features of ip. It rather features a side-by-side comparison if ifconfig and ip to get a quick overview of the command syntax.

Show network devices and configuration

ifconfig

ip addr show
ip link show

Enable a network interface

ifconfig eth0 up
ip link set eth0 up

A network interface is disabled in a similar way:

ifconfig eth0 down
ip link set eth0 down
quanta
  • 51,413
  • 19
  • 159
  • 217
Fel
  • 1,449
  • 1
  • 10
  • 18
  • 56
    Interesting how in every use case you mentioned the ip command is longer and more complex. Probably going to be a primary reason people still use `ifconfig` – TheLQ Dec 18 '12 at 18:20
  • 23
    @TheLQ: `ip` provides much, much more features. Of course it is more complex. Anyway, many commands can be shortened. e.g. `ip addr show` can be shortened to `ip a`, `ip link show` to `ip l`, `ip link set eth0 up` to `ip l set eth0 up` and so on. This brings `ip` on par with `ifconfig`. – BatchyX Dec 18 '12 at 19:32
  • 19
    Just remember, the entire world is not a Linux machine. Solaris, AIX, HP-UX, all of the BSDs, and SCO (not that anyone cares about *them*) all use `ifconfig`. If you want to be a *unix* admin (not just a *Linux* admin) you should make sure you're at least familiar with ifconfig and its basic syntax... – voretaq7 Dec 19 '12 at 18:17
  • "The command /bin/ip has been around for some time now." *On some distributions of Linux*. Everywhere else, it's some variation on ifconfig. – Kaz Dec 19 '12 at 22:52
  • 10
    Your first example answers it. Why run 2 commands when 1 does it? – ott-- Apr 30 '13 at 18:21
  • ip may have been around for some time, but it's the first I've even heard of it. I do mostly manage BSD and Solaris servers though. The few Linux ones I work on, I always go with what I know first (ifconfig) and it's always worked so I've never had reason to search out another tool... – Brian Knoblauch Oct 03 '14 at 15:47
  • 6
    @ott `ip addr show` pretty much includes the output of `ip link show`. – alexia Nov 20 '14 at 18:57
  • 1
    I find the output from `ip route list` to be a bit thin on information compared to `netstat -nr` – ericx Mar 26 '16 at 14:22
  • I find the output of `ip` pretty ugly and unreadable, so I usually pipe it to `column -t`. – Pablo A Feb 27 '18 at 04:40
  • 2
    `ip addr show` can be shortened to `ip a` and sure you may like the look of the ifconfig output. but ifconfig's output doesn't always list all the ip addresses. in my book thats pretty broken. – Jasen Mar 16 '18 at 02:34
  • 1
    `ip` is all well and good. But it seems odd to me that after 11+ years, it still cannot tell if an Ethernet device is **connected** to an upstream router/switch/etc. To be clear: `ifconfig` can report `RUNNING` if eth0 is connected, but there is no combination of verbs or options in `ip` that will give you that information. – Seamus Sep 06 '20 at 22:36
47

Yes, ifconfig is deprecated in favor of iproute2 (the ip command) on Linux.

Similarly, the arp, route and netstat commands are also deprecated.

However, iproute2 is Linux specific, when some other Unixes use ifconfig, so it may help to know/remember how it works if you're ever going to use another Unix...

To learn the "new way", I suggest you to look at those 3 links :

According to the last link, ifconfig has not been maintained for +20 years:

Except for the patch mass that Debian accumulated, the net-tools package has not seen any upstream development after version 1.60, released sometime about April 15 2001.

Totor
  • 2,916
  • 3
  • 23
  • 31
  • 9
    `ifconfig` was developed by BSD back in the day. Linux essentially used BSD's IP stack (as did Windows and others of the time, why `ipconfig` is still similar to `ifconfig`). In the 2.4 Kernel Linux starting diverging heavily from BSD's stack, that was the beginning of 2001. It's not happenstance that `ifconfig` in Linux hasn't been well maintained since then. – Chris S Apr 30 '13 at 18:02
  • 5
    10 years!? Time to launch a "save ifconfig" project on GitHub, I guess. – kenchilada May 01 '13 at 14:46
20

ifconfig is deprecated for many years now, time to switch, especially in a case like yours.

quanta
  • 51,413
  • 19
  • 159
  • 217
Sven
  • 98,649
  • 14
  • 180
  • 226
  • 1
    I also like its cisco-esque command shortening. "ip a" = "ip address show" – Coops Dec 17 '12 at 11:15
  • 5
    meh. There's enough scripts and other tools around that are built over ifconfig, that I don't feel the need to switch until it disappears... – Jason Antman Dec 17 '12 at 19:55
  • 11
    I've never heard of `ip`. I just tested it on a FreeBSD server and it says `ip: Command not found.`. Maybe `ifconfig` is only deprecated on Linux. – ctype.h Dec 18 '12 at 03:25
  • 2
    @ctype.h: Indeed, it is only deprecated on linux. ifconfig's release targetting linux dates back from 1999. `ip` was already the recommended choice for 2.4 kernels. – BatchyX Dec 18 '12 at 18:15
  • `ifconfig` reports `RUNNING` in its output if the Enet interface is connected to a switch/router. `ip` appears to have no equivalent for that in Sep, 2020. ??? – Seamus Sep 06 '20 at 23:02
  • If I'm not mistaken, ifconfig's "RUNNING" == "state UP" in ip link. Not to be confused with the UP in flags field... – Governa Jan 14 '21 at 17:46
5

ip has been the replacement for ifconfig for a while, probably at some point ifconfig will update, however I wouldn't wait for it and learn to work with ip as well. Its supported on all linux distri's

quanta
  • 51,413
  • 19
  • 159
  • 217
Flash
  • 1,310
  • 7
  • 13
  • 8
    ip has been the replacement for ifconfig **on Linux**, as a choice made by some distros. – Kaz Dec 19 '12 at 22:51
  • it seems extremely unlikely that ifconfig could be made fully compatible with linux. commands like `ifconfig eth0 192.168.0.7/24` do not have a clear meaning: eg. if `eth0` already has 2 ip addresses on it (two on it, not one one an alias like eth0:1). – Jasen Mar 16 '18 at 02:23