github.com/mysteriumnetwork/node@v0.0.0-20240516044423-365054f76801/bin/ip_info (about) 1 #!/bin/bash 2 3 # Automate retrieval of IP information 4 # 5 # Usage: 6 # Lookup info of current IP: 7 #> bin/ip2info 8 # 9 # Lookup info of given IP: 10 #> bin/ip2info 216.58.209.110 11 12 IP=$1 13 if [ -z "$IP" ]; then 14 IP=`curl -s "https://api.ipify.org/?format=text"` 15 fi 16 17 REVERSE_IP=`echo $IP | awk -F "." '{print $4"."$3"."$2"."$1}'` 18 19 ASN_INFO=`dig +short $REVERSE_IP.origin.asn.cymru.com TXT` 20 PEER_INFO=`dig +short $REVERSE_IP.peer.asn.cymru.com TXT` 21 22 NUMBER=`echo $ASN_INFO | cut -d'|' -f 1 | cut -d'"' -f 2 | cut -d' ' -f 1` 23 ASN="AS$NUMBER" 24 25 ASN_REPORT=`dig +short $ASN.asn.cymru.com TXT` 26 27 SUBNET=`echo $ASN_INFO | cut -d'|' -f 2` 28 COUNTRY=`echo $ASN_INFO | cut -d'|' -f 3` 29 ISSUER=`echo $ASN_INFO | cut -d'|' -f 4` 30 31 PEERS=`echo $PEER_INFO | cut -d'|' -f 1 | cut -d'"' -f 2` 32 33 REGISTRY_DATE=`echo $ASN_REPORT | cut -d'|' -f 4` 34 REGISTRANT=`echo $ASN_REPORT | cut -d'|' -f 5 | cut -d'"' -f 1` 35 36 # Print tab delimited with headers 37 echo "# Query,Subnet,Registrant,AS Number,Country,Issuer,Registry Date,Peer ASNs" 38 echo -e "$IP\t$SUBNET\t$REGISTRANT\t$ASN\t$COUNTRY\t$ISSUER\t$REGISTRY_DATE\t$PEERS"