whatismyudp.c
This is a UDP server that simply responds to any packet with the sender's IP address and port number. Internet users can use this to discover their global IP address/port mapping, so they can attempt NAT traversal for P2P applications. This is a very limited subset of the functionality of the STUN protocol, and is intended to be as simple as possible so that it can be used even with just netcat in a terminal. The response packet format is in ASCII: host " " port "\n"
- the source IP address followed by a space, followed by the source port, followed by a newline. The protocol supports IPv4 and IPv6.
Public deployments:
celehner.com:7777
west.celehner.com:7777
Example session: client runs netcat command, presses enter to send packet, receives reply, and then quits the program:
$ nc -u -p 8888 celehner.com 7777
104.156.229.84 8888
^C
Note: some netcat implementations are IPv4-only, and may have a separate IPv6 version, like netcat6/nc6. Other netcat implementations let you specify one or the other with a -4
/-6
option.