STUN: Multiple servers

Colleagues, tell me please, can I specify for Asterisk several stun-servers for a survey?

Sometimes these servers go down, and Asterisk will send a request to the next.
I tried to set how many lines of type ‘stunaddr = XXX’, but the Asterisk takes the value only from the last…

Am I doing something wrong, or can it work with only one stun-server?

I am grateful for the answer on the essence of my question,

chan_sip is deprecated.

stunaddr is single valued.

If you know your net, you don’t need STUN. It just helps the upstream servers a little bit in some cases. Just have a look at what the STUN client is doing.

If you run into connection problems, then the reason likely has nothing to do with STUN.

And what are the alternatives?

I believe that you do not quite understand why I started asking about it.

The asterisk is located behind the router with NAT.
This is not a big problem. I can always specify in ‘externaddr’ its external address.
But this is when the external interface of the router is one.

And in my case there are two of them and they are with different ip-addresses.
When the first network is down, the router automatically switches to the second.

Take your time to start telling me about autonomous systems and dynamic routing protocols. I myself regularly tell students about this.
But in the city where this router is located, providers of such words have never heard.

The best I can do is issue the ‘reload’ command when it becomes clear that the router has switched to another uplink.
In the described case, automatically filling in the ‘Contact:’ and ‘From:’ felds helps a lot.


I think you need to look at what the upstream servers are doing. There is no general rule, but the ones I’ve met recently do not need any special settings for the SIP communication. They always use the connections that start from the local pbx. The only thing to worry about is the timescale of some firewall states, but that also depends on what the upstream trunks are doing and what kind of intermediate traffic they allow (like OPTIONS requests).

When you switch to a different gateway with a different IP, all you need to do is probably to reregister your external trunks and lines as soon as possible. Some routers can inform you about such changes (e.g. pfSense has a callback function that gets called after any firewall filter changes) and that can be used to un- and then register the new outgoing connection on the pbx. That’s easy to do with chan_pjsip, but chan_sip requires to reload the entire sip module, if not Asterisk itself.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.