[asterisk-users] Asterisk and peers behind nat with port forward, how to proxy?

Raul Dias raul at dias.com.br
Thu Sep 14 11:56:40 MST 2006


Hi Marcus,

On Thu, 2006-09-14 at 16:43 +0200, Marcus Carlson wrote:
> Try canreinvite=no in your sip.conf file. Then all calls will go via 
> asterisk.

this solved the "proxy" problem.
Now I can see in the logs that all connections goes thru asterisk.

The calls are up to 1 ~ 2 minutes, but they still mute after that.

Continuing with my setup:

> >             [ Voip Provider ] ------ (XX) XXXX-XXXX 
> >                  x.x.x.x         (real world phone number)
> >                     |
> >             { The Internet }
> >                     |
> >           200.x.x.x (Internet IP)
> >              [linux router]
> >                 10.0.51.1
> >                     |
> >         ------------------------- -> (The Lan)
> >         |                       |
> > [sip peer 1/client]     [asterisk server]
> >      10.0.51.3              10.0.51.2
> >
> >
> > The linux router does Nat/firewall for The Lan.
> > sip clients inside the Lan can talk to each other (and asterisk) fine.
> >
> > The router has port forwarding for IAX[2], SIP, RTP (10000-20000) and
> > MGCP to the asterisk box (10.0.51.2).

My setup is pretty much the sample config with little things altered.

This is the source asterisk 1.2.12.  I compiled and packaged (rpm) it
myself.  No patch or addon package added (like sounds, addons, festival
and so forth).

Commented options are not included.
--------In extension.conf:----------
[general]
static=yes
writeprotect=no
autofallthrough=yes
clearglobalvars=no
priorityjumping=no

[globals]
CONSOLE=Console/dsp
IAXINFO=guest
TRUNK=Zap/g2 
TRUNKMSD=1

[from-external]
exten => s,1,Answer
exten => s,2,Wait(2)
exten => s,3,Background(swi/swi)
exten => s,4,Goto(from-external,s,1) ; This is for debugging
; Voip line1 (more testing)
exten => voip,1,Goto(from-external,s,1)
; Internal Peers
#include swi-ramais.conf

; internal use
[internal]
exten => s,1,Answer()   ; Make sure we have ansered the call, Playback
will do it,
                        ; but we need to ensure the 2s Wait
exten => s,2,Wait(2)    ; Wait 2s for a SIP session stablish
;welcome title
exten => s,3,Playback(swi/info)
; internal peers
#include swi-ramais.conf
exten => _9NXXXXXXX,1,Dial(SIP/voip1/${EXTEN:1})
----------->8-------------------


-------------- Now in my sip.conf: -------------------
[general]
context=default
allowguest=no
realm=swi
bindport=5060
bindaddr=0.0.0.0
srvlookup=yes
tos=lowdelay 
externip=<external NAT ip 200.x.x.x>
register=<user>:<pass>@voip.net.br:5060/voip1

[voip1]
username=<user>
type=peer
secret=<pass>
port=5060
insecure=very
host=voip.net.br
fromuser=<user>
fromdomain=voip.net.br
dtmfmode=rfc2833
disallow=all
context=from-external
allow=ilbc
allow=alaw
allow=g729
canreinvite=no ; add to keep asterisk owning the call

;internal peers
[peer1]
context=internal
type=friend
secret=<some pass>
host=dynamic
; more just like above
------------------------>8-------------------------------

If this is enough, I can paste the full debug with "sip debug" activated
or even paste the sniffing result with ethereal (if necessary).

I just dont want to flood the list unnecessary.


- Raul Dias







More information about the asterisk-users mailing list