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:
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.
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.
And that’s how to use the ip command in place of ifconfig. Because ifconfig is obsolete, don’t use ifconfig.