Skip to main content

Get your own ip address

Project description

getownip - A python script to determine your ip address

Example:

import getownip
print("public IPv4: " + getownip.get(getownip.Public, getownip.IPv4))
print("local IPv6: " + getownip.get(getownip.Local, getownip.IPv6))

To retrieve a local ip address, a default route must exist. Otherwise, None is returned.

When retrieving a public ip address, a random one of a list of servers is accessed. Currently, the following list of servers is used:

service IPv4 IPv6
ipv4.cf yes
icanhazip.com yes yes
ipaddress.com yes
getmyip.dev yes yes
ipinfo.io yes
l2.io yes
my-ip.io yes yes
ident.me yes yes
ifconfig.me yes
ipify.org yes yes
seeip.org yes yes

If one of these services fails to answer, another one will be tried until every service has failed. In this case, the last occurred exception will be thrown.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

getownip-0.0.1.tar.gz (3.2 kB view hashes)

Uploaded Source

Built Distributions

getownip-0.0.1-py3-none-any.whl (4.2 kB view hashes)

Uploaded Python 3

getownip-0.0.1-py2.py3-none-any.whl (4.1 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page