LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-25-2015, 11:25 AM   #1
ChronicUser
Member
 
Registered: Mar 2015
Posts: 31

Rep: Reputation: Disabled
geoiplookup


Does anyone know how one might pass a list of IP to geoiplookup?

List is either in CIDR notation or in an nmap acceptable format, for example: 10.10.1-10.20-40
 
Old 04-25-2015, 02:52 PM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,700

Rep: Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895
Unless there is some unplublished option there isn't anything in the man pages that indicates it accepts a range of addreses.
 
Old 04-25-2015, 03:01 PM   #3
ChronicUser
Member
 
Registered: Mar 2015
Posts: 31

Original Poster
Rep: Reputation: Disabled
I know I took a look in the man pages as well searched for a way on the net.
What people are saying is that there are some workarounds with xargs but than you really need a list of IP addresses one per a line.

Thought I would post a question here and see if someone else would have some different ideas.

Sadly you came to the same conclusion as me...

O well no big deal. Could you suggest any alternative command line tools that can do the same job but will accept normal formats of IP addresses ( the ones I listed in the first post ).
 
Old 04-25-2015, 04:06 PM   #4
corp769
LQ Guru
 
Registered: Apr 2005
Location: /dev/null
Posts: 5,818

Rep: Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007
Used the following as a reference for the range generation - http://stackoverflow.com/questions/2...f-ip-addresses

Code:
#!/bin/bash

INET_NTOA() {
    local IFS=. num quad ip e
    num=$1
    for e in 3 2 1
    do
        (( quad = 256 ** e))
        (( ip[3-e] = num / quad ))
        (( num = num % quad ))
    done
    ip[3]=$num
    iptemp="${ip[*]}"
    geotemp=$(which geoiplookup)
    echo "$iptemp - $(eval $geotemp "${ip[*]}")"
}

INET_ATON () {
    local IFS=. ip num e
    ip=($1)
    for e in 3 2 1
    do
        (( num += ip[3-e] * 256 ** e ))
    done
    (( num += ip[3] ))
    echo "$num"
}

read -p "Start of IP address range: " ip1
read -p "End of IP address range: " ip2

ip1n=$(INET_ATON $ip1)
ip2n=$(INET_ATON $ip2)

if [[ $ip2n -lt $ip1n ]]; then
    echo "Wrong range: $ip1 - $ip2"
    exit 1;
fi

for ipn in $(seq $ip1n $ip2n)
do
    INET_NTOA $ipn
done
That being said, I slightly edited the one function to do a 'range scan' per say. Of course, modify and have fun with it. Mind you, this is just the simplest bash-script way that I have found. Of course this can be done a few other ways.

Cheers
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Shell script for geoiplookup cmd Hariharan Linux - Software 5 10-14-2010 01:20 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:35 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration