SIP+NAT Problem

Hi,

I have trouble to login sip hard phone with asterisk. My astreisk server is behind Nat router and my sip hard phone is also behind other Nat Router.

Layout

sip phone -> localnet - Nat Roter -> Internet -> Nat Roter -> asterisk

My configuration are

sip.conf

externip=xxxxx
localnet=xxxxx
nat=yes
canreinvite=no
qualify=yes

[111]
type =frined
host=dynamic
username=111
secret=111
nat=yes
canreinvite=no
qualify=yes
context=ext-local

My asterisk server debug show nothing and when I set
host=routerip adress
Then sip show peer command show unreacheable and also asterisk debug message 111 unreachable msg on astreisk cli

How I can solve this problem

Adv Thxs

sip is not firewall freindy
you must forward a ton of ports on both ends and you must turn off any firewall SPI (Stateful Packet Inspection)
so to use you need to make your network insecure

for SIP
SIP 5004-5082
RTP 10001-20000

For IAX (and nothing on the client end)
IAX 4569

Thx
I already fwd these udp ports also to my asterisk server and stop my firewall.

Then what coulld be my problem.
Once thing when I give command CLI
sip debug peer xxx
It say unable to get IP address of peer
I have no problem with IAX2.

CLI DEBUG

<-- SIP read from 203.99.51.130:5060:
REGISTER sip:62.189.19.234 SIP/2.0
Via: SIP/2.0/UDP 203.99.51.130:40508;branch=z9hG4bKIlDWgS6ZVvV8s2Ny
Max-Forwards: 70
User-Agent: PA168T V1.50.005 CFG0
From: “55” sip:55@62.189.19.234;tag=jojhgJmiSDK99zUT
To: “55” sip:55@62.189.19.234
Call-ID: 0v52ZBKt7Y7odF3I@10.0.0.98
CSeq: 11 REGISTER
Contact: sip:55@10.0.0.98:5060
Expires: 60
Content-Length: 0

— (11 headers 0 lines)—
Aug 11 11:39:25 DEBUG[28177]: acl.c:211 ast_apply_ha: ##### Testing 203.99.51.130 with 192.168.10.0
Aug 11 11:39:25 DEBUG[28177]: chan_sip.c:1109 ast_sip_ouraddrfor: Target address 203.99.51.130 is not local, substituting externip
Using latest REGISTER request as basis request
Sending to 203.99.51.130 : 40508 (NAT)
Transmitting (NAT) to 203.99.51.130:5060:
SIP/2.0 100 Trying
Via: SIP/2.0/UDP 203.99.51.130:40508;branch=z9hG4bKIlDWgS6ZVvV8s2Ny;received=203.99.51.130
From: “55” sip:55@62.189.19.234;tag=jojhgJmiSDK99zUT
To: “55” sip:55@62.189.19.234
Call-ID: 0v52ZBKt7Y7odF3I@10.0.0.98
CSeq: 11 REGISTER
User-Agent: Asterisk PBX
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY
Max-Forwards: 70
Contact: sip:55@62.189.19.234
Content-Length: 0

Transmitting (NAT) to 203.99.51.130:5060:
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 203.99.51.130:40508;branch=z9hG4bKIlDWgS6ZVvV8s2Ny;received=203.99.51.130
From: “55” sip:55@62.189.19.234;tag=jojhgJmiSDK99zUT
To: “55” sip:55@62.189.19.234;tag=as5dc76b08
Call-ID: 0v52ZBKt7Y7odF3I@10.0.0.98
CSeq: 11 REGISTER
User-Agent: Asterisk PBX
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY
Max-Forwards: 70
Contact: sip:55@62.189.19.234
WWW-Authenticate: Digest realm=“asterisk”, nonce="77112394"
Content-Length: 0

Waiting for your valuable info.

Regards

Satti

What kinds of routers are on both ends? Before you look any further you might want to visit this thread forums.digium.com/viewtopic.php? … ight=drwho