Quickly look up ownership information about IP addresses
Project description
Objective
A python class to search ip2asn information for matches.
See the pretty documentation over on readthedocs.
Installation
Using pip or pipx:
pipx install ip2asn
Example Usage
setup
ip2asn -f ip2asn.db --fetch
command line
Searching for an address
# ip2asn 8.8.8.8
Address: 8.8.8.8
Numeric ip: 134744072
ASN: 15169
Owner: GOOGLE - Google LLC
Country: US
ip_range: 8.8.8.0 - 8.8.8.255
Searching for an ASN
# ip2asn -a 15169
ASN: 15169
Owner: GOOGLE
Country: US
ip_range: 8.8.4.0 - 8.8.4.255
ASN: 15169
Owner: GOOGLE
Country: US
ip_range: 8.8.8.0 - 8.8.8.255
ASN: 15169
Owner: GOOGLE
...
(google has a lot of registrations)
Displaying a tcpdump / libpcap filter given a address or ASN
# ip2asn -T -a 15169
( net 8.8.4.0/24 or net 8.8.8.0/24 or net 8.35.200.0/21 or ....
Coding
Searching by IP address
import ip2asn
i2a = ip2asn.IP2ASN("ip2asn-v4-u32.tsv")
result = i2a.lookup_address("93.184.216.34")
import pprint
pprint.pprint(result)
Produces:
{'ASN': '15133',
'country': 'US',
'ip_numeric': 1572395042,
'ip_range': [1572394752, 1572396543],
'ip_text': '93.184.216.34',
'owner': 'EDGECAST - MCI Communications Services, Inc. d/b/a Verizon Business'}
Searching by ASN
import ip2asn
i2a = ip2asn.IP2ASN("ip2asn-combined.tsv")
results = i2a.lookup_asn(15169, limit=2) # limit is optional
import pprint
pprint.pprint(results)
``**
**Produces:**
``` text
[{'ASN': '15169',
'country': 'US',
'ip_range': [134743040, 134743295],
'owner': 'GOOGLE - Google LLC'},
{'ASN': '15169',
'country': 'US',
'ip_range': [134744064, 134744319],
'owner': 'GOOGLE - Google LLC'}]
Author
Wes Hardaker, USC/ISI
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ip2asn-1.6.6.tar.gz
(10.0 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
ip2asn-1.6.6-py3-none-any.whl
(12.2 kB
view details)
File details
Details for the file ip2asn-1.6.6.tar.gz.
File metadata
- Download URL: ip2asn-1.6.6.tar.gz
- Upload date:
- Size: 10.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.27.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2b326abc46c8de4874909b4449467a726622e37a8e59cafde42dd92744d2416d
|
|
| MD5 |
e94f842a1bcd5f0531f08f27fea6e256
|
|
| BLAKE2b-256 |
fc7f0340d62710e75a776b748934ffad01f2ab1d16f7473600fde22e8da5bfec
|
File details
Details for the file ip2asn-1.6.6-py3-none-any.whl.
File metadata
- Download URL: ip2asn-1.6.6-py3-none-any.whl
- Upload date:
- Size: 12.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.27.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f15c6d59ad4a8c1fb8986b21ffeb004aa02fac08d736d90397302b19aa7a7d96
|
|
| MD5 |
88bd59cf5f388f70f6c883b48cd0f954
|
|
| BLAKE2b-256 |
a73d16b3283c4669155bd8ccc37f0d22f678f0ffe998068717ddbfa16591def3
|