Skip to main content

Discover external IP addresses and NAT topologies using STUN.

Project description

pypi license

Discover external IP addresses and NAT topologies using STUN (Simple Traversal of UDP Through Network Address Translators).

PyNAT follows RFC 3489, and is inspired by a similar program for Python 2.x called PyStun.

Installation

PyNAT requires Python 3.2 or later.

From PyPI

Install PyNAT by running pip3 install pynat from the command line.

From GitHub

Clone or download the git repo, navigate to the directory, and run:

python3 setup.py sdist
cd dist
pip3 install pynat-<version>.tar.gz

Usage

To get information about the network topology and external IP/port used, run pynat:

Network type: restricted_cone
External IP: 127.0.0.1
External port: 1337

Run pynat -h or pynat --help for more options:

usage: pynat [-h] [--source_ip SOURCE_IP] [--source-port SOURCE_PORT]
             [--stun-host STUN_HOST] [--stun-port STUN_PORT]

PyNAT v0.0.0 Discover external IP addresses and NAT topologies using STUN.
Copyright (C) 2018 Ariel Antonitis. Licensed under the MIT License.

optional arguments:
  -h, --help            show this help message and exit
  --source_ip SOURCE_IP
                        The source IPv4 address to bind to.
  --source-port SOURCE_PORT
                        The source port to bind to.
  --stun-host STUN_HOST
                        The STUN host to use for queries.
  --stun-port STUN_PORT
                        The port of the STUN host to use for queries.

To use PyNAT inside a Python shell or project:

from pynat import get_ip_info
topology, ext_ip, ext_port = get_ip_info()

Development

PyNAT versioning functions on a MAJOR.MINOR.PATCH.[DEVELOP] model. Only stable, non development releases will be published to PyPI. Because PyNAT is still a beta project, the MAJOR increment will be 0. Minor increments represent new features. Patch increments represent problems fixed with existing features.

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

pynat-0.1.0.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

pynat-0.1.0-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file pynat-0.1.0.tar.gz.

File metadata

  • Download URL: pynat-0.1.0.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pynat-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ae6df08efeb04f0776d5dc4bdaf420a441d038c7604fecdcc65d524705c69286
MD5 66ab6be8e4d47515e484c76cfde7da76
BLAKE2b-256 f8552631fd65da9f527f9a3168e8e77a310e0a1b6610add329bddba1fa41846a

See more details on using hashes here.

Provenance

File details

Details for the file pynat-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pynat-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ae85a557aff96200690f186c0b60d907348dd56e3480d8ef580a60aee633dd0f
MD5 0f8a579f917a8b58788cf9f74b5f85ed
BLAKE2b-256 96450970893e043001cafeb5b1fc9ed28c36d05994f3410ff7908563772ea489

See more details on using hashes here.

Provenance

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