Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Update ChinaDNS IP Address File
if curl -f 'http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest' -o /tmp/chinaip.list; then
cat /tmp/chinaip.list | grep ipv4 | grep CN | awk -F\| '{ printf("%s/%d\n", $4, 32-log($5)/log(2)) }' > /tmp/chinadns_chnroute.txt
if [[ $(wc -l </tmp/chinadns_chnroute.txt) -ge 100 ]]; then
echo '47.89.44.170/32' >> /tmp/chinadns_chnroute.txt
echo '139.162.86.215/32' >> /tmp/chinadns_chnroute.txt
cp /tmp/chinadns_chnroute.txt /etc/chinadns_chnroute.txt
else
echo 'Too few lines. File corrupted?'
fi;
else
echo 'Failed to download China IP addresses'
fi;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment