Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Monitor top-10000 hosts from different places in the world. Give output of change.
#!/bin/bash
open_dns() {
# Look for open DNS at X.X.Y.Y
parallel -j0 --tag host -t a youtube.com {1}.{1}.{2}.{2} ::: {1..255} ::: {1..255} |
grep 'youtube.com has address' |
perl -pe 's/^(\d+) (\d+)\t.*/$1.$1.$2.$2/'
}
if [ ! -e open_dns_list ] ; then
# Create list of open DNS if it does not exist
open_dns > open_dns_list
fi
if [ ! -e top-1m.csv.zip ] ; then
# Download Alexa list if it does not exist
wget http://s3.amazonaws.com/alexa-static/top-1m.csv.zip
fi
# Unpack top-1m
zcat top-1m.csv.zip |
# Keep only top 10000
head -n10000 |
# Split list on ,
# Retry lookups 10 times if they fail
# Sort output because the order is not significant
# mispipe is needed to get the error code from host
# look up 'a' and 'mx' record
# on all open DNS servers
# save output to new
parallel -j0 -k --tagstring {3}-{1}-{4} --colsep , --retries 10 \
mispipe \"host -t {1} {3} {4}\" sort \
::: a mx \
:::: - \
:::: open_dns_list > new;
# Is there any difference from last run?
diff new old;
# Make this the basis for next run
mv new old
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment