这里直接给出脚本以及运行的效果图,主要推断了一下cdn然后能够直接过滤url。默认就是dig +域名 +short。
脚本qdig(随便能够取一个名字)例如以下:
#!/usr/bin/env bash
c=$(echo $1 | awk -F '://' '{print $1}')
if [ "$c" = "http" ] || [ "$c" = "https" ]; then
b=$(echo $1 | awk -F '://' '{print $2}' | awk -F '/' '{print $1}')
fi
if [ "$c" != "http" ] && [ "$c" != "https" ]; then
b=$(echo $1 | awk -F '/' '{print $1}')
fi
a=$(dig $b +short)
if [ "$a" = "" ]; then
echo ""
echo 'dig' $b '+short'
echo '域名还没有进行cname'
exit 1
else
echo ""
echo 'dig' $b '+short'
echo "$a"
echo ""
echo "$a" | awk -F "." '{if($(NF-2)=="wscdns"||$(NF-2)=="ourglb0"||$(NF-2)=="cdn20"||$(NF-2)=="lxdns"||$(NF-2)=="ourwebcdn"){print "网宿"}}'
echo "$a" | awk -F "." '{if($(NF-2)=="cdnga"||$(NF-2)=="cdngc"||$(NF-2)=="cdnetworks"||$(NF-2)=="gccdn"){print "同兴"}}'
echo "$a" | awk -F "." '{if($(NF-2)=="fastcdn"||$(NF-2)=="tlgslb"){print "帝联"}}'
echo "$a" | awk -F "." '{if($(NF-2)=="ccgslb"){print "蓝汛"}}'
echo "$a" | awk -F "." '{if($(NF-2)=="qingcdn"){print "白山"}}'
echo "$a" | awk -F "." '{if($(NF-2)=="hadns"||$(NF-2)=="cloudcdn"||$(NF-2)=="hacdn"||$(NF-2)=="fastwebcdn"||$(NF-2)=="cloudglb"){print "快网"}}'
echo "$a" | awk -F "." '{if($(NF-2)=="cdntip"||$(NF-2)=="qq"||$(NF-2)=="dnsv1"){print "腾讯"}}'
echo "$a" | awk -F "." '{if($(NF-2)=="lecloud"||$(NF-2)=="letv"||$(NF-2)=="leletv"){print "乐视"}}'
fi
完毕后将qdig增加环境变量。运行效果例如以下qdig链接和qdig域名效果一样:
~/tools » qdig http://static.alphadn.com/xxx/xxx.jpg
dig static.alphadn.com +short
7fv9ur3h.https.z0.glb.qiniudns.com.
static.alphadn.com.cloudglb.com.
c06.i06.ctljs.lv3.cloudglb.com.
222.186.20.123
222.186.20.109
58.220.2.10
58.220.2.124
快网
快网