Back to Basics Part 6 — Using the ip command in GNU/Linux for beginners

For years, people used the ifconfig tool to handle their command line IP / network interface related tasks.

However, ifconfig is long dead, and has since been replaced with the IP tool, although it will take users some time to make the total switch, as ip is considerably more powerful than ifconfig was.

This tutorial is geared to users who are not quite absolute CLI beginners, but are ready to start getting their toes wet when dealing with networking and interfaces.

IP Command in Linux

Getting right into it, the first command we will look at, checks all network interfaces, and shows information related to them such as IP address: ip addr show

Use the commands ip -4 a or ip -6 a to only show IPv4 or IPv6 related information

The same command can be used, to specifically look up information related to a certain interface. In this case, using wlp1s0 (wifi adapter) as the interface: ip addr show wlp1s0

Last but not least, you may also use it to show interfaces that are active: ip link ls up

Network interfaces

Enabling or disabling a network interface is also accomplished quite easily using the ip command (Note wlp1s0 is the name of the interface, and the up/down command enables or disables the interface on the device).

Enabling an interface (using the same interface from previous examples): ip link set wlp1s0 up

Disabling the very same interface: ip link set wlp1s0 down

You can use the IP command to set an IP address for the computer. The general command is ip a add IP/mask dev INTERFACE, e.g.: ip addr add 192.168.2.10/24 dev wlan0

Or use the command to remove an IP address again by using the del command instead of add, e.g. sudo ip addr del 192.168.2.10/24 dev wlan0

Other IP commands

To check the routing tables for your system, use: ip route show

Just like with the ‘addr show’ options, we can also pinpoint routing information down to a specific IP address: ip route get XXX.XXX.X.X #replace X with the desired IP address

Looking up network statistics is another extremely useful way to utilize the ip command, especially if you are under suspicions about packet loss occurring: ip -s link

You can also use the following command to quickly see all available options that ip can use: ip help

Lastly, but not least, you can use the manpages if you need more information, as ip can do much more powerful things than discussed here, as this was meant for beginners: man ip

And one more resource for you, is super handy cheatsheat that RedHat have put together, for using the ip command, found here.

Last words

Your typical home user will likely never need to actually use the ip command, for any of the usual day to day tasks.

However, as soon as you start delving into any form of server/sysadmin work, be it web hosting, or even just hosting a Minecraft server for you and your neighbour, you can quickly start tumbling down the networking rabbit hole; so learning the basics of ip as well as other tools like netstat or its replacement ss should be high on your priority list.

Summary

Article Name

Back to Basics Part 6 — Using the ip command in GNU/Linux for beginners

Description

The IP command tutorial is geared to users who are not quite absolute CLI beginners, but are ready to start getting their toes wet when dealing with networking and interfaces on GNU/Linux.