DNS Workshop

Wednesday Jan 11, 2012

Give nsupdate a history

the useful nsupdate tool (used to send dynamic updates towards an authoritative DNS server, part of the BIND nameserver distribution, www.isc.org) does not have a commandline history, nor automatic command completion.

Luckily, on Unix systems, this missing feature can be added to nsupdate using a small tool called rlwrap. rlwrap stands for 'readline wrapper'. Readline is an open source library that implements command history and tab completion, and it is used inside many well known command line tools. However it needs to be linked at compile time to be work on a program by default. If the developer does not link readline, the functions are not part of the program.

However it is possible to start a commandline tool such as nsupdate under the control of the readline wrapper. In this case, the readline wrapper will intercept when the command line tool tries to read data from the keyboard and will add the additional readline functions to the command line tool. rlwrap is part of most Unix/Linux distributions and can often be installed using the systems package manager.

In case of nsupdate, we can start nsupdate with

$ rlwrap nsupdate 

and voila, our old dog nsupdate has just learned some new tricks, it has now a command history that can be used with the cursor up and down keys (see the readline man page for a complete list of possible key bindings).

If rlwrap finds a file (named with the name of the commandline tool) containing keywords (space separated) in its search path for completion files (on my system that is /usr/share/rlwrap/completions), it will auto-complete the keywords found in the file when the user presses the tabulator key. Please find attached to this blogpost my completion file for nsupdate.

I don't not want to encourage the usage of nslookup (use dig or drill), but rewrap works also on the old steam engine called nslookup.

Please have a look at the rlwrap manual page. There are some more tricks to rlwrap that are not mentioned in this blog post.

Attachments

Comments:

Very useful.

(May I suggest the tar file contain a relative path to the completion script? :-)

Posted by Jan-Piet Mens on January 11, 2012 at 09:23 AM CET #

Hi Jan-Piet,

valid suggestion, I made it a zip file containing the completion text.

-- Carsten

Posted by Carsten Strotmann on January 11, 2012 at 05:59 PM CET #

From the BIND 9.9.rc1 release notes:

Support for readline has been added to nslookup and nsupdate -
see ./configure for options at build time.

:-)

Posted by Jan-Piet Mens on January 13, 2012 at 08:08 AM CET #

Post a Comment:
  • HTML Syntax: Allowed

Calendar

Feeds

Search

Links

Navigation