Using pystun3 (with examples)
Use Case 1: Making a STUN request
pystun3
Motivation: Making a STUN request without any additional arguments will use the default STUN server and source port. This can be useful for quickly obtaining the network address translation (NAT) configuration of your network.
Explanation: The pystun3
command without any arguments will make a STUN request to the default STUN server (stun.1und1.de) using a random source port.
Example Output:
Binding test: success
External IP: xxx.xxx.xxx.xxx
External Port: xxxx
Mapped IP: xxx.xxx.xxx.xxx
Mapped Port: xxxx
In the output, External IP
and External Port
represent the public IP and port from which the STUN request was made, while Mapped IP
and Mapped Port
represent the public IP and port as seen by the STUN server.
Use Case 2: Making a STUN request and specifying the STUN server
pystun3 --stun-host stun.1und1.de
Motivation: In some situations, you may need to specify a specific STUN server to make the request. This could be useful when testing connectivity to a specific STUN server or when the default STUN server is not available.
Explanation: By using the --stun-host
argument followed by the desired STUN server hostname or IP, you can make a STUN request to the specified server.
Example Output:
Binding test: success
External IP: xxx.xxx.xxx.xxx
External Port: xxxx
Mapped IP: xxx.xxx.xxx.xxx
Mapped Port: xxxx
The output will be similar to the previous example, showing the network address translation (NAT) configuration.
Use Case 3: Making a STUN request and specifying the source port
pystun3 --source-port 7932
Motivation: In certain scenarios, you may need to specify the source port used for the STUN request. This could be useful for testing specific port configurations or when dealing with firewalls or network restrictions that only allow certain ports.
Explanation: The --source-port
argument followed by the desired source port number allows you to set a specific source port for the STUN request.
Example Output:
Binding test: success
External IP: xxx.xxx.xxx.xxx
External Port: xxxx
Mapped IP: xxx.xxx.xxx.xxx
Mapped Port: xxxx
The output will display the NAT configuration, similar to the previous examples.