I am sure that this solution would work on windows but I am a linux starter and not sure the reliability of ifconfig on linux distros.
ifconfig is part of the net-tools package. The net-tools package is no longer maintained. iproute2 is a new collection of tools intended to replace net-tools.
Two things however:
1. iproute2 was supposed to replace net-tools beginning around the 2.2 kernel release.
2. I have still not seen a linux distribution that doesn't have ifconfig
So, it's taking a long time to abandon net-tools. You're not likely to run into problems relying on ifconfig for quite some time to come. Conversely, your script should anticipate iproute2 for the future. ideally, your script would support both.
Regarding permissions... you do not need root permissions to run ifconfig. With no arguments, ifconfig displays information about the network interfaces--everything you're looking for. You only need root privileges if you want to change
how a network interface is configured (IP address, netmask, etc.). I'm not familiar with the tools in iproute2, but I imagine a non-root user would be able to display network configuration just like with ifconfig.
EDIT: Here's a wikipedia link: ifconfig
. And, though it wasn't meant this way, MS3FGX's comment is anecdotal evidence of how little has happened in switching to iproute2. It's hard to switch when the general population isn't aware that there's supposed to be a switch.