Stoppt die Vorratsdatenspeicherung! Jetzt klicken &handeln! Willst du auch an der Aktion teilnehmen? Hier findest du alle relevanten Infos und Materialien:
Jump to menu and information about this site.


Useful but Unknown Unix Tools: Calculating with IPs //at 12:22 //by abe

from the juggling-with-netmasks dept.

There are two small CLI tools I need often when I’m handling larger networks or more than a few IP addresses at once:


netmask is very handy for calculating with netmasks (anyone expected something else? ;-) in all variants:

$ netmask
$ netmask -s  
$ netmask --range  (2048)
$ netmask
$ netmask
$ netmask --cisco

(The IP ranges in RFC5737 where too small for the examples I had in mind. :-)

There’s though one thing netmask can’t do out of the box and that’s where the second tool comes into play:


When I read the package name prips, I always think of something like “print postscript” or so, but it’s actually an abbreviation for “print IPs”.

And that’s all it does:

$ prips
$ prips
$ prips -i 2
$ prips -f hex

prips has proven to be very useful in combination with shell loops like these:

$ prips | xargs -n 1 host
$ for ip in `prips`; do host $ip; done

And since prips doesn’t support the netmask syntax, you can even easily combine those two tools:

$ prips `netmask`

(Hah! Now I was able to use RFC5737 IP ranges! ;-)


Re: Useful but Unknown Unix Tools: Calculating with IPs

Posted by: Niall Donegan
Time: Sat, 27 Aug 2011 14:47

"sipcalc" is handy for the IPv6 option. For example to get all the /40s in 2001:DB8::/32 (Yay, I'll get to use RFC3849!!)

sipcalc -S40 2001:DB8::/32

It also has plenty of other useful options for both IPv4 and IPv6.


Re: Useful but Unknown Unix Tools: Calculating with IPs

Posted by: i5513
Time: Sat, 27 Aug 2011 18:24

of course ipcalc is another tool!


Re: Useful but Unknown Unix Tools: Calculating with IPs

Posted by: someguy
Time: Fri, 10 Feb 2017 00:27

Thanks for this post. I didn't know about 'prips'; very useful indeed.


Re: Useful but Unknown Unix Tools: Calculating with IPs

Posted by: Kim
Time: Fri, 03 Sep 2021 16:33

Yes, it's unfortunate that netselect's description implies that it is useful for finding a fast server for apt, when in fact it is mostly useful for finding a low-latency server for something else. --


Your Comment

Spam Protection: To post a comment, you'll have to answer the following question: What is 42 minus 19?

URL or E-Mail: [http://... or] (optional)
Title: (optional)
Spam Protection Answer:

Tag Cloud

2CV, aha, Apache, APT, aptitude, ASUS, Automobiles, autossh, Berlin, bijou, Blogging, Blosxom, Blosxom Plugin, Browser, BSD, CDU, Chemnitz, Citroën, CLI, CLT, Conkeror, CSS, CX, deb, Debian, Doofe Parteien, E-Mail, eBay, EeePC, Emacs, Epiphany, Etch, ETH Zürich, Events, Experimental, Firefox, Fläsch, FreeBSD, Freitagstexter, FVWM, Galeon, Gecko, git, GitHub, GNOME, GNU, GNU Coreutils, GNU Screen, Google, GPL, grep, grml, gzip, Hackerfunk, Hacks, Hardware, Heise, HTML,, IRC, irssi, Jabber, JavaShit, Kazehakase, Lenny, Liferea, Linux, LinuxTag, LUGS, Lynx, maol, Meme, Microsoft, Mozilla, Music, mutt, Myon, München, nemo, Nokia, nuggets, Open Source, OpenSSH, Opera, packaging, Pentium I, Perl, Planet Debian, Planet Symlink, Quiz, Rant, ratpoison, Religion, RIP, Sarcasm, Sarge, Schweiz, screen, Shell, Sid, Spam, Squeeze, SSH, Stoeckchen, Stöckchen, SuSE, Symlink, Symlink-Artikel, Tagging, Talk, taz, Text Mode, ThinkPad, Ubuntu, USA, USB, UUUCO, UUUT, VCFe, Ventilator, Vintage, Wahlen, Wheezy, Wikipedia, Windows, WML, Woody, WTF, X, Xen, zsh, Zürich, ÖPNV


Mo Tu We Th Fr Sa Su

Tattletale Statistics

Blog postings by posting time
Blog posting times this month


Advanced Search


Recent Postings

0 most recent of 0 postings total shown.

Recent Comments

Hackergotchi of Axel Beckert


This is the blog or weblog of Axel Stefan Beckert (aka abe or XTaran) who thought, he would never start blogging... (He also once thought, that there is no reason to switch to this new ugly Netscape thing because Mosaïc works fine. That was about 1996.) Well, times change...

He was born 1975 at Villingen-Schwenningen, made his Abitur at Schwäbisch Hall, studied Computer Science with minor Biology at University of Saarland at Saarbrücken (Germany) and now lives in Zürich (Switzerland), working at the Network Security Group (NSG) of the Central IT Services (Informatikdienste) at ETH Zurich.

Links to internal pages are orange, links to related pages are blue, links to external resources are green and links to Wikipedia articles, Internet Movie Database (IMDb) entries or similar resources are bordeaux. Times are CET respective CEST (which means GMT +0100 respective +0200).

RSS Feeds

Identity Archipelago

Picture Gallery

Button Futility

Valid XHTML Valid CSS
Valid RSS Any Browser
This content is licensed under a Creative Commons License (SA 3.0 DE). Some rights reserved. Hacker Emblem
Get Mozilla Firefox! Powered by Linux!
Typed with GNU Emacs Listed at Tux Mobil
XFN Friendly Button Maker


People I know personally

Other blogs I like or read

Independent News

Interesting Planets

Web comics I like and read

Stalled Web comics I liked

Blogging Software

Blosxom Plugins I use

Bedside Reading

Just read

  • Bastian Sick: Der Dativ ist dem Genitiv sein Tod (Teile 1-3)
  • Neil Gaiman and Terry Pratchett: Good Omens (borrowed from Ermel)

Currently Reading

  • Douglas R. Hofstadter: Gödel, Escher, Bach
  • Neil Gaiman: Keine Panik (borrowed from Ermel)

Yet to read

  • Neil Stephenson: Cryptonomicon (borrowed from Ermel)

Always a good snack

  • Wolfgang Stoffels: Lokomotivbau und Dampftechnik (borrowed from Ermel)
  • Beverly Cole: Trains — The Early Years (getty images)