[asterisk-users] How to configure a stun server for a sip peer

Gordon Henderson gordon+asterisk at drogon.net
Fri Apr 27 07:05:01 MST 2007


On Fri, 27 Apr 2007, Marco Ciacci wrote:

> HI all!
> I'm looking for some infos to configure stun server support for a SIP peer.
> I've installed Asterisk 1.4.3, but searching for stun support in chan_sip 
> (sip.conf) i've found nothing, only a "misterious" externip = stun...
> But where i have to put the ip of stun server?
> No infos around Google and forum! :-)

I don't know is 1.4 supports a STUN server, 1.2 doesn't that I'm aware of.

What are you trying to achieve? If it's just asterisk behind NAT, then:

The externip= paramter in sip.conf lets asterisk know what the external IP 
address is, so it can put that in the outgoing SIP headers, and hope that 
incoming packets to that IP address are "magically" forwarded by the 
router. You need nat=yes too.

So, Eg. You have a router which has external facing IP address 1.2.3.4 and 
doing NAT to internal hosts on 192.168.1.x. you put externip=1.2.3.4 in 
the sip.conf file and arrange the router to port-forward incoming 5060 to 
the asterisk box on 192.168.1.x. At the same time, you need to get the 
router to port-forward RTP on 10000-20000 by default to the asterisk box 
too.

Then, external SIP devices use the external IP address 1.2.3.4 and it all 
"just works". (you may have issues if the external SIP devices are behind 
NAT, but that's another issue)

If asterisk supports STUN, then what the external STUN server will do is 
tell asterisk what it's external IP address is. (and maybe some more)

I'm sure there's a good reason for SIP having it's IP address encoded into 
it, but I can't think of one right now )-:

Gordon


More information about the asterisk-users mailing list