This project aims to bring the default behavior of Windows' ipconfig
command to Linux.
Stretch Goals
- Implement
/all
- Windows support (for cross-platform app practice)
&ipconfig I've got a busy day tomorrow, so I'm calling it a jam. I had a lot of fun making this, even though some information proved a lot more difficult to acquire than I had anticipated. In addition to being a handy networking info tool, this also turned into my second attempt at a string library. I've spent more time than I'd care to admit chasing down bugs in said library, but I'm almost certain issues are still lurking, so if you see something weird let me know.
Overall, I was really surprised by the Linux APIs. Sometimes they were very straightforward, and other times they were downright strange. It's definitely radically different than Win32, but overall, not a bad experience (though if I continue down this path, I'm really going to need more robust file parsing).
I also have to give a shoutout to CLion. It has to be the best piece of software I've ever used on Linux, I was completely blown away! Still not as plug and play as Visual Studio, but very impressive and easy to use (aside from CMake, ugh).
The code and a compiled binary can be found in the github repo: https://github.com/errorsuccessdev/ipconfig
&ipconfig I don't have any good screenshots for you, because the program looks exactly the same as it did yesterday! The difference is, it's now using my own attempt at a string library. Since I can't make text posts in this channel, I'll leave you all with a screenshot of how that's going 🙂
&ipconfig I now have all of the information I need to gather for each adapter. It's taken several days and a lot of string parsing to get here, so I'm very pleased to have everything displaying properly.
Getting the IPv6 address in particular gave me some trouble. getifaddrs
lists IPv6 addresses as separate interfaces, so I settled on going over the interface list a second time to find the IPv6 version of the interface, and adding that address to the adapter struct. There may be a better approach, but this works for now.
Windows does list adapters that don't have an IPv4 address, but in my first major departure from ipconfig
's formatting, I've decided to omit these since I don't find that information useful.
The other departure from Windows' formatting is the DNS suffix. Getting this on Linux has likewise proven difficult. I've settled on parsing /etc/resolv.conf
for now, but this is a global DNS suffix, and there may be more than one, hence the slight naming difference.
&ipconfig So far, I have the following functionality built out:
ifaddrs
struct/sys/class/net/interface_name/wireless
). Figuring out how that works is definitely on the to do list.ifa_addr
member of the ifaddrs
struct (specifically, inet_ntoa()
). I think rolling my own version if this function would be a good exercise./etc/resolv.conf
. This isn't the cleanest approach, but it does work on my test systems.