[asterisk-dev] STUN support idea

Ian Pilcher arequipeno at gmail.com
Sun Oct 30 23:19:02 CDT 2011


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!

-- 
========================================================================
Ian Pilcher                                         arequipeno at gmail.com
"If you're going to shift my paradigm ... at least buy me dinner first."
========================================================================




More information about the asterisk-dev mailing list