[asterisk-dev] STUN support idea

David Vossel dvossel at digium.com
Mon Oct 31 10:43:46 CDT 2011


----- Original Message -----
> From: "Ian Pilcher" <arequipeno at gmail.com>
> To: asterisk-dev at lists.digium.com
> Sent: Sunday, October 30, 2011 11:19:02 PM
> Subject: [asterisk-dev] STUN support idea
> I am one of many residential Asterisk users who have to deal with NAT
> and a dynamic IP address. I've been looking a res_stun_monitor.c and
> chan_sip.c, and I have an idea for a fairly straightforward (I think)
> enhancement.
> 
> The basic idea is that res_stun_monitor.c would provide the new IP
> address as part of the AST_EVENT_NETWORK_CHANGE event that it creates
> when it detects a change. chan_sip.c would then update the externaddr
> before re-registering. (This seems like it would be a simple addition
> to network_change_event_sched_cb.)
> 
> Is this as simple as it seems? Will I need to do any locking?
> 
> The remaining challenge is to somehow figure out the external IP
> address
> at startup. I could add a separate STUN query to chan_sip, but that
> seems wasteful (not to mention racy). Better to have res_stun_monitor
> generate an event at startup, I think, and somehow defer any SIP
> registrations until that event is processed. Upon reflection, I'll
> also
> have to provide some way for consumers to distinguish a post-startup
> address change from the initial address; should be simple enough to do
> with an IE.
> 
> chan_iax2 is the only other consumer of these events, and it doesn't
> have nearly the NAT-sensitivity that SIP does, right?
> 
> What do people think of this approach? Are there any enormous
> obstacles
> of which I'm unaware?
> 
> (Note that I specifically have no intention of dealing with port
> mapping. Anyone running Asterisk at home should be able to set up
> port forwarding rules in his or her "router".)
> 
> Thanks!
> 

Hey,

res_stun_monitor was primarily developed as a tool that would force registration refreshes anytime a network change occurred that could be detected through stun responses.  This was for people using Asterisk behind a dynamic IP.  The IP changes, and then because Asterisk only re-registers possibly once a day then calls are lost for hours. With stun monitor we can detect the change immediately and re-register early.

What you want to do is a new use case entirely, but I've heard quite a bit of people request this functionality.  As long as we are explicitly setting the port mappings ourselves, and people understand this only resolves the external IP correctly in very specific use cases, then I think this would be a good enhancement that 90% of the people using the sip externip setting would benefit from.

This should be a new option in chan_sip that defaults to off.  Something like, update_extern_addr_on_network_change_event = yes/no... or something shorter if you can think of it.  

-- 
David Vossel
Digium, Inc. | Software Developer, Open Source Software
445 Jan Davis Drive NW - Huntsville, AL 35806 - USA
Check us out at: www.digium.com & www.asterisk.org
The_Boy_Wonder in #asterisk-dev



More information about the asterisk-dev mailing list