之前做智能dns的时候编写的脚本,现在贴出来,希望对大家有用,注意需要提前汇总下各个地方的dns。
脚本内容如下:
- #!/bin/bash
- #2011/08/01 by larry
- #chown u+x chk_dns.sh
- [ -z "$1" ] && echo "Usage: ./$0 -d domain(required) [-i isp] [-a area] [-h help]" && exit 1
- #Get command options
- Help_DOC='Usage: -h you can find other options.
- -i input telecom operators(CMCC,EDU,CNC,CT,OT,KJW,CNO).
- -a input place name(BJ,SH,GD,HA,HE....).
- -d input domain name(Example:www.domain.com)'
- args=`getopt -o d:i:a:h -l domain:,isp:,area:,help -- $@`
- eval set -- "${args}"
- while :
- do
- case $1 in
- -d|--domain)domain="$2";shift 2;;
- -i|--isp)isp="$2" ;shift 2;;
- -a|--area)area="$2";shift 2;;
- -h|--help)echo "$Help_DOC" && exit 2;shift 2;;
- --)break ;;
- *)echo "Usage: sh $0 --help" && exit 1;;
- esac
- done
- grep -v '^#' /home/lianghq/dns.list |awk '/'${isp}'/&&/'${area}'/{print $4}' | while read line
- do
- place=`awk '/'$line'/{print $3}' /home/lianghq/dns.list`
- #echo -e "==================(\033[36m"$place######$line"\033[0m)=================="
- echo "==================(${place}######${line})=================="
- dig @$line $domain |egrep -v '(^;|^ns|^dns.|^..gtld-servers.net.)'|awk '$4 ~/'A'|'CNAME'/{print}'
- done
自己收集的dns列表如下:
[01] [BJ] CT_BJ 219.141.148.37
[01] [BJ] CT_BJ 219.141.140.10
[01] [BJ] CT_BJ 219.141.136.10
[01] [BJ] CNC_BJ 202.106.196.115
[01] [BJ] CMCC_BJ 211.98.2.4
[02] [CQ] CT_CQ 61.128.252.11
[02] [CQ] CNC_CQ 221.5.213.175
[02] [CQ] EDU_CQ 202.202.0.33
[03] [TJ] CNC_TJ 218.69.254.163
[04] [SH] CT_SH 202.101.6.2
[04] [SH] CNC_SH 112.64.143.101
[05] [XJ] CT_XJ 220.171.12.211
[05] [XJ] CNC_XJ 221.7.1.197
[06] [GX] CT_GX 218.65.250.165
[06] [GX] CNC_GX 221.7.228.140
[07] [XZ] CNC_XZ 221.13.65.38
[08] [NM] CT_NM 123.178.154.18
[09] [NX] CNC_NX 221.199.11.227
[10] [ZJ] CT_ZJ 218.75.28.234
[11] [GD] CT_GD 202.104.245.186
[11] [GD] CNC_GD 210.21.230.58
[11] [GD] EDU_GD 222.16.80.34
[11] [GD] CMCC_GD 211.98.4.1
[12] [HB] CNC_HB 220.249.116.179
[14] [HA] CT_HA 222.85.85.85
[14] [HA] CNC_HA 202.102.224.78
[15] [HL] CT_HL 219.147.219.70
[16] [HN] CNC_HN 58.20.221.214
[16] [HN] CMCC_HN 211.98.71.26
[17] [JL] CNC_JL 202.98.1.11
[18] [JS] CT_JS 202.102.24.34
[18] [JS] CNC_JS 218.104.32.106
[18] [JS] CMCC_JS 221.130.13.232
[19] [JX] CT_JX 202.101.226.68
[20] [LN] CT_LN 219.149.52.3
[20] [LN] CNC_LN 202.96.80.1
[21] [GZ] CT_GZ 202.98.198.170
[21] [GZ] CNC_GZ 221.13.30.242
[21] [GZ] CNC_GZ 221.13.28.234
[22] [QH] CT_QH 125.72.92.166
[23] [SC] CT_SC 202.98.96.68
[23] [SC] CT_SC 61.139.2.69
[23] [SC] CNC_SC 221.10.112.5
[24] [SD] CNC_SD 218.58.74.240
[24] [SD] CNC_SD 202.110.203.13
[25] [FJ] CNC_FJ 218.106.152.69
[26] [SN] CT_SN 61.150.127.242
[27] [SX] CNC_SX 211.90.80.65
[28] [AH] CNC_AH 211.91.88.129
[29] [GS] CT_GS 61.178.89.163
[29] [GS] CNC_GS 221.7.34.238
[30] [HI] CNC_HI 221.11.156.166
[31] [YN] CT_YN 61.166.150.123
[31] [YN] CT_YN 61.138.196.170
[32] [KJW] KJW_1 159.226.8.6
[32] [CNO] CNO_01 220.231.53.200
[32] [CNO] CNO_05 210.13.246.132
[32] [OT] OT_SG 165.21.83.94
[32] [OT] OT_TW 168.95.192.140
[32] [OT] OT_TW 203.133.1.12
[32] [OT] OT_HK 203.80.96.10
[32] [OT] OT_JP 218.219.54.66
[32] [OT] OT_KR 121.254.25.228
[32] [OT] OT_US 8.8.8.8
[32] [OT] OT_US 8.8.4.4
[32] [OT] OT_US 208.67.222.222
[32] [OT] OT_US 208.67.220.220
希望对各位有用。