timeDNS commandlinefu.com
.
This isn't too terribly practical, but it is a good code example of using subshells to run the queries in parallel and the use of an "anonymous function" (a/k/a "inline group") to group i/o.
.
I'm assuming you have already defined your local DNS cache as ${local_DNS}, (here, it's 192.168.0.1).
.
You do need to install `moreutils` to get `sponge`.
.
If you're willing to wait, a slower version w/o sponge, (and w/o sorting), is this:
.
DNS () { for x in "192.168.0.1" "208.67.222.222" "208.67.220.220" "198.153.192.1" "198.153.194.1" "156.154.70.1" "156.154.71.1" "8.8.8.8" "8.8.4.4"; do (echo -n "$x "; dig @"$x" "$*"|grep Query) ; done ; }
$ timeDNS commandlinefu.com 192.168.0.1 ;; Query time: 2 msec 208.67.222.222 ;; Query time: 13 msec 198.153.192.1 ;; Query time: 17 msec 208.67.220.220 ;; Query time: 17 msec 156.154.71.1 ;; Query time: 18 msec 8.8.8.8 ;; Query time: 20 msec 156.154.70.1 ;; Query time: 22 msec 8.8.4.4 ;; Query time: 22 msec 198.153.194.1 ;; Query time: 27 msec
Uses GNU Parallel. Show Sample Output
http://public-dns.info gives a list of online dns servers. you need to change the country in url (br in this url) with your country code. this command need some time to ping all IP in list. Show Sample Output
Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?
You must be signed in to comment.
commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.
Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.
» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10
Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):
Subscribe to the feed for: