STOP Using the Linux ifconfig Command [Here’s Why]

ip command

The ifconfig command is obsolete, and you should no longer use it! This tutorial covers the ip command, which you should use in place of ifconfig.

Here’s how to use the ip command instead. The ip command can do a bunch of other stuff as well, but we’ll focus on how it replaces the ifconfig command. To see the full manual for the command, type the following into your terminal:

man ip

Using the ip Command Instead of ifconfig

Let’s look at two ip commands – ip addr focuses on addresses and ip link on network interfaces.

IP Addresses vs. Interfaces

IP addresses are your device’s address on the network (surprise!), and interfaces are usually the physical network card or Wifi adapter connected to the network (though you can have virtual interfaces as well). An interface can have multiple addresses.

The ip addr Command

Here are some common ifconfig tasks performed with the ip addr command:

Display All IP Addresses

ip addr show

Show IP addresses for a Single Network Interface

ip addr show dev eth0

eth0 should be the network interface’s name – see how to list all interfaces below.*

Assign an IP address to a Network Interface

sudo ip address add 192.168.1.11/24 dev eth0

*Here, the IP address 192.168.1.11 is assigned to the interface eth0. Multiple addresses can be assigned using CIDR notation.

Removing an IP Address from an Interface

sudo ip address del 192.168.1.1/24 dev eth0

The IP address 192.168.1.11 is removed from the interface eth0.

The ip link Command

Listing All Network Interfaces

ip link show

Show the Details of a Single Network Interface

ip link show dev eth0

eth0 should be the name of the network interface – see how to list all interfaces above.*

Bringing a Network Interface UP or DOWN

ip link set eth0 up

This will bring eth0 UP – or online. You can also bring it DOWN:

ip link set eth0 down

…or offline – allowing you to disconnect and reconnect a network interface.

Conclusion

And that’s how to use the ip command in place of ifconfig. Because ifconfig is obsolete, don’t use ifconfig.

To learn more about networking in Linux, check out our other articles!

SHARE:
nv-author-image

Brad Morton

I'm Brad, and I'm nearing 20 years of experience with Linux. I've worked in just about every IT role there is before taking the leap into software development. Currently, I'm building desktop and web-based solutions with NodeJS and PHP hosted on Linux infrastructure. Visit my blog or find me on Twitter to see what I'm up to.

Leave a Reply

Your email address will not be published. Required fields are marked *