How to find site attribution

Source: Internet
Author: User
Tags nslookup nslookup command

1. Script Usage

Give a URL that automatically gets the URL corresponding to the IP and the IP ownership.

2, script use preparation:

A, nslookup command installation:

Yum Install Nslookup–y

b, with access to public network rights.

3. How to use the script:

[[Email protected]1nidongde]#SHDns.SH-h--------------------------------------------------------------------------------version:v1.0Date:20170614Purpose: DNS, get domain name corresponding IP list and IP attribution address according to Url,nslookup.            Parameter interpretation: no parameters; Query the connectivity of individual IPs eg. SHDns.SHwww.baidu.comSHDns.SHwww.baidu.com/ning.htmlSHDns.SHhttp//www.baidu.com            SHDns.SHHttps//www.baidu.com/            SHDns.SHhttp//www.baidu.com/ning.html-FfileSpecifies the URL list file that resolves all URLs in the file eg. SHDns.SH-F url_list.txt-h help parameter eg. SHDns.SH-h-IP IP address query IP address attribution to eg. SHDns.SH-ip114.114.114.114-l list Lists the DNS lists in use eg. SHDns.SH-L--------------------------------------------------------------------------------

4. Script content:

[[Email protected]1nidongde]# MoreDns.SH #/bin/bash#Date:20170527#zn # Purpose: URL domain resolves all ips and obtains IP attribution #dns list based on IP shell_name=$0dns_list="    114.114.114.114    223.5.5.5    1.2.4.8    112.124.47.27    8.8.8.8    208.67.222.222    61.132.163.68    219.141.136.10    61.128.192.68    218.85.152.99    202.100.64.68    202.96.128.86    202.103.225.68    202.98.192.67    222.88.88.88    219.147.198.230    202.103.24.68    222.246.129.80    218.2.2.2    202.101.224.69    219.148.162.31    219.146.0.130    218.30.19.40    202.96.209.133    61.139.2.69    219.150.32.132    222.172.200.68    202.101.172.35    202.106.196.115    221.5.203.98    210.21.196.6    202.99.160.68    202.102.224.68    202.97.224.69    202.98.0.68    221.6.4.66    202.99.224.68    202.102.128.68    202.99.192.66    221.11.1.67    210.22.70.3    119.6.6.6    202.99.104.68    221.12.1.227"#URL传参正确性判断: The domain name is extracted from the URL and the domain name is correctly judgedfunctionFun_url_check () {if[ `Echo$1|Egrep '^http://|^https://'-c ' = =1]; ThenURL=`Echo$1|awk-f\/'{print $}'`    elif[ `Echo$1|awk-f\/'{print $}'|grep '\.'-c ' = =1]; ThenURL=`Echo$1|awk-f\/'{print $}'`    Else        Echo-E"\e[31m$1 URL Format Error! \e[0m"exit; fiNum=`Echo$URL |WC-C 'if[ `Echo$URL |TR 'a-za-z0-9-'  '.'|grep-O'\.'|WC-l '! = 'Echo$ ($num-1))` ]; Then        Echo-E"\e[31m$1 URL Format Error! \e[0m"exit; fi    Echo-E"\e[31m domain name: \e[32m$url \e[31murl:\e[32m$1\e[0m"} #nslookup解析域名对应IP列表functionfun_ip_list () { forDnsinch$DNS _list DoTimeoutTenNslookup $1$Dns |grep-V $Dns |awk-f\:'/address/{print$2}'& Done} #获取IP归属地functionfun_ip_local () {IP=$1    Echo-ne $IP"\ t"Curl-S"http://ip138.com/ips138.asp?ip=${ip}&action=2"| Iconv-f gb2312-t utf-8|grep "'|grep 'the site data'|awk-F'[<>]' '{print$7}'|awk '{print "\ T" $NF}'} #URL传参正确性判断; Get the IP list of the domain name and IP attribution addressfunctionFun_main () {URL=$1Fun_url_check $URL forIpinch' Fun_ip_list $URL |Sort-u |Sort-T'.'-K1N,1-K2N,2-k3n,3-K4N,4`     Dofun_ip_local $IP Done}if[ $1=='- H']; ThenCat<<EOF--------------------------------------------------------------------------------version:v1.0Date:20170614Purpose: DNS, get domain name corresponding IP list and IP attribution address according to Url,nslookup.            Parameter interpretation: no parameters; Query the connectivity of individual IPs eg. SH$Shell _name www.baidu.comSH$Shell _name www.baidu.com/ning.htmlSH$Shell _name http://www.baidu.com            SH$Shell _name https://www.baidu.com/            SH$Shell _name http://www.baidu.com/ning.html-FfileSpecifies the URL list file that resolves all URLs in the file eg. SH$Shell _name-F url_list.txt-h help parameter eg. SH$Shell _name-h-IP IP address query IP address attribution to eg. SH$Shell _name-ip114.114.114.114-l list Lists the DNS lists in use eg. SH$Shell _name-L--------------------------------------------------------------------------------Eofexitfiif[ $1=='- F']; ThenUrl_file=$2    Cat$URL _file | whileRead URL; DoFun_main $URL Doneelif[ $1=='-ip']; ThenIP=$2fun_ip_local $IPelif[ $1=='- L']; Then    Echo$DNS _list|sed 's//\n/g'|Sort-T'.'-K1N,1-K2N,2-k3n,3-K4N,4ElseURL=$1Fun_main $URLfi

How to find site attribution

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.