Getting your public IP v4 and v6
Project description
Intro
Simple python module for getting your public IP V4 and V6 from several providers in random mode.
Supported providers:
- Google (DNS & HTTP)
- Cloudflare (DNS)
- OpenDNS (DNS)
- Akamai (DNS & HTTP)
Installation
This module can be installed from pypi website
pip install publicaddr
Lookup for IPv4 and v6
Lookup for your public IPs from random providers.
import publicaddr
publicaddr.lookup()
{'ip4': 'x.x.x.x', 'ip6': 'x:x:x:x:x:x:x:x', 'provider': 'OpenDNS',
'proto': 'DNS', 'duration': '0.037'}
Get IPv4 only
Get your public IPv4 with default provider (Google with DNS protocol).
import publicaddr
publicaddr.get(ipversion=4)
{'ip': 'x.x.x.x', 'duration': '0.025'}
Get IPv6 only
Get your public IPv6 with default provider (Google with DNS protocol).
import publicaddr
publicaddr.get(ipversion=6)
{'ip': 'x:x:x:x:x:x:x:x', 'duration': '0.063'}
Get IP with specific provider
Example to use the provider Cloudflare instead of the default one.
from publicaddr import get, PROVIDER_CLOUDFLARE, IP_V6, PROTO_DNS
myip = get(provider=PROVIDER_CLOUDFLARE, ipversion=IP_V6, ipproto=PROTO_DNS)
{'ip': 'x:x:x:x:x:x:x:x', 'duration': '0.020'}
For developpers
Run test units
python3 -m unittest -v discover tests/
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
publicaddr-0.5.0.tar.gz
(5.9 kB
view hashes)
Built Distribution
Close
Hashes for publicaddr-0.5.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2d86d79a875fc1fd46688527a7f3d444fbf720b65e53cde8f6a8feca3289627f |
|
MD5 | 596aaed16becab648e9fe39dd85d01a5 |
|
BLAKE2b-256 | dd0b950d21789a23119deb38df58d848380606658abeb60070076561142f38b2 |