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)
- Cloudflare (DNS)
- OpenDNS (DNS)
- Akamai (HTTP)
Installation
This module can be installed from pypi website
pip install publicaddr
Lookup
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.4.0.tar.gz
(5.4 kB
view hashes)
Built Distribution
Close
Hashes for publicaddr-0.4.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 44480a6365c768920bc17a75a7b5d31c1c8ae7ee2eb7ad2f89a9c98fa80f7129 |
|
MD5 | 197db3b679f069d30f98fb63cf998d08 |
|
BLAKE2b-256 | d37dc0621359168f3ab190bc04603004616dfead13644bc01dfabd15245b4177 |