Use pystun to obtain the NAT type and public IP address of the LAN

Source: Internet
Author: User

Use pystun to obtain the NAT type and public IP address of the LAN

Pystun is a STUN client tool used to obtain the NAT type and public IP address of the LAN.
A Python STUN client for getting NAT type and external IP (RFC 3489)


Pystun: https://pypi.python.org/pypi/pystun
Download the source code: pystun-0.1.0.tar.gz for pystun to this address

The following describes how to install pystun on Linux. First, you must confirm that Python is installed.
1. Decompress pystun-0.1.0.tar.gz
[Root @ localhost] # tar-xzvf pystun-0.1.0.tar.gz
2. Go to the source code directory and run the installation command.
[Root @ localhost] # pystun-0.1.0 cd
[Root @ localhost pystun-0.1.0] # python setup. py install
Traceback (most recent call last ):
File "setup. py", line 2, in <module>
From setuptools import setup, find_packages
ImportError: No module named setuptools

If the above "ImportError: No module named setuptools" error occurs, install python-setuptools.
[Root @ localhost pystun-0.1.0] # yum-y install python-setuptools
......
Installed:
Python-setuptools.noarch 0: 0. 6.10-3. el6

Complete!

After successfully installing setuptools, run the installation command in step 2:
[Root @ localhost pystun-0.1.0] # python setup. py install
Running install
......
Installed/usr/lib/python2.6/site-packages/pystun-0.1.0-py2.6.egg
Processing dependencies for pystun = 0.1.0
Finished processing dependencies for pystun = 0.1.0

3. Install pystun now. Run pystun to check whether the NAT type and public IP address can be obtained.
[Root @ localhost pystun-0.1.0] # pystun
Traceback (most recent call last ):
......
ImportError: No module named argparse

If the above "ImportError: No module named argparse" error occurs, install argparse as follows:
[Root @ localhost pystun-0.1.0] # easy_install argparse
Searching for argparse
......
Installed/usr/lib/python2.6/site-packages/argparse-1.4.0-py2.6.egg
Processing dependencies for argparse
Finished processing dependencies for argparse

Install argparse and run pystun to obtain the NAT type and public IP address.
[Root @ localhost pystun-0.1.0] # pystun
NAT Type: Restric NAT
External IP: 119.165.58.156
External Port: 54320

Success!

This article permanently updates the link address:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.