Back to Basics Part 6 -- Using the ip command in GNU/Linux for beginners - gHacks Tech News

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

ip-addr-show

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
Back to Basics Part 6 -- Using the ip command in GNU/Linux for beginners
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.
Author
Publisher
Ghacks Technology News
Logo
Advertisement

We need your help

Advertising revenue is falling fast across the Internet, and independently-run sites like Ghacks are hit hardest by it. The advertising model in its current form is coming to an end, and we have to find other ways to continue operating this site.

We are committed to keeping our content free and independent, which means no paywalls, no sponsored posts, no annoying ad formats or subscription fees.

If you like our content, and would like to help, please consider making a contribution:


Previous Post: «
Next Post: »

Comments

  1. Jilano said on April 15, 2018 at 10:19 am
    Reply

    Good job, Mike! I love and bookmark all these articles on Linux. It can be really useful, especially for someone who just started.

    PS: There is an issue with the picture. It seems that she’s overlapping the right sidebar. https://imgur.com/wmAV3uJ

  2. Paul(us) said on April 15, 2018 at 12:09 pm
    Reply

    Really great series Mike, I wishing and hoping that you will keep this series up till everything (and I mean latterly everything) is explained. I think up to now there such a nice read because you are have written them in an understandable way!

    P.s. Did you notice that the picture (Under IP Command in Linux) fanned out to a format from 38.69 cm and with doing so blocked the advertisement part on the left side?

    1. Paul(us) said on April 15, 2018 at 12:14 pm
      Reply

      Not fanned out to the left side (like I wrought earlier) but the right side and by doing so blocking the (right! :-) ) side advertisements.

      Hopefully, Martin will get the correcting possibility up and running again.

  3. P said on April 15, 2018 at 7:49 pm
    Reply

    Thanks! I need to bring my linux skills up to date.

  4. sunscribe said on April 15, 2018 at 10:48 pm
    Reply

    Enjoyed it, thanks.
    In case you want to get your DHCP-issued address back after experimenting:

    dhclient interface_name -v

  5. John Fenderson said on April 16, 2018 at 7:12 pm
    Reply

    “ifconfig is long dead, and has since been replaced with the IP tool”

    What, ifconfig is long dead? I use it every single day (as well as ip). It sure seems alive to me!

Leave a Reply

Check the box to consent to your data being stored in line with the guidelines set out in our privacy policy

Please note that your comment may not appear immediately after you post it.