Network Control from the Terminal

I grew up in Linux with the ifconfig tool and for whatever reason I can’t remember how to use the newer ip command. I keep losing my references so I am putting it here, mostly for me but if you find it useful, that’s cool too.

History

Around 2009 the debian-devel mailing list announced plans to phase out the net-tools package due to lack of maintenance. In 2018 the legacy net-tools is still around. Although not installed by default, it is still available as net-tools-depreciated in the official repository for openSUSE Leap and Tumbleweed.

I could install those legacy tools… but I think it is time I stop shouting from my front porch for kids to get off my lawn and just take the time to know the new and better tool set. ip is not a drop in replacement for my beloved ifconfig as there are differences but similar enough to get what I want.

Query the Network Interfaces

List interfaces with associated information

ip a

This command is similar to using ipconfig alone

ip -4 a

Same as above but only show IP4 information

ip -6 a

Same as above but only show IP6 information

ip a show [interface name]

This will show only information about a specific interface. You will have to know the specific name. In my case the wireless interface is wlp3s0. Yours may be different.

List the interfaces that are “up”

ip link ls up

This will only show interfaces that are up, maybe not connected but are up and talking

Mix and match commands

Now that you have a few of the basics, you can string more together to give you exactly what you want. In this case, show only the IP4 information on a specific interface

ip -4 a show [interface name]

Modify the Network Interfaces

Not something I do not do very often because I rarely have the need but it’s good to know

Bring up and down an Interface

To bring the interface down

ip link set dev [interface name] down

To bring the interface up

ip link set dev [interface name] up

There are many more advanced features but typically, this is all I need. My systems are all set with dynamic address on my network and devices that need a specific IP, like my printer, have a rule in the router that will assign it a network address.

References

Replacing ifconfig with ip at Linux.com

Debian Devel Mailing Lists

Debian Devel discussion on plans to phase out net-tools

net-tools-deprecated from openSUSE