I had a weird situation yesterday when a shell script broke on the machine of colleague. the Script was parsing output from ifconfig, and it would assume that there was no : (colon) after the interface name.

E.g. directly behind the eth0:

eth0      Link encap:Ethernet  HWaddr 08:00:27:da:bb:a9
          inet addr:  Bcast:  Mask:
          inet6 addr: fe80::a00:27ff:feda:bba9/64 Scope:Link

I have confirmed already that the output is different between Distributions, e.g. on CentOS it looks quite different. I was wondering about a good way to version-track code like this. Given a specific Linux distro/version, how can I quickly get to the source code of its ifconfig program? How would I know, when it has changed the last time, or how often it changes?

  • Don't parse ifconfig - it's meant for human consumption. Use something like ip link instead. – Toby Speight Feb 22 '18 at 18:10

On many distros ifconfig is deprecated and replaced by the ip command. On my Centos7.4 ifconfig --version says net-tools 2.10-alpha while on my Ubuntu 16.04 it says net-tools 1.60 / ifconfig 1.42 (2001-04-13).

You can usually get the source for a package by installing {package}-src or some such with the distro's package manager.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.