net-tools to iproute cheat sheet
This is also known as: "ifconfig is not installed by default
anymore, how do I do this only with the ip command?"
I have been slowly training my brain to use the new commands but I
sometimes forget some. So, here's a couple of equivalence from the old
package to net-tools the new iproute2, about 10 years late:
net-tools |
iproute2 |
shorter form | what it does |
|---|---|---|---|
arp -an |
ip neighbor |
ip n |
|
ifconfig |
ip address |
ip a |
show current IP address |
ifconfig |
ip link |
ip l |
show link stats (up/down/packet counts) |
route |
ip route |
ip r |
show or modify the routing table |
route add default GATEWAY |
ip route add default via GATEWAY |
ip r a default via GATEWAY |
add default route to GATEWAY |
route del ROUTE |
ip route del ROUTE |
ip r d ROUTE |
remove ROUTE (e.g. default) |
netstat -anpe |
ss --all --numeric --processes --extended |
ss -anpe |
list listening processes, less pretty |
Another trick
Also note that I often alias ip to ip -br -c as it provides a
much prettier output.
Compare, before:
anarcat@angela:~> ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host noprefixroute
valid_lft forever preferred_lft forever
2: wlan0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
link/ether xx:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff permaddr xx:xx:xx:xx:xx:xx
altname wlp166s0
altname wlx8cf8c57333c7
4: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
link/ether xx:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff
inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
valid_lft forever preferred_lft forever
20: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether xx:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff
inet 192.168.0.108/24 brd 192.168.0.255 scope global dynamic noprefixroute eth0
valid_lft 40699sec preferred_lft 40699sec
After:
anarcat@angela:~> ip -br -c a
lo UNKNOWN 127.0.0.1/8 ::1/128
wlan0 DOWN
virbr0 DOWN 192.168.122.1/24
eth0 UP 192.168.0.108/24
I don't even need to redact MAC addresses! It also affects the display of the other commands, which look similarly neat.
Also imagine pretty colors above.
Finally, I don't have a cheat sheet for iw vs iwconfig (from
wireless-tools) yet. I just use NetworkManager now and rarely have
to mess with wireless interfaces directly.
Background and history
For context, there are traditionally two ways of configuring the network in Linux:
- the old way, with commands like
ifconfig,arp,routeandnetstat, those are part of the net-tools package - the new way, mostly (but not entirely!) wrapped in a single
ipcommand, that is the iproute2 package
It seems like the latter was made "important" in Debian in 2008,
which means every release since Debian 5 "lenny"
has featured the
ip command.
The former net-tools package was demoted in December 2016 which
means every release since Debian 9 "stretch" ships without an
ifconfig command unless explicitly requested. Note that this was
mentioned in the release notes in a similar (but, IMHO, less
useful) table.
(Technically, the net-tools Debian package source still indicates it
is Priority: important but that's a bug I have just filed.)
Finally, and perhaps more importantly, the name iproute is hilarious
if you are a bilingual french speaker: it can be read as "I proute"
which can be interpreted as "I fart" as "prout!" is the sound a fart
makes. The fact that it's called iproute2 makes it only more
hilarious.
You can use your Mastodon account to reply to this post.