SIP & NAT: Why do my settings work?

Hi,

I set up Asterisk behind NAT. SIP-Phones are in the same subnet. It works perfectly with inbound and outbound calls. But why ?
Don’t get me wrong - I love it, but I need to document what I’ve done. Well and now I can’t explain it any more :open_mouth:

Please take a look into my configuration:
sip.conf

[general]
language=de
useragent=Asterisk PBX
bindport=5080
bindaddr=0.0.0.0
disallow=all
disable=all
allow=alaw
allow=ulaw
allow=g729
allow=gsm
allow=slinear
;srvlookup=yes
nat=no
;externhost=asterisk.dyndns.org
;externrefresh=180
;localnet=192.168.178.0/255.255.255.0
host=sipgate.de
;host=217.10.79.9
register=><username>:<pw>@sipgate.de/<username>
canreinvite=no
dtmfmode=rfc2833
;qualify=yes
fromdomain=sipgate.de

[sipgate]
type=peer
insecure=port,invite
nat=yes
username=<username>
fromuser=<username>
fromdomain=sipgate.de
secret=<pw>
host=sipgate.de
qualify=yes
canreinvite=no
dtmfmode=rfc2833
context=sipgate-in

[telefone](!); Template
type = friend
context = meine-telefone
host = dynamic

[200](telefone); Hausmeister
callerid="Hausmeister Krause"<200>
secret = 1234

extensions.conf

[general]
[meine-telefone]
exten=>_0.,1,Dial(SIP/${EXTEN:1}@sipgate)
exten =>_0.,n,Hangup

As you might see, I commented (every?) setting for NAT out.

From which setting does the Asterisk know the routers official (routable) IP address ? I’d also disable any port-forwarding and dyndns in my router.
But it keeps working. What I need to document is a comparison between Asterisk with NAT and without NAT configuration.

Could someone please help me with that ?
Thanks a lot in advance

It works because canreinvite=no. This means that asterisk is bridging both the media (rtp) and control (sip) streams through the server rather than telling them to talk to one another directly.

I presume you have port 5060 & the RTP ports forwarded in to the server form the router? If not then asterisk is being a bit clever somewhere but it does that sometimes.

You usually only need the externhost/externip stuff if you need sip phones the other side of the nat.

Oh thanks for your reply. I will uncomment this line later today and will retry.

BTW: My router is a Fritz!Box and it seems that it’s supporting Full Cone NAT. I think this is also a reason why it’s working. Could that be the case ?

regards