secynic / ipwhois

Retrieve and parse whois data for IPv4 and IPv6 addresses
https://ipwhois.readthedocs.io/en/latest
BSD 2-Clause "Simplified" License
555 stars 121 forks source link

Cannot do bulk_whois on '177.104.124.235' #290

Open DolleDries opened 4 years ago

DolleDries commented 4 years ago

Code:

from ipwhois import IPWhois from ipwhois.experimental import get_bulk_asn_whois from ipwhois.experimental import bulk_lookup_rdap from pprint import pprint

ipno = '23.129.64.151'

ipno = '177.104.124.235' IPlist = [ipno] print ipno obj = IPWhois(ipno)

RDAP = obj.lookup_rdap(depth=1) print "Rdap" pprint(RDAP)

WHOIS = obj.lookup_whois() print "WhoIs" pprint(WHOIS)

""" Weird, Bulk-mode does't work on '177.104.124.235'. Why? Are there more IPno's it doen't work on? """

BULK = get_bulk_asn_whois(addresses=IPlist, retry_count=5)

print "Bulk"

pprint(BULK)

RDAP = bulk_lookup_rdap(addresses=IPlist)

print "RDAP"

pprint(RDAP)

print "%s ([%s], %s,%s)" % (ipno, WHOIS['asn_description'], WHOIS['asn_country_code'], WHOIS['asn_cidr'] )

secynic commented 4 years ago

bulk_lookup_rdap returns a named tuple.

Try this: results, stats = bulk_lookup_rdap(['177.104.124.235'])

DolleDries commented 4 years ago

bulk_lookup_rdap returns a named tuple.

Try this: results, stats = bulk_lookup_rdap(['177.104.124.235']) pprint(results)

Well... I kind of did (see att.) Still get an error...

I've got a big list of IPnumbers and it just bails out without telling me why. I had some trouble in finding the problem...

BTW Tis is what I am it using for: http://vandervlies.xs4all.nl/~andre/BAN/

I power my machine down at 00:00 CET and restart is around 09:00 CET

           Andre van der Vlies <andre@vandervlies.xs4all.nl>
           Certifiable Linux/UNIX engineer (CLUE)
           Homepage: http://vandervlies.xs4all.nl/~andre

-- 'Reality is that which, when you stop believing in it, doesn't go away.'

secynic commented 4 years ago

Can you include the output from logging? Put this above your code:

import logging
LOG_FORMAT = ('[%(asctime)s] [%(levelname)s] [%(filename)s:%(lineno)s] '
   '[%(funcName)s()] %(message)s')
logging.basicConfig(level=logging.DEBUG, format=LOG_FORMAT)
DolleDries commented 4 years ago

Can you include the output from logging? Put this above your code:

import logging
LOG_FORMAT = ('[%(asctime)s] [%(levelname)s] [%(filename)s:%(lineno)s] '
   '[%(funcName)s()] %(message)s')
logging.basicConfig(level=logging.DEBUG, format=LOG_FORMAT)

Sure.

-- Andre van der Vlies andre@vandervlies.xs4all.nl Certifiable Linux/UNIX engineer (CLUE) Homepage: http://vandervlies.xs4all.nl/~andre

'Reality is that which, when you stop believing in it, doesn't go away.'
                -  Philip K. Dick
# vim: ts=4 sw=4 ff=unix sm ai ic:

^[^#]

--

DolleDries commented 4 years ago

Can you include the output from logging? Put this above your code:

import logging
LOG_FORMAT = ('[%(asctime)s] [%(levelname)s] [%(filename)s:%(lineno)s] '
   '[%(funcName)s()] %(message)s')
logging.basicConfig(level=logging.DEBUG, format=LOG_FORMAT)

Sorry, I tried to catch the output with: python trywhois.py 2>&1 >Barf

But didn't succeed??? (need to to dive in the logging module...)

This what I see on screen: . . . [2020-09-29 11:17:50,391] [DEBUG] [experimental.py:72] [get_bulk_asn_whois()] ASN bulk query initiated. Traceback (most recent call last): File "trywhois.py", line 32, in BULK, stats = get_bulk_asn_whois(addresses=IPlist, retry_count=5) File "/usr/local/lib/python2.7/dist-packages/ipwhois/experimental.py", line 110, in get_bulk_asn_whois raise ASNLookupError('ASN bulk lookup failed.') ipwhois.exceptions.ASNLookupError: ASN bulk lookup failed.

-- Andre van der Vlies andre@vandervlies.xs4all.nl Certifiable Linux/UNIX engineer (CLUE) Homepage: http://vandervlies.xs4all.nl/~andre

'Reality is that which, when you stop believing in it, doesn't go away.'
                -  Philip K. Dick
# vim: ts=4 sw=4 ff=unix sm ai ic:

^[^#]

--

DolleDries commented 4 years ago

Can you include the output from logging? Put this above your code:

import logging
LOG_FORMAT = ('[%(asctime)s] [%(levelname)s] [%(filename)s:%(lineno)s] '
   '[%(funcName)s()] %(message)s')
logging.basicConfig(level=logging.DEBUG, format=LOG_FORMAT)

Ah! script will do it.... (Not fully awake yet...)

-- Andre van der Vlies andre@vandervlies.xs4all.nl Certifiable Linux/UNIX engineer (CLUE) Homepage: http://vandervlies.xs4all.nl/~andre

'Reality is that which, when you stop believing in it, doesn't go away.'
                -  Philip K. Dick
# vim: ts=4 sw=4 ff=unix sm ai ic:

^[^#]

--

secynic commented 4 years ago

I'm going to use this issue to provide the original error message on line 110 in get_bulk_asn_whois.

Is outbound port 43/TCP enabled for you? Can you hit whois.cymru.com:43?

DolleDries commented 4 years ago

I'm going to use this issue to provide the original error message on line 110 in get_bulk_asn_whois.

Is outbound port 43/TCP enabled for you? Can you hit whois.cymru.com:43?

telnet whois.cymru.com 43 Trying 38.229.36.132... Connected to v4.whois.cymru.com. Escape character is '^]'.

Is this wgat you want? Or should I use http?

-- Andre van der Vlies andre@vandervlies.xs4all.nl Certifiable Linux/UNIX engineer (CLUE) Homepage: http://vandervlies.xs4all.nl/~andre

'Reality is that which, when you stop believing in it, doesn't go away.'
                -  Philip K. Dick
# vim: ts=4 sw=4 ff=unix sm ai ic:

^[^#]

--