Asterisk behind NAT and Phone also Behind NAT(SIP NAT ISSUE)


I spent much time to solve this work but I am unable to do so. I also post this question but not received exact reply.

I need a asterisk expert who can solve my problem.

My network layout is

Phone -> localnet ->Routerwith NAT->Internet ->Router with Nat ->Localnetwork-asterisk

My sip.conf
externip=my router ip which is also my asterisk public IP
llocalnet=my internetwork number/mask

I set my router behind asterisk on DMZ(open all ports)

but my phone could not log on with asterisk.

asterisk CLI debug show nothing, I think my phone request not touch my asterisk.

How can solve this issue.

lot of thanks


your phone probably needs to either be given an external IP address, or it will need to have a STUN server added to it. i’m guessing that

if you go and download X-lite (it’s a softphone) you can test the STUN server, as it has that capability and would allow you to test that theory.


I have made this test when i give my x-lite phone internal address of asterisk server then my x-lite log on with my asterisk but when I give x-lite external Ip it does not log on.

my x-lite behind one rouer and asterisk behind another router

with regards Satti.

how can your softphone log on to the server if it has a non-routable address? or do you have both the phone and server on the same LAN and just have them behind routers?

here is what i’m talking about, i don’t think you understood.

xlite <–NAT–> router <--------> internet <--------> router <–NAT–> asterisk

the two routers are on DIFFERENT networks, it sounds like you have them on the same network, which may or may not be part of the problem.

now, since xlite can’t tunnel through the NAT, you need to enable STUN so that it can find an external address, so that asterisk knows where to send data to.

there is another thread on a very similar issue, i suggest you go read it:


I have two routers

my asterisk server behind 192.168.1.x router (on DMZ)
my phone behind 10.0.0.x router

I think you understand my question


did you try setting STUN on xlite?

did you read the other thread, which is almost identical to this one?


Now I will try to use stun server, How I can use/set stun server by x-lite.

I have to install stun server in my asterisk server to use stun srver by x-lite


no, you go into the x-lite options, and select the option to use a STUN server. the entry should be prepopulated already, and nothing needs to be installed on your servers.

PLEASE try to read some of the documentation out there before asking questions that are so blatantly obvious - this is all covered in the x-lite user’s guide.


If I well understood, you opened all ports on the firewall of all the routers. Good thing.

But, with a router, you need also to route the port from external IP address to the internal one (the one used by the asterisk pbx).

If you want to register someone connected on public internet to an astersik pbx behind a NAT, you need to open ports but you need also to mention to your router that all infos coming to the registering port will go to a specific internal IP address.


In sip soft phone when I seclet topolgy there is option of stun server having two options:-
o discover server
o use specified server

I select discover server and when i use stun server then I have to give its name.

my sip soft phone error is

Registeration eroor 408: Request Time out

I also forward my sip and rtp ports from router to my local asterisk server ip.

Then what could be solution




when I give command in asterisk CLI
sip debug peer 55
I get message
Unable to get IP address of peer