The world evolves
I regularly see "recommendations" to use ifconfig to get interface information in mailing list posts or bug reports and other places. I might even be guilty of it myself. Still, the world of networking has evolved quite a lot since ifconfig was the de-facto standard to bring up a device, check its IP or set an IP.Following some improvements in the kernel and the gradual move to driving network things via netlink; ifconfig has been largely replaced by the ip command.
Running just ip yields the following:
Usage: ip [ OPTIONS ] OBJECT { COMMAND | help }
ip [ -force ] -batch filename
where OBJECT := { link | address | addrlabel | route | rule | neigh | ntable |
tunnel | tuntap | maddress | mroute | mrule | monitor | xfrm |
netns | l2tp | fou | macsec | tcp_metrics | token | netconf | ila }
OPTIONS := { -V[ersion] | -s[tatistics] | -d[etails] | -r[esolve] |
-h[uman-readable] | -iec |
-f[amily] { inet | inet6 | ipx | dnet | mpls | bridge | link } |
-4 | -6 | -I | -D | -B | -0 |
-l[oops] { maximum-addr-flush-attempts } | -br[ief] |
-o[neline] | -t[imestamp] | -ts[hort] | -b[atch] [filename] |
-rc[vbuf] [size] | -n[etns] name | -a[ll] | -c[olor]}
I understand this may look complicated to some people, but the jist of it is to understand that with ip, you interact with objects, and apply some kind of function to it. For example:
ip address show
This is the main command that would be used in place of ifconfig. It will just display the IP addresses assigned to all interfaces. To be precise, it will show you the layer 3 details the interface: the IPv4 and IPv6 addresses, whether it is up, what are the different properties related to the addresses...
Another command will give you details about the layer 2 properties of the interface: its MAC address (ethernet address), etc; even if it is shown by ip address:
ip link show
Furthermore, you can set devices up or down (similar to ifconfig eth0 up or ifconfig eth0 down) simply by using:
ip link set DEVICE up or ip link set DEVICE down
As shown above, there are lots of other objects that can be interacted with using the ip command. I'll cover another: ip route, in another post.
Why is this important?
As time passes, more and more features are becoming easier to use with the ip command instead of with ifconfig. We've already stopped installing ifconfig on desktops (it still gets installed on servers for now), and people have been discussing dropping net-tools (the package that ships ifconfig and a few other old commands that are replaced) for a while now. It may be time to revisit not installing net-tools by default anywhere.
I want to know about your world
Are you still using one of the following tools?
/bin/netstat (replaced by ss, for which I'll dedicate another blog post entirely)
/sbin/ifconfig
/sbin/ipmaddr (replaced by ip maddress)
/sbin/iptunnel
/sbin/mii-tool (ethtool should appropriately replace it)
/sbin/nameif
/sbin/plipconfig
/sbin/rarp
/sbin/route
/sbin/slattach
If so and there is just no alternative to using them that comes from iproute2 (well, the ip or ss commands) that you can use to do the same, I want to know about how you are using them. We're always watching for things that might be broken by changes; we want to avoid breaking things when possible.
8 comments:
I added alias ip='ip -c' to my .bashrc.
It makes the ip output so much more readable
I still use ifconfig/netstat/route quite extensively. Partly because that's what I've grown up using, but also because (at work) I manage non-Linux-but-still-*nix systems - where those commands are pretty much always present, as opposed to the newer but (exclusively Linux?) iproute2 ones.
However the outputs are different enough on each platform that cross-platform scripting isn't really feasible. (Or at least reliable.) We only ever use the "classic" commands when we're on a terminal. :)
Jamie; I agree, I also have extensive muscle-memory that forces me to think before running this or that command. That's why I posted this. It's unfortunate but unavoidable that there are still systems that rely exclusively on ioctls/ifconfig and all of that makes cross-platform scripting hard. That said; there's only so much cross-platform you can do anyway, features quickly don't match up.
Using 'ip', but not particularly happy with it. The default output manages to be both not-very-human- and not-very-machine-readable. Such is progress.
I was still using ifconfig and I am planning on switching to ip. How do I remove bridge link. I am using ubuntu 16.04 server. I have a bridge link lxdbr0 and conjureup0. I wont need these any more. How do I remove then forever?I pasted below my ip links. Appreciate ur help.
1: lo: mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
link/ether 00:15:5d:02:cb:0b brd ff:ff:ff:ff:ff:ff
3: lxdbr0: mtu 1500 qdisc noqueue state DOWN mode DEFAULT group default qlen 1000
link/ether 2e:3b:1d:99:8a:1d brd ff:ff:ff:ff:ff:ff
4: conjureup0: mtu 1500 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
link/ether 32:91:8e:86:fd:67 brd ff:ff:ff:ff:ff:ff
How do I remove bridge link forever. I am using ubuntu 16.04 server. I have a bridge link lxdbr0 and conjureup0. I wont need these any more.
with command ip link delete the links are deleted but the show again after I restart the system.
How do I remove then forever?I pasted below my ip links. Appreciate ur help.
1: lo: mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
link/ether 00:15:5d:02:cb:0b brd ff:ff:ff:ff:ff:ff
3: lxdbr0: mtu 1500 qdisc noqueue state DOWN mode DEFAULT group default qlen 1000
link/ether 2e:3b:1d:99:8a:1d brd ff:ff:ff:ff:ff:ff
4: conjureup0: mtu 1500 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
link/ether 32:91:8e:86:fd:67 brd ff:ff:ff:ff:ff:ff
"ip address show" is so much easier than ifconfig -- not.
I've used ifconfig for almost 40 years, I dont think ip addr show is easier ...
Post a Comment