Raul Dias
2006-Sep-14 07:20 UTC
[asterisk-users] Asterisk and peers behind nat with port forward, how to proxy?
Hi, I have the following 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). When I have a call between the outside world (VOIP provider) and a internal sip peer, I can see that the data transfer (RTP) is between the the VOIP provider and the client (10.0.51.3). That said, the PROBLEM is: After a few seconds (2 to 20) the call becomes mute (but still active). It does not matter which side started the call. For what I understood, shouldnt asterisk (10.0.51.2) work as a proxy for (10.0.51.3), instead of letting it talk directly with the VOIP Provider? I think that this is where the problem is. In sip.conf I have externip set to the router Internet ip address. However as the peer is also behind the nat (10.0.51.3), the voip provider will see the same IP because of nat. But they are different boxes. - Raul Dias
Marcus Carlson
2006-Sep-14 07:43 UTC
[asterisk-users] Asterisk and peers behind nat with port forward, how to proxy?
Hi Raul, Try canreinvite=no in your sip.conf file. Then all calls will go via asterisk. Marcus Raul Dias skrev:> Hi, > > > I have the following 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). > > When I have a call between the outside world (VOIP provider) and a > internal sip peer, I can see that the data transfer (RTP) is between the > the VOIP provider and the client (10.0.51.3). > > > That said, the PROBLEM is: > After a few seconds (2 to 20) the call becomes mute (but still active). > It does not matter which side started the call. > > > For what I understood, shouldnt asterisk (10.0.51.2) work as a proxy for > (10.0.51.3), instead of letting it talk directly with the VOIP Provider? > > I think that this is where the problem is. In sip.conf I have externip > set to the router Internet ip address. However as the peer is also > behind the nat (10.0.51.3), the voip provider will see the same IP > because of nat. But they are different boxes. > > > - Raul Dias > > _______________________________________________ > --Bandwidth and Colocation provided by Easynews.com -- > > asterisk-users mailing list > To UNSUBSCRIBE or update options visit: > http://lists.digium.com/mailman/listinfo/asterisk-users >
Raul Dias
2006-Sep-14 11:58 UTC
[asterisk-users] Asterisk and peers behind nat with port forward, how to proxy?
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