jselbie / stunserver

Version 1.2. This is the source code to STUNTMAN - an open source STUN server and client code by john selbie. Compliant with the latest RFCs including 5389, 5769, and 5780. Also includes backwards compatibility for RFC 3489. Compiles on Linux, MacOS, BSD, Solaris, and Win32 with Cygwin. Windows binaries avaialble from www.stunprotocol.org.
http://www.stunprotocol.org
Apache License 2.0
1.44k stars 349 forks source link

How many host-serevr PC are needed for running the full mode? #58

Open qq765490023 opened 7 months ago

qq765490023 commented 7 months ago

To run the full mode, I need to provide 2 ip addresses, so should I run the same server but on two different server with the same command or just one server computer with two IPs? What is the specifc steps to run full mode?

jselbie commented 7 months ago

Just one server with two IP addresses.

The full command I run on stunprotcol.org is this:

./stunserver --ddp --mode full --family 4 --protocol udp --primaryinterface 172.31.10.101 --altinterface 172.31.10.102 --primaryadvertised 3.135.212.85 --altadvertised 3.132.228.249

jselbie commented 7 months ago

Where --primaryinterface 172.31.10.101 and --altinterface 172.31.10.102 specify the loca IP addresses on that box. And --primaryadvertised 3.135.212.85 and --altadvertised 3.132.228.249 are the corresponding public IP addresses.

jselbie commented 7 months ago

About once a year, on AWS, I have to clumsily revisit how to make an AWS instance with two IP addresses for both IPv4 and IPv6. And Amazon seemingly changes how this is done through their EC2 console each time.

Then I have to get an elastic IP address as well.

qq765490023 commented 7 months ago

Thank you for responding Jselbie, But considering I am not using cloud services, I am still curious if it is feasible to run on two seperate hosts while they have their own public IP respectively. If yes then how? Otherwise, any requirements in terms of the way for obtaining dual-IPs?

jselbie commented 7 months ago

The code does not have have support for chaining two basic-mode servers to logically act as a full mode server. It was something I considered a long time ago adding, but once I learned some rudimentary system administration stuff such that a single NIC machine can have multiple IP addresses, it didn't seem relevant anymore. A handful of security issues to work through as well.

The first thing you need to successfully host a full server mode STUN server is two public IP addresses. They don't have to be on the same sub-net.

You can do any of the following:

What if your environment and network topology? And what are you really trying to do?

For what it's worth, most applications, including WebRTC, really don't need "full mode". Full-mode only exists to complete the specification for enabling clients to determine what their own NAT classification is. But if your client applications follow the ICE methodology of similar, only the basic model of STUN is required.

qq765490023 commented 7 months ago

My purpose is to detect the NAT types of users/clients so that to know in advance about if they can connect each other. Now everything is clear. Thank you sooo much. Have a great day! _

jselbie commented 7 months ago

If you use the ICE methodology for P2P connectivity, the clients will not need to detect their own NAT type. The WebRTC stack is a great starting point for ICE connectivity.

qq765490023 commented 7 months ago

Ya, I agree with you for setting up connections. But at our scenario we use this data to help clients to make decisions as you know Turn Server shall bring in additional latencies.