The STUN (Simple Traversal of UDP through NATs (Network Address Translation)) server is an implementation of the STUN protocol that enables STUN functionality in SIP-based systems. The STUN server tarball also includes a client API to enable STUN functionality in SIP endpoints. In addition, there is a command line UNIX client and a graphical windows client that check what type of NAT the user is using.
STUN is an application-layer protocol that can determine the public IP and nature of a NAT device that sits between the STUN client and STUN server.
The current version of the code supports most of RFC 3489 except the ability to get OTPs from the server.
Short instructions on setting up STUN server version 0.94
1. Download and compile the source obtained from the above links.
2. The server binary is known as “server”, on the same note the client binary is known as “client”.
3. You must have two IPs bound to the machine that you want to set up the STUN server on or, use two different machines. Preferably, you would set up the STUN server to have the IPs on the local machine through ifconfig.
4. After setting up both IPs, type the following on the command line:
./server -v -h primary-ip -a secondary-ip -b
-v will cause the server to give you verbose output for testing
-b will cause the server to go into the background and not close when you close the shell.
Next, you can test the server by using the client program included called client.
STUN server version 0.94
Usage:
./server -v -h / -h IP_Address -a IP_Address -p port -o port -m mediaport
If the IP addresses of your NIC are 10.0.1.150 and 10.0.1.151, run this program with
./server -v -h 10.0.1.150 -a 10.0.1.151
STUN servers need two IP addresses and two ports, these can be specified with:
-h sets the primary IP
-a sets the secondary IP
-p sets the primary port and defaults to 3478
-o sets the secondary port and defaults to 3479
-b makes the program run in the background
-m sets up a STERN server starting at port m
-v runs in verbose mode
patch to support stund work behind NAT
You can set up STUN server to work on internal network by specifying mapped (natted) external IPs:
-e (patch) sets the primary (e)xternal IP
-s (patch) sets the (s)econdary external IP
Patch also addresses compilation error on x86_64 architecture.