ipof is thought for shell usage to quickly resolve a name to the IP. There is a similar tool
gethostip which is part of
syslinux, which unfortunately is not able to resolve IPv6.
ipof perhaps is a bit Linux centric, and needs a recent libc.
git clone https://hilbix/misc.git ipof cd ipof/src make sudo cp ipof /usr/local/bin/
ipof heise.de: Just outputs the IP of heise.de. The order is as the IPs are handed out from the library. So you might get different results with different calls.
ipof -a heise.de: Outputs all IPs of heise.de, this shows you all IPs
ipof -6 heise.de: Outputs IPv6 of heise.de (aka. AAAA record)
ipof -4 heise.de: Outputs IPv4 of heise.de (is probably the same as
ipof -a -d heise.de: Outputs resolving dupes, too. I see both IPs 3 times. To understand why you can use following
ipof -a -d -x heise.de: Outputs extended information. Here you can see that the libc resolver tells us different possible protocols to use. This is why disabling dupes checking hands out one IP multiple times.
ipof -- -illegal-.example.com: Usually names do not start with a dash (-). If you fear that this might happen, as possible with shell variables (like
ipof -- "$var") you can use the usual double-hyphen (--).
ipof localhost: It uses the libc resolver which parses
ipof -+: Read from
stdin, disallowing the use of options
ipof -: Read from
stdin, you can switch options by entering the
ipof: Prints all the possible options.
The return value if
ipof is 0 (true) only when all names were successfully resolved. Else it returns 1 (false). This way you can use it naturally in shells.
As you probably will notice,
ipof -adx fails. As it was written for brevity it has no option parser, instead it just interprets the arguments as they come, and if they start with a dash (-) they are swallowed if they are a valid option. If not they are resolved. This comes handy in interactive mode, as you can use these options anywhere from
ipof - -h
Options: --> active -h help -? help - read stdin -- end of options --file read file, options on -+[fil] read file, no options -b buffered --> -u unbuffered -p progress --> -n no progress --> -r reset error flag -e set error flag -o set ok -q quiet errors --> -e errors -x extended info --> -i ip info -v verbose --> -s silent -t totally silent --> -c clean dupes -d dupes -a show all addresses --> -1 show single address --> -0 any address format -4 IPv4 address format -6 IPv6 address format
This way you can start it with
ipof - and use it interactively (it does not use readline, though) to resolve hostnames. If you forgot your state, just type
-h and you can see your current settings (the
-q: Errors are no more printed. Normally failures are printed to
stderr. Note that the return value still tells any failure.
-p: Progress indicator. This prints a dot (.) when resolving starts and then another character which shows the outcome (
xfor failure, and so on). If you use it to resolve files you can keep an eye on the progress this way. Perhaps combine with
-v: Prints the resolved hostname in front of the IPs. If
-ais present, all IPs are printed on the same line.
-t: No IPs are printed at all. Similar to
ipof >/dev/nullbut can be switched on and off.
-b: Buffered output, in case you want to spare context switches. By default the output is "unbuffered", this means, the output can be seen as soon as it occurs. Note that this covers the progress, too, so you can buffer the progress until you switch back to "unbuffered" mode with
-dare probably only interesting for debugging purpose.
-+/path/to/filereads a file without allowing options within, just to be sure.
They are read whitespace separated. So any combination of blanks, as domain names usually do not have blanks in it.
It currently only knows IPv4 and IPv6. Other socket families are not yet supported. If you can help with that, you are welcome. (Well, on the paper I am HAM DG8MGV, so it's weird that I cannot support AX25, but currently I do not own any HAM Radio equipment. Sorry.)
It was not tested thoroughly. So there might be other bugs. If you find some, please fix and send a pull request. Eventually I will honor. Perhaps create an
ipof topic branch for this.
It is missing reverse lookup.
"Copyright Less License". This means, not Copyrighted and never Copyrighted. In other words: Free as in Free Beer, Free Speech, Free People and Free Votes.