ifconfig not found

Intro

In a recent blog we explored using the ss command to replace netstat. The iproute2 package that provides ss also provides ip, which as the title of this blog suggests, replaces ifconfig and arp.

All of those old utilities are considered deprecated, so you really should get comfortable with the iproute2 replacements. They aren’t going away anytime soon, but utilities like ifconfig are already removed from the latest versions of modern Linux distros like Ubuntu.

So, let’s go through the common use cases of the deprecated utilities, and see how we can replicate or even improve on the functionality with ip.

List network interfaces and IP address

Old:

ifconfig -a

New:

ip addr

Short list of network interfaces

Old:

ifconfig -s

New:

ip link

Set an IP address manually

Old:

ifconfig eth0 10.0.0.140 netmask 255.255.255.0 broadcast 10.0.0.255

New:

ip addr add 10.0.0.140/24 dev eth0

Bring interfaces up or down

Old:

ifconfig eth0 up

ifconfig eth0 down

New:

ip link set eth0 up

ip link set eth0 down

Old:

arp

New:

ip neigh

Old:

netstat -r

route

New:

ip route

Common Options

ip supports a few common options across command and objects to give you more info:

Show only IPv6 objects

ip -6 addr

Show only IPv4 objects

Here we’re using the maddr object, which are multicast addresses

ip -4 maddr

Show Statistics

ip -s link

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    RX: bytes  packets  errors  dropped overrun mcast
    656434     2906     0       0       0       0
    TX: bytes  packets  errors  dropped carrier collsns
    656434     2906     0       0       0       0

Show Human Readable Statistics

ip -s link

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    RX: bytes  packets  errors  dropped overrun mcast
    656k       2.90k    0       0       0       0
    TX: bytes  packets  errors  dropped carrier collsns
    656k       2.90k    0       0       0       0

Show Brief Output

ip -br link

lo               UNKNOWN        00:00:00:00:00:00 <LOOPBACK,UP,LOWER_UP>
enp3s0           UP             11:22:33:44:55:66 <BROADCAST,MULTICAST,UP,LOWER_UP>

Taking it Further

Syntax Shortcuts

Technically, the command to list IP addresses is:

ip address show

However, the ip command accepts abbreviated directives much like common networking OS command line interpreters.

Likewise, we abbreviated ip neighbor show down to ip neigh. You can go even further with something like ip n s or just ip n.

More Objects and Commands

There’s a pattern:

ip $OBJECT $COMMAND

Both objects and commands can be abbreviated as mentioned above. There are a bunch of objects at your disposal, including familiar stuff we’ve already seen:

  • address
  • neighbor
  • route
  • rule
  • tunnel
  • tuntap

There’s also a bunch of esoteric stuff you can lookup in the man page. Most of the objects support add, delete, show, list (with the default usually being show) but some have different actions or require slightly different arguments. You can get more information on how to use a parituclar object with:

 man ip $COMMAND

 man ip neigh

 man ip address

Summary

Well, there you have it, ip actually has a pretty consistent layout and a pretty good man page. I highly recommend going through it if you find yourself needing to do something not covered here. I do think this should be enough to get you started with ip, and feeling more confident about ditching ifconfig, route, and arp.