IPZcroller

Hi!

During the past year I have on and off worked on a small tool that aims to bring functionally of ip-management systems to a command line interface. It’s to use for operations where you work within headless environments. The idea is to have a quick tool too bring up whenever you deploy any kind of network-related hardware/software that needs to reserve it’s own ip-address and document it.

I have developed a “poc” in M$ Powershell. It doesn’t do anything fancy or even how I feel it should should be done… but the result turned out surprisingly well and it works. What I do is mostly storing ip-addresses in giant strings in csv-files, that I then import and split them up with string.split() into some handy variables.
To present the data in shell I loop through 0 to 255 and print a “constructed” string each time, and whenever the loop finds an “end-point/octet” that is marked it will print available info.
For the presentation to calculate right addresses to display I take total height of shell window with powershells $host and some simple math.
To navigate I also use $host to record key presses and redirect those to a switch.

Here is a screen shot of what it looks like:

Though I’m pretty pleased with my script and it really does what I need it to do, I have tried sometimes now to migrate it to be used on *nix systems or in general to at least be cross platform. But I only feel that I fail over and over. No good results.
The reason for migrating is that I do use Linux as my main OS at home and from my experience, Windows is not even close to utilize headless systems as natural as Linux does. I’m also eager to learn something else other than high-level languages such as C or Rust.
Programs which relies on cli/curses has always appealed to me by its simplicity and speed of use.
As also written above, I do use some cheap tricks to get it all to work… and I feel that even though my computer probably can handle way larger files than what I’ve tested with so far. I want to build something more reliable, efficient and standardized… maybe by using a pure database for the addresses, a better format for syncing against more known IPAMs?

This is why I now seek advice on how to move forward. I’m more used to work in python than powershell but I feel it’s unnecessary to rely on a script engine. I would much rather have it as a small compiled binary so the end-user can use it in any environment desired.
I started looking into Rust and the libraries it has to offer for curses but really came nowhere after 4-5 hours of fiddling around.

So… based on the screen shoot, or by tying it out, how would you go about to make something like this?

You can find the powershell version here:

It might be easier to do using http/html and a little bit of JavaScript than to deal with CLI and terminal emulator voodoo.

If you insist on CLI, I recently saw a talk on how to do some nice stuff, it was at a Go conference, but terminals are terminals regardless of the language: https://youtu.be/3d15R-Nx57c

Another thing to consider is to perhaps look at broadcast traffic and pair up mac addresses with IPs.

Thanks for those tips!
I watched the whole conference presentation, and that is exactly what I’m looking for. Simple ways of controlling the terminal, for displaying data clean and swift. Maybe I have focused too much on using curses?
Go is also the kind of language (system level) that I’m interested in learning.

Have not yet thought about mac addresses, though at my job there has been some moments where we often wished that we had some kind of record for those. Has happened with printers that someone reset and accidentally configured to use dynamic IPs!

Have you used vtysh? This command is ubiquitous because open source switches have adapted quagga and vtysh is an IOS clone that talks to the daemons. There is VAST room for improvement here. I believe most work is going to orchestration, kubernetes and openstack like things, where you use a browser to define a large collection of machines and networks. There isn’t a lot of work on the basic command line, that I know of. If you tear into Open NOSes like Microsoft SONiC, you’ll find a collection of daemons written in python that manage the layers of a switch and communicate through redis pub/sub over localhost, maintaining a network database within Quagga. The Quagga daemons are responsible for managing all of the network devices and most often a BGP network.

So, where am I going with this… this is where [vtysh lives]
(https://github.com/Quagga/quagga/tree/master/vtysh). It uses readline to manage line editing on a terminal. It is not very user friendly, it is very complex, configuring a network device through it almost always involves googling tens or even hundreds examples on the internet. If you could crack this to make it even a tiny bit easier, I’m sure you’d find happy users.

I’m not sure its worthwhile, since the orchestration tools that I mentioned are part of a management stack sold to fortune 500 type clients with massive device fleets. The type of tools they use to manage these typically work on multiple devices at the same time. Vtysh is used to manage a single instance, much like the IOS command line on a Cisco device. Windows and Linux home networks are usually defined through a web browser to a router or through GUIs like NetworkManager. There is another way! vtysh + quagga.

I have not or heard of it before. I tried to grasp what it’s all about but could not really. It looks to me as more of a realtime management tool for BIG networks or even controlcenter of router/switch-configs at some points?

Since I’m actually not an network engineer, I tend to get lost quite quickly and my knowledge stretches mostly to the basic concepts like ipv4, dns, ping, vpn, switch/router and a bit of firewall… So won’t probably use what you posted. But, it is interesting either way and could be fun if someone here, who understands it a bit more and maybe can as you say, extend features of it :wink:

However, I’ve started with some experimentation with Go-lang. I need to correct my self to what I said before that it is a pure system-level language, I have now a much greater understanding of what it is and what it wants to be as a language. I really like it though. It’s tough coming from the scripting world of Python and Powershell but it’s really tempting now to write and clean code, not just for the looks of it, + alot more. maybe goroutine -> ping 256 ips at once and dynamically populate a table?

I have in separate experiments managed to get simple pings working, basic sqlite3 reading from a file and tui with nice selectable rows in a table.

Thanks for all the response so far and I’m really looking forward to show something more complete than what I’ve got now.

1 Like

I was triggered by “command line” networking, probably not the best advice. Carry on. Golang is a reasonable choice, lots of packages are out there, similar to the powershell ecosystem. The “basic” concepts you mention are the most common tasks for an admin.