Start a STUN server in one of various modes of operation using any of
the [OPTION]s described below:
NAME
stunserver - STUN protocol service (RFC 5389 and RFC 3489)
Available options:
--mode=MODE
Where MODE is either "basic" or "full". In basic mode, the server only listens on one port and does not support STUN CHANGE requests. In full mode, the STUN service listens on two different interfaces and two different ports on each. A client binding request may specify an option for the server to send the response back from one of the alternate interfaces and/or ports. Basic mode is sufficient for basic NAT traversal. Full mode facilitates clients attempting to determine NAT behavior and NAT filtering behavior. Full mode requires two unique network interfaces with different IP addresses. Full mode does not work with TCP or TLS, only UDP. If this parameter is not specified, basic mode is the default.
SYNOPSIS
stunserver [OPTIONS]
--primaryinterface=INTERFACE or IPADDRESS
The value for this option may the name of an interface (such as "eth0" or "lo"). Or it may be one of the available IP addresses assigned to a network interface present on the host (such as "128.23.45.67"). The interface chosen will be used by the service as the primary listening address in either full or basic mode. In basic mode, the default primary interface is ALL adapters (socket binds to INADDR_ANY). In full mode, the service binds to the the first non-localhost interface that in the UP state with a valid IP Address.
DESCRIPTION
stunserver starts a STUN listening service that responds to STUN binding requests from remote clients. Options are described below.
--altinterface=INTERFACE OR IPADDRESS
Same as the --primaryinterface option, except this option's value specifies the listening address for the alternate address in full mode. It has no meaning in basic mode nor does it have meaning in when TCP or TLS is the listening protocol. In full mode, the service will bind to the the second non-localhost interface that is in the UP state with a valid IP address.
OPTIONS
The following options are supported.
--mode MODE
--primaryinterface INTERFACE
--altinterface INTERFACE
--primaryport PORTNUMBER
--altport PORTNUMBER
--family IPVERSION
--protocol PROTO
--maxconn MAXCONN
--help
Details of each option are as follows.
--mode MODE
Where the MODE parameter specified is either "basic" or "full".
In basic mode, the server listens on a single port. Basic mode is sufficient for basic NAT traversal scenarios in which a client needs to discover its external IP address and obtain a port mapping for a local port it is listening on. The STUN CHANGE-REQUEST attribute is not supported in basic mode.
In full mode, the STUN service listens on two different interfaces and two different ports on each. A client binding request may specify an option for the server to send the response back from one of the alternate interfaces and/or ports. Full mode facilitates clients attempting to discover NAT behavior and NAT filtering behavior of the network they are on. Full mode requires two unique IP addresses on the host. When run over TCP, the service is not able to support a CHANGE-REQUEST attribute from the client.
If this parameter is not specified, basic mode is the default.
--primaryinterface INTERFACE
Where INTERFACE specified is either a local IP address (e.g."192.168.1.2") of the host or the name of a network interface (e.g. "eth0").
The interface or address specified will be used by the service as the primary listening address.
In basic mode, the default is to bind to all available adapters (INADDR_ANY). In full mode, the default is to bing to the first non-localhost adapter with a configured IP address.
--altinterface INTERFACE OR IPADDRESS
Where INTERFACE specified is either a local IP address (e.g. "192.168.1.3") of the host or the name of a network interface (e.g. "eth1").
This parameter is nearly identical as the --primaryinterface option except that it specifies the alternate listening address for full mode.
This option is ignored in basic mode. In full mode, the default is to bind to the second non-localhost adapter with a configured IP address.
--primaryport PORTNUM
Where PORTNUM is a value between 1 to 65535.
This is the primary port the server will bind to for listening for incoming binding requests. The service will bind both the primary address and the alternate address to this port.
--primaryport=PORTNUM
PORTNUM is a value between 1 to 65535. This is the UDP or TCP port that the primary and alternate interfaces listen on as the primary port for binding requests. The default is 3478 for UDP and TCP. For TLS it is 5349.
The default is 3478.
--altport=PORTNUM
PORTNUM is a value between 1 to 65535. This is the UDP or TCP port that the primary and alternate interfaces listen on as the alternate port. The default is 3479. It has no meaning in basic mode.
--altport PORTNUM
Where PORTNUM is a value between 1 to 65535.
--family=IPVERSION
IPVERSION is either "4" or "6" to specify the usage of IPV4 or IPV6. If not specified, the default value is "4".
This is the alternate port the server will bind to for listening for incoming binding requests. The service will bind both the primary address and the alternate address to this port.
--protocol=PROTO
PROTO is either "udp" or "tcp". "udp" is the default.
This option is ignored in basic mode. The default is 3479.
--maxconn=MAXCONN
MAXCONN is a value between 1 and 100000. The default is 1000. This value specifies the maximum number of simultaneous TCP connections allowed (per thread). It's an ignored parameter when the PROTOCOL option is UDP.
--family IPVERSION
Where IPVERSION is either "4" or "6" to specify the usage of IPV4 or IPV6.
--verbosity=LOGLEVEL
Sets the verbosity of the logging level. 0 is the default (minimal output and logging). 1 shows slightly more. 2 and higher shows even more.
The default family is 4 for IPv4 usage.
--protocol PROTO
Where PROTO is either IP protocol, "udp" or "tcp".
udp is the default.
--maxconn MAXCONN
Where MAXCONN is a value between 1 and 100000.
For TCP mode, this parameter specifies the maximum number of simultaneous connections that can exist at any given time.
This parameter is ignored when the protocol is UDP.
--verbosity LOGLEVEL
Where LOGLEVEL is a value greater than or equal to 0.
This parameter specifies how much is printed to the console with regards to initialization, errors, and network activity. A value of 0 specifies a very minimal amount of output. A value of 1 shows slightly more. A value of 2 shows even more. Specifying 3 will show a lot more.
The default is 0.
--help
Prints this help page
Examples:
stunserver
EXAMPLES
stunserver
With no options, starts a basic STUN binding service on UDP port 3478.
stunserver --mode full --primaryinterface 128.34.56.78 --altinterface 128.34.56.79
Above example starts a dual-host STUN service on the the interfaces identified by the IP address "128.34.56.78" and "128.34.56.79". There are four socket listeners:
stunserver --mode full --primaryinterface 128.34.56.78 --altinterface 128.34.56.79
Above example starts a dual-host STUN service on the the interfaces identified by the IP address "128.34.56.78" and "128.34.56.79". There
are four UDP socket listeners:
128.34.56.78:3478 (Primary IP, Primary Port)
128.34.56.78:3479 (Primary IP, Alternate Port)
128.34.56.79:3478 (Primary IP, Primary Port)
128.34.56.79:3479 (Alternate IP, Alternate Port)
An error occurs if the addresses specified do not exist on the local host running the service.
An error occurs if the addresses specified do not exist on the localhost running the service.
stunserver --mode full --primaryinterface eth0 --altinterface eth1
Same as above, except the interfaces are specified by their names as enumerated by the system. (The "ifconfig" or "ipconfig" command will enumerate available interface names.
builder.AddResponseOriginAddress(addrOrigin,fLegacyFormat);// pass true to send back SOURCE_ADDRESS, otherwise, pass false to send back RESPONSE-ORIGIN
builder.AddResponseOriginAddress(addrOrigin);// pass true to send back SOURCE_ADDRESS, otherwise, pass false to send back RESPONSE-ORIGIN
}
if(fSendOtherAddress)
{
builder.AddOtherAddress(addrOther,fLegacyFormat);// pass true to send back CHANGED-ADDRESS, otherwise, pass false to send back OTHER-ADDRESS
builder.AddOtherAddress(addrOther);// pass true to send back CHANGED-ADDRESS, otherwise, pass false to send back OTHER-ADDRESS
}
// even if this is a legacy client request, we can send back XOR-MAPPED-ADDRESS since it's an optional-understanding attribute