SIP peer problem

Hi
I have a SIP trunk that i should register on server with my public ip address
my asterisk registered successfully on sip server, but i can’t have outgoing call! and the SIP peer is unreachable!
My sip.conf:

[general]
register => my_sip_user:my_sip_passr@server_ip ~400
localnet= server_ip/255.255.255.255
nat=yes
externip=my_public_ip

[mysipuser]
type=peer
dtmfmode=rfc2833
host=server_ip
user=my_sip_user
secret=my_sip_pass
context=incoming
disallow=all
allow=ulaw
qualify=yes
deny=0.0.0.0/0
permit=server_ip/32
insecure=invite,port

with this configuration, i can see my user status in “sip show registry” => Registered
but in “sip show peers” my user status is UNREACHABLE
incoming call are accepted successfully, but i can’t have outgoing call!

localnet should be something like 192.168.1.0/255.255.255.0. It should not be anything to do with the service provider.

Most people do not need nat=yes.

Most people do not need insecure=port.

You don’t seem to have disabled allowguest.

(Edit: Full address with /32 was OK.)

hi
none of these configurations changes the status!
I set allowguest=no but nothing happened
I configure this sip account on my 3CX softphone, it works perfectly! But in my asterisk some thing is wrong but I don’t find it!

allowguest=no improves security. It doesn’t fix NAT problems.

I think you need to provide a clear a diagram of your network and the output resulting when you use sip set debug on.

My linux connects to internet through a PPPoE connection that gets the public ip address!
The provider provide me a publice ip address as my sip server but i think the real SIP server is behind a firewall!
i enable debug on my peer and get these messages:
SERVER_PUBLIC_IP=> IP address of my provider (i think the ip of provider’s firewall)

Reliably Transmitting (NAT) to SERVER_PUBLIC_IP:5060:
OPTIONS sip:SERVER_PUBLIC_IP SIP/2.0
Via: SIP/2.0/UDP MY_PUBLIC_IP:5060;branch=z9hG4bK1c3509f8;rport
Max-Forwards: 70
From: “asterisk” sip:asterisk@MY_PUBLIC_IP;tag=as120d85fd
To: sip:SERVER_PUBLIC_IP
Contact: sip:asterisk@MY_PUBLIC_IP:5060
Call-ID: 28d3467a5f858e3d5b8da3d44e56eedb@MY_PUBLIC_IP:5060
CSeq: 102 OPTIONS
User-Agent: Asterisk PBX 1.8.7.0
Date: Wed, 18 Jan 2012 08:15:33 GMT
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH
Supported: replaces, timer
Content-Length: 0


<— SIP read from UDP:SERVER_PUBLIC_IP:5060 —>
hello
<------------->
Retransmitting #1 (NAT) to SERVER_PUBLIC_IP:5060:
OPTIONS sip:SERVER_PUBLIC_IP SIP/2.0
Via: SIP/2.0/UDP MY_PUBLIC_IP:5060;branch=z9hG4bK1c3509f8;rport
Max-Forwards: 70
From: “asterisk” sip:asterisk@MY_PUBLIC_IP;tag=as120d85fd
To: sip:SERVER_PUBLIC_IP
Contact: sip:asterisk@MY_PUBLIC_IP:5060
Call-ID: 28d3467a5f858e3d5b8da3d44e56eedb@MY_PUBLIC_IP:5060
CSeq: 102 OPTIONS
User-Agent: Asterisk PBX 1.8.7.0
Date: Wed, 18 Jan 2012 08:15:33 GMT
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH
Supported: replaces, timer
Content-Length: 0


Retransmitting #2 (NAT) to SERVER_PUBLIC_IP:5060:
OPTIONS sip:SERVER_PUBLIC_IP SIP/2.0
Via: SIP/2.0/UDP MY_PUBLIC_IP:5060;branch=z9hG4bK1c3509f8;rport
Max-Forwards: 70
From: “asterisk” sip:asterisk@MY_PUBLIC_IP;tag=as120d85fd
To: sip:SERVER_PUBLIC_IP
Contact: sip:asterisk@MY_PUBLIC_IP:5060
Call-ID: 28d3467a5f858e3d5b8da3d44e56eedb@MY_PUBLIC_IP:5060
CSeq: 102 OPTIONS
User-Agent: Asterisk PBX 1.8.7.0
Date: Wed, 18 Jan 2012 08:15:33 GMT
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH
Supported: replaces, timer
Content-Length: 0


Retransmitting #3 (NAT) to SERVER_PUBLIC_IP:5060:
OPTIONS sip:SERVER_PUBLIC_IP SIP/2.0
Via: SIP/2.0/UDP MY_PUBLIC_IP:5060;branch=z9hG4bK1c3509f8;rport
Max-Forwards: 70
From: “asterisk” sip:asterisk@MY_PUBLIC_IP;tag=as120d85fd
To: sip:SERVER_PUBLIC_IP
Contact: sip:asterisk@MY_PUBLIC_IP:5060
Call-ID: 28d3467a5f858e3d5b8da3d44e56eedb@MY_PUBLIC_IP:5060
CSeq: 102 OPTIONS
User-Agent: Asterisk PBX 1.8.7.0
Date: Wed, 18 Jan 2012 08:15:33 GMT
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH
Supported: replaces, timer
Content-Length: 0


Retransmitting #4 (NAT) to SERVER_PUBLIC_IP:5060:
OPTIONS sip:SERVER_PUBLIC_IP SIP/2.0
Via: SIP/2.0/UDP MY_PUBLIC_IP:5060;branch=z9hG4bK1c3509f8;rport
Max-Forwards: 70
From: “asterisk” sip:asterisk@MY_PUBLIC_IP;tag=as120d85fd
To: sip:SERVER_PUBLIC_IP
Contact: sip:asterisk@MY_PUBLIC_IP:5060
Call-ID: 28d3467a5f858e3d5b8da3d44e56eedb@MY_PUBLIC_IP:5060
CSeq: 102 OPTIONS
User-Agent: Asterisk PBX 1.8.7.0
Date: Wed, 18 Jan 2012 08:15:33 GMT
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH
Supported: replaces, timer
Content-Length: 0


Really destroying SIP dialog ‘28d3467a5f858e3d5b8da3d44e56eedb@MY_PUBLIC_IP:5060’ Method: OPTIONS

<— SIP read from UDP:SERVER_PUBLIC_IP:5060 —>
SIP/2.0 504 Server Time-out
From: “asterisk” sip:asterisk@MY_PUBLIC_IP;tag=as19058109
To: sip:SERVER_PUBLIC_IP;tag=dfdc08cf
CSeq: 102 OPTIONS
Call-ID: 474f05e175209a1a18ca8f64395ddd1f@MY_PUBLIC_IP:5060
Via: SIP/2.0/UDP MY_PUBLIC_IP:5060;branch=z9hG4bK6fda0133;rport=5060
Content-Length: 0

<------------->
— (7 headers 0 lines) —

<— SIP read from UDP:SERVER_PUBLIC_IP:5060 —>
hello
<------------->

There are no REGISTER or INVITE transactions in that trace.

My registration doesn’t have any problem! “show sip registry” shows that my account is “Registered”,I have problem with outgoing calls only! “show sip peers” shows peer "UNREACHABLE"
I just get those messages in a loop!!

The OPTION packets are the result of the qualify option.

You need to have a trace of an INVITE dialogue, and possibly also a REGISTER one, to see which addresses are actually being passed.

Hi
I set qualify= no and enable debug on my peer! I find one other public ip address in logs!!
MY_SIP_USER : my sip trunk user name
PUBLIC_IP1: my public ip address
PUBLIC_IP2: public ip address of provider
PUBLIC_IP3: the new ip address I find it i don’t know where is it!!
These are logs of about 10 minutes:

<— SIP read from UDP:PUBLIC_IP2:5060 —>
SIP/2.0 504 Server Time-out
From: “asterisk” sip:asterisk@PUBLIC_IP1;tag=as53f9153d
To: sip:PUBLIC_IP2;tag=e6842f9e
CSeq: 102 OPTIONS
Call-ID: 6104ea252bf5f4bd08ca42cc2161a25f@PUBLIC_IP1:5060
Via: SIP/2.0/UDP PUBLIC_IP1:5060;branch=z9hG4bK59c4c3fa;rport=5060
Content-Length: 0

<------------->
— (7 headers 0 lines) —

<— SIP read from UDP:PUBLIC_IP2:5060 —>
hello
<------------->

<— SIP read from UDP:PUBLIC_IP2:5060 —>
hello
<------------->

<— SIP read from UDP:PUBLIC_IP2:5060 —>
SIP/2.0 504 Server Time-out
From: “asterisk” sip:asterisk@PUBLIC_IP1;tag=as1c5b4c2d
To: sip:PUBLIC_IP2;tag=de04b3d9
CSeq: 102 OPTIONS
Call-ID: 140f7be164e08cb05f642567681e7627@PUBLIC_IP1:5060
Via: SIP/2.0/UDP PUBLIC_IP1:5060;branch=z9hG4bK77c92927;rport=5060
Content-Length: 0

<------------->
— (7 headers 0 lines) —

<— SIP read from UDP:PUBLIC_IP2:5060 —>
hello
<------------->

<— SIP read from UDP:PUBLIC_IP2:5060 —>
SIP/2.0 504 Server Time-out
From: “asterisk” sip:asterisk@PUBLIC_IP1;tag=as22944c06
To: sip:PUBLIC_IP2;tag=c4080e17
CSeq: 102 OPTIONS
Call-ID: 651090f7788b27643994052f1f25a793@PUBLIC_IP1:5060
Via: SIP/2.0/UDP PUBLIC_IP1:5060;branch=z9hG4bK6e59ed3e;rport=5060
Content-Length: 0

<------------->
— (7 headers 0 lines) —
[Jan 21 01:36:35] NOTICE[24659]: chan_sip.c:12596 sip_reregister: – Re-registration for MY_SIP_USER@PUBLIC_IP2
REGISTER 11 headers, 0 lines
Reliably Transmitting (NAT) to PUBLIC_IP2:5060:
REGISTER sip:PUBLIC_IP2 SIP/2.0
Via: SIP/2.0/UDP PUBLIC_IP1:5060;branch=z9hG4bK293bed5f;rport
Max-Forwards: 70
From: sip:MY_SIP_USER@PUBLIC_IP2;tag=as4f868f66
To: sip:MY_SIP_USER@PUBLIC_IP2
Call-ID: 1226b604535448df1baa1a0a0cf7f938@PUBLIC_IP3
CSeq: 106 REGISTER
User-Agent: Asterisk PBX 1.8.7.0
Authorization: Digest username=“MY_SIP_USER”, realm=“huawei”, algorithm=MD5, uri=“sip:sip:huawei.com”, nonce=“66144d55e6082c3b11654170c03875ff”, response="16a8f2dc9ee6329e87b7ba8a434521bf"
Expires: 400
Contact: sip:s@PUBLIC_IP1:5060
Content-Length: 0


<— SIP read from UDP:PUBLIC_IP2:5060 —>
SIP/2.0 401 Unauthorized
From: sip:MY_SIP_USER@PUBLIC_IP2;tag=as4f868f66
To: sip:MY_SIP_USER@PUBLIC_IP2;tag=6e47ca75
CSeq: 106 REGISTER
Call-ID: 1226b604535448df1baa1a0a0cf7f938@PUBLIC_IP3
Via: SIP/2.0/UDP PUBLIC_IP1:5060;branch=z9hG4bK293bed5f;rport=5060
WWW-Authenticate: Digest realm=“huawei”,nonce=“fa4ae14d4be36ce4694ccbe449ce85eb”,domain=“sip:huawei.com”,stale=false,algorithm=MD5
Content-Length: 0

<------------->
— (8 headers 0 lines) —
esponding to challenge, registration to domain/host name PUBLIC_IP2
REGISTER 11 headers, 0 lines
Reliably Transmitting (NAT) to PUBLIC_IP2:5060:
REGISTER sip:PUBLIC_IP2 SIP/2.0
Via: SIP/2.0/UDP PUBLIC_IP1:5060;branch=z9hG4bK49208ad2;rport
Max-Forwards: 70
From: sip:MY_SIP_USER@PUBLIC_IP2;tag=as1f615d82
To: sip:MY_SIP_USER@PUBLIC_IP2
Call-ID: 1226b604535448df1baa1a0a0cf7f938@PUBLIC_IP3
CSeq: 107 REGISTER
User-Agent: Asterisk PBX 1.8.7.0
Authorization: Digest username=“MY_SIP_USER”, realm=“huawei”, algorithm=MD5, uri=“sip:sip:huawei.com”, nonce=“fa4ae14d4be36ce4694ccbe449ce85eb”, response="87157993fc36756133d40d40dfc81bb1"
Expires: 400
Contact: sip:s@PUBLIC_IP1:5060
Content-Length: 0


<— SIP read from UDP:PUBLIC_IP2:5060 —>
SIP/2.0 200 OK
From: sip:MY_SIP_USER@PUBLIC_IP2;tag=as1f615d82
To: sip:MY_SIP_USER@PUBLIC_IP2;tag=467a4d0a
CSeq: 107 REGISTER
Call-ID: 1226b604535448df1baa1a0a0cf7f938@PUBLIC_IP3
Via: SIP/2.0/UDP PUBLIC_IP1:5060;branch=z9hG4bK49208ad2;rport=5060
Contact: sip:MY_SIP_USER@PUBLIC_IP1:5060;user=phone;expires=400
Content-Length: 0

<------------->
— (8 headers 0 lines) —
Scheduling destruction of SIP dialog ‘1226b604535448df1baa1a0a0cf7f938@PUBLIC_IP3’ in 32000 ms (Method: REGISTER)
[Jan 21 01:36:36] NOTICE[24659]: chan_sip.c:20148 handle_response_register: Outbound Registration: Expiry for PUBLIC_IP2 is 120 sec (Scheduling reregistration in 105 s)

<— SIP read from UDP:PUBLIC_IP2:5060 —>
hello
<------------->

<— SIP read from UDP:PUBLIC_IP2:5060 —>
SIP/2.0 504 Server Time-out
From: “asterisk” sip:asterisk@PUBLIC_IP1;tag=as3789832a
To: sip:PUBLIC_IP2;tag=b12c2ef4
CSeq: 102 OPTIONS
Call-ID: 6773c5120a8ed73602015a5d0092c5b3@PUBLIC_IP1:5060
Via: SIP/2.0/UDP PUBLIC_IP1:5060;branch=z9hG4bK070a56b8;rport=5060
Content-Length: 0

<------------->
— (7 headers 0 lines) —

<— SIP read from UDP:PUBLIC_IP2:5060 —>
hello
<------------->

<— SIP read from UDP:PUBLIC_IP2:5060 —>
SIP/2.0 504 Server Time-out
From: “asterisk” sip:asterisk@PUBLIC_IP1;tag=as4ca08ece
To: sip:PUBLIC_IP2;tag=9e46810d
CSeq: 102 OPTIONS
Call-ID: 4cfe47cb087ba67e303cd8e3238fe77e@PUBLIC_IP1:5060
Via: SIP/2.0/UDP PUBLIC_IP1:5060;branch=z9hG4bK716cef3d;rport=5060
Content-Length: 0

<------------->
— (7 headers 0 lines) —

<— SIP read from UDP:PUBLIC_IP2:5060 —>
hello
<------------->
Really destroying SIP dialog ‘1226b604535448df1baa1a0a0cf7f938@PUBLIC_IP3’ Method: REGISTER

<— SIP read from UDP:PUBLIC_IP2:5060 —>
hello
<------------->

<— SIP read from UDP:PUBLIC_IP2:5060 —>
SIP/2.0 504 Server Time-out
From: “asterisk” sip:asterisk@PUBLIC_IP1;tag=as7e126fe6
To: sip:PUBLIC_IP2;tag=cc860e1d
CSeq: 102 OPTIONS
Call-ID: 0fd982de392690130c0f15827b777ae3@PUBLIC_IP1:5060
Via: SIP/2.0/UDP PUBLIC_IP1:5060;branch=z9hG4bK4ba64af6;rport=5060
Content-Length: 0

<------------->
— (7 headers 0 lines) —

<— SIP read from UDP:PUBLIC_IP2:5060 —>
hello
<------------->

<— SIP read from UDP:PUBLIC_IP2:5060 —>
hello
<------------->

<— SIP read from UDP:PUBLIC_IP2:5060 —>
hello
<------------->

<— SIP read from UDP:PUBLIC_IP2:5060 —>
hello
<------------->

<— SIP read from UDP:PUBLIC_IP2:5060 —>
hello
<------------->

<— SIP read from UDP:PUBLIC_IP2:5060 —>
hello
<------------->
[Jan 21 01:38:21] NOTICE[24659]: chan_sip.c:12596 sip_reregister: – Re-registration for MY_SIP_USER@PUBLIC_IP2
REGISTER 11 headers, 0 lines
Reliably Transmitting (NAT) to PUBLIC_IP2:5060:
REGISTER sip:PUBLIC_IP2 SIP/2.0
Via: SIP/2.0/UDP PUBLIC_IP1:5060;branch=z9hG4bK51298ac5;rport
Max-Forwards: 70
From: sip:MY_SIP_USER@PUBLIC_IP2;tag=as70b002d0
To: sip:MY_SIP_USER@PUBLIC_IP2
Call-ID: 1226b604535448df1baa1a0a0cf7f938@PUBLIC_IP3
CSeq: 108 REGISTER
User-Agent: Asterisk PBX 1.8.7.0
Authorization: Digest username=“MY_SIP_USER”, realm=“huawei”, algorithm=MD5, uri=“sip:sip:huawei.com”, nonce=“fa4ae14d4be36ce4694ccbe449ce85eb”, response="87157993fc36756133d40d40dfc81bb1"
Expires: 400
Contact: sip:s@PUBLIC_IP1:5060
Content-Length: 0


<— SIP read from UDP:PUBLIC_IP2:5060 —>
SIP/2.0 401 Unauthorized
From: sip:MY_SIP_USER@PUBLIC_IP2;tag=as70b002d0
To: sip:MY_SIP_USER@PUBLIC_IP2;tag=3a2f072c
CSeq: 108 REGISTER
Call-ID: 1226b604535448df1baa1a0a0cf7f938@PUBLIC_IP3
Via: SIP/2.0/UDP PUBLIC_IP1:5060;branch=z9hG4bK51298ac5;rport=5060
WWW-Authenticate: Digest realm=“huawei”,nonce=“4c66637a2bcb61fc6f6c78ed550b8f1c”,domain=“sip:huawei.com”,stale=false,algorithm=MD5
Content-Length: 0

<------------->
— (8 headers 0 lines) —
esponding to challenge, registration to domain/host name PUBLIC_IP2
REGISTER 11 headers, 0 lines
Reliably Transmitting (NAT) to PUBLIC_IP2:5060:
REGISTER sip:PUBLIC_IP2 SIP/2.0
Via: SIP/2.0/UDP PUBLIC_IP1:5060;branch=z9hG4bK2c0820a4;rport
Max-Forwards: 70
From: sip:MY_SIP_USER@PUBLIC_IP2;tag=as1374b4d4
To: sip:MY_SIP_USER@PUBLIC_IP2
Call-ID: 1226b604535448df1baa1a0a0cf7f938@PUBLIC_IP3
CSeq: 109 REGISTER
User-Agent: Asterisk PBX 1.8.7.0
Authorization: Digest username=“MY_SIP_USER”, realm=“huawei”, algorithm=MD5, uri=“sip:sip:huawei.com”, nonce=“4c66637a2bcb61fc6f6c78ed550b8f1c”, response="667668a0eb94260d3638e34d0b978a8b"
Expires: 400
Contact: sip:s@PUBLIC_IP1:5060
Content-Length: 0


<— SIP read from UDP:PUBLIC_IP2:5060 —>
SIP/2.0 200 OK
From: sip:MY_SIP_USER@PUBLIC_IP2;tag=as1374b4d4
To: sip:MY_SIP_USER@PUBLIC_IP2;tag=11ce9527
CSeq: 109 REGISTER
Call-ID: 1226b604535448df1baa1a0a0cf7f938@PUBLIC_IP3
Via: SIP/2.0/UDP PUBLIC_IP1:5060;branch=z9hG4bK2c0820a4;rport=5060
Contact: sip:MY_SIP_USER@PUBLIC_IP1:5060;user=phone;expires=400
Content-Length: 0

<------------->
— (8 headers 0 lines) —
Scheduling destruction of SIP dialog ‘1226b604535448df1baa1a0a0cf7f938@PUBLIC_IP3’ in 32000 ms (Method: REGISTER)
[Jan 21 01:38:21] NOTICE[24659]: chan_sip.c:20148 handle_response_register: Outbound Registration: Expiry for PUBLIC_IP2 is 120 sec (Scheduling reregistration in 105 s)

<— SIP read from UDP:PUBLIC_IP2:5060 —>
hello
<------------->

<— SIP read from UDP:PUBLIC_IP2:5060 —>
hello
<------------->

<— SIP read from UDP:PUBLIC_IP2:5060 —>
hello
<------------->
Really destroying SIP dialog ‘1226b604535448df1baa1a0a0cf7f938@PUBLIC_IP3’ Method: REGISTER

<— SIP read from UDP:PUBLIC_IP2:5060 —>
hello
<------------->

<— SIP read from UDP:PUBLIC_IP2:5060 —>
hello
<------------->

<— SIP read from UDP:PUBLIC_IP2:5060 —>
hello
<------------->

<— SIP read from UDP:PUBLIC_IP2:5060 —>
hello
<------------->

<— SIP read from UDP:PUBLIC_IP2:5060 —>
hello
<------------->

<— SIP read from UDP:PUBLIC_IP2:5060 —>
hello
<------------->

<— SIP read from UDP:PUBLIC_IP2:5060 —>
hello
<------------->
[Jan 21 01:40:06] NOTICE[24659]: chan_sip.c:12596 sip_reregister: – Re-registration for MY_SIP_USER@PUBLIC_IP2
REGISTER 11 headers, 0 lines
Reliably Transmitting (NAT) to PUBLIC_IP2:5060:
REGISTER sip:PUBLIC_IP2 SIP/2.0
Via: SIP/2.0/UDP PUBLIC_IP1:5060;branch=z9hG4bK6acfb20b;rport
Max-Forwards: 70
From: sip:MY_SIP_USER@PUBLIC_IP2;tag=as15f5003b
To: sip:MY_SIP_USER@PUBLIC_IP2
Call-ID: 1226b604535448df1baa1a0a0cf7f938@PUBLIC_IP3
CSeq: 110 REGISTER
User-Agent: Asterisk PBX 1.8.7.0
Authorization: Digest username=“MY_SIP_USER”, realm=“huawei”, algorithm=MD5, uri=“sip:sip:huawei.com”, nonce=“4c66637a2bcb61fc6f6c78ed550b8f1c”, response="667668a0eb94260d3638e34d0b978a8b"
Expires: 400
Contact: sip:s@PUBLIC_IP1:5060
Content-Length: 0


<— SIP read from UDP:PUBLIC_IP2:5060 —>
SIP/2.0 401 Unauthorized
From: sip:MY_SIP_USER@PUBLIC_IP2;tag=as15f5003b
To: sip:MY_SIP_USER@PUBLIC_IP2;tag=8ed83352
CSeq: 110 REGISTER
Call-ID: 1226b604535448df1baa1a0a0cf7f938@PUBLIC_IP3
Via: SIP/2.0/UDP PUBLIC_IP1:5060;branch=z9hG4bK6acfb20b;rport=5060
WWW-Authenticate: Digest realm=“huawei”,nonce=“0aeeb88876091fc5d067e4a837ca91b3”,domain=“sip:huawei.com”,stale=false,algorithm=MD5
Content-Length: 0

<------------->
— (8 headers 0 lines) —
esponding to challenge, registration to domain/host name PUBLIC_IP2
REGISTER 11 headers, 0 lines
Reliably Transmitting (NAT) to PUBLIC_IP2:5060:
REGISTER sip:PUBLIC_IP2 SIP/2.0
Via: SIP/2.0/UDP PUBLIC_IP1:5060;branch=z9hG4bK4b2746aa;rport
Max-Forwards: 70
From: sip:MY_SIP_USER@PUBLIC_IP2;tag=as6f1c30b6
To: sip:MY_SIP_USER@PUBLIC_IP2
Call-ID: 1226b604535448df1baa1a0a0cf7f938@PUBLIC_IP3
CSeq: 111 REGISTER
User-Agent: Asterisk PBX 1.8.7.0
Authorization: Digest username=“MY_SIP_USER”, realm=“huawei”, algorithm=MD5, uri=“sip:sip:huawei.com”, nonce=“0aeeb88876091fc5d067e4a837ca91b3”, response="cffabf0c71baef40feccb5f1a40322f2"
Expires: 400
Contact: sip:s@PUBLIC_IP1:5060
Content-Length: 0


<— SIP read from UDP:PUBLIC_IP2:5060 —>
SIP/2.0 200 OK
From: sip:MY_SIP_USER@PUBLIC_IP2;tag=as6f1c30b6
To: sip:MY_SIP_USER@PUBLIC_IP2;tag=57048d09
CSeq: 111 REGISTER
Call-ID: 1226b604535448df1baa1a0a0cf7f938@PUBLIC_IP3
Via: SIP/2.0/UDP PUBLIC_IP1:5060;branch=z9hG4bK4b2746aa;rport=5060
Contact: sip:MY_SIP_USER@PUBLIC_IP1:5060;user=phone;expires=400
Content-Length: 0

<------------->
— (8 headers 0 lines) —
Scheduling destruction of SIP dialog ‘1226b604535448df1baa1a0a0cf7f938@PUBLIC_IP3’ in 32000 ms (Method: REGISTER)
[Jan 21 01:40:06] NOTICE[24659]: chan_sip.c:20148 handle_response_register: Outbound Registration: Expiry for PUBLIC_IP2 is 120 sec (Scheduling reregistration in 105 s)

<— SIP read from UDP:PUBLIC_IP2:5060 —>
hello
<------------->

<— SIP read from UDP:PUBLIC_IP2:5060 —>
hello
<------------->

<— SIP read from UDP:PUBLIC_IP2:5060 —>
hello
<------------->
Really destroying SIP dialog ‘1226b604535448df1baa1a0a0cf7f938@PUBLIC_IP3’ Method: REGISTER

<— SIP read from UDP:PUBLIC_IP2:5060 —>
hello
<------------->

<— SIP read from UDP:PUBLIC_IP2:5060 —>
hello
<------------->

<— SIP read from UDP:PUBLIC_IP2:5060 —>
hello
<------------->

<— SIP read from UDP:PUBLIC_IP2:5060 —>
hello
<------------->

<— SIP read from UDP:PUBLIC_IP2:5060 —>
hello
<------------->

<— SIP read from UDP:PUBLIC_IP2:5060 —>
hello
<------------->

<— SIP read from UDP:PUBLIC_IP2:5060 —>
hello
<------------->
[Jan 21 01:41:51] NOTICE[24659]: chan_sip.c:12596 sip_reregister: – Re-registration for MY_SIP_USER@PUBLIC_IP2
REGISTER 11 headers, 0 lines
Reliably Transmitting (NAT) to PUBLIC_IP2:5060:
REGISTER sip:PUBLIC_IP2 SIP/2.0
Via: SIP/2.0/UDP PUBLIC_IP1:5060;branch=z9hG4bK4d80432b;rport
Max-Forwards: 70
From: sip:MY_SIP_USER@PUBLIC_IP2;tag=as4bf7bc09
To: sip:MY_SIP_USER@PUBLIC_IP2
Call-ID: 1226b604535448df1baa1a0a0cf7f938@PUBLIC_IP3
CSeq: 112 REGISTER
User-Agent: Asterisk PBX 1.8.7.0
Authorization: Digest username=“MY_SIP_USER”, realm=“huawei”, algorithm=MD5, uri=“sip:sip:huawei.com”, nonce=“0aeeb88876091fc5d067e4a837ca91b3”, response="cffabf0c71baef40feccb5f1a40322f2"
Expires: 400
Contact: sip:s@PUBLIC_IP1:5060
Content-Length: 0


<— SIP read from UDP:PUBLIC_IP2:5060 —>
SIP/2.0 401 Unauthorized
From: sip:MY_SIP_USER@PUBLIC_IP2;tag=as4bf7bc09
To: sip:MY_SIP_USER@PUBLIC_IP2;tag=2846a424
CSeq: 112 REGISTER
Call-ID: 1226b604535448df1baa1a0a0cf7f938@PUBLIC_IP3
Via: SIP/2.0/UDP PUBLIC_IP1:5060;branch=z9hG4bK4d80432b;rport=5060
WWW-Authenticate: Digest realm=“huawei”,nonce=“7f36dccd1bb96ec168383b1f99c7e7e6”,domain=“sip:huawei.com”,stale=false,algorithm=MD5
Content-Length: 0

<------------->
— (8 headers 0 lines) —
esponding to challenge, registration to domain/host name PUBLIC_IP2
REGISTER 11 headers, 0 lines
Reliably Transmitting (NAT) to PUBLIC_IP2:5060:
REGISTER sip:PUBLIC_IP2 SIP/2.0
Via: SIP/2.0/UDP PUBLIC_IP1:5060;branch=z9hG4bK4a06a2d1;rport
Max-Forwards: 70
From: sip:MY_SIP_USER@PUBLIC_IP2;tag=as5cb26694
To: sip:MY_SIP_USER@PUBLIC_IP2
Call-ID: 1226b604535448df1baa1a0a0cf7f938@PUBLIC_IP3
CSeq: 113 REGISTER
User-Agent: Asterisk PBX 1.8.7.0
Authorization: Digest username=“MY_SIP_USER”, realm=“huawei”, algorithm=MD5, uri=“sip:sip:huawei.com”, nonce=“7f36dccd1bb96ec168383b1f99c7e7e6”, response="d92b507ceff746c70de7633e64abf8ac"
Expires: 400
Contact: sip:s@PUBLIC_IP1:5060
Content-Length: 0


<— SIP read from UDP:PUBLIC_IP2:5060 —>
SIP/2.0 200 OK
From: sip:MY_SIP_USER@PUBLIC_IP2;tag=as5cb26694
To: sip:MY_SIP_USER@PUBLIC_IP2;tag=4fdcd622
CSeq: 113 REGISTER
Call-ID: 1226b604535448df1baa1a0a0cf7f938@PUBLIC_IP3
Via: SIP/2.0/UDP PUBLIC_IP1:5060;branch=z9hG4bK4a06a2d1;rport=5060
Contact: sip:MY_SIP_USER@PUBLIC_IP1:5060;user=phone;expires=400
Content-Length: 0

<------------->
— (8 headers 0 lines) —
Scheduling destruction of SIP dialog ‘1226b604535448df1baa1a0a0cf7f938@PUBLIC_IP3’ in 32000 ms (Method: REGISTER)
[Jan 21 01:41:51] NOTICE[24659]: chan_sip.c:20148 handle_response_register: Outbound Registration: Expiry for PUBLIC_IP2 is 120 sec (Scheduling reregistration in 105 s)

<— SIP read from UDP:PUBLIC_IP2:5060 —>
hello
<------------->

<— SIP read from UDP:PUBLIC_IP2:5060 —>
hello
<------------->

<— SIP read from UDP:PUBLIC_IP2:5060 —>
hello
<------------->
Really destroying SIP dialog ‘1226b604535448df1baa1a0a0cf7f938@PUBLIC_IP3’ Method: REGISTER

<— SIP read from UDP:PUBLIC_IP2:5060 —>
hello
<------------->

<— SIP read from UDP:PUBLIC_IP2:5060 —>
hello
<------------->

<— SIP read from UDP:PUBLIC_IP2:5060 —>
hello
<------------->

<— SIP read from UDP:PUBLIC_IP2:5060 —>
hello
<------------->

<— SIP read from UDP:PUBLIC_IP2:5060 —>
hello
<------------->

<— SIP read from UDP:PUBLIC_IP2:5060 —>
hello
<------------->

<— SIP read from UDP:PUBLIC_IP2:5060 —>
hello
<------------->
[Jan 21 01:43:36] NOTICE[24659]: chan_sip.c:12596 sip_reregister: – Re-registration for MY_SIP_USER@PUBLIC_IP2
REGISTER 11 headers, 0 lines
Reliably Transmitting (NAT) to PUBLIC_IP2:5060:
REGISTER sip:PUBLIC_IP2 SIP/2.0
Via: SIP/2.0/UDP PUBLIC_IP1:5060;branch=z9hG4bK3c211459;rport
Max-Forwards: 70
From: sip:MY_SIP_USER@PUBLIC_IP2;tag=as5697de04
To: sip:MY_SIP_USER@PUBLIC_IP2
Call-ID: 1226b604535448df1baa1a0a0cf7f938@PUBLIC_IP3
CSeq: 114 REGISTER
User-Agent: Asterisk PBX 1.8.7.0
Authorization: Digest username=“MY_SIP_USER”, realm=“huawei”, algorithm=MD5, uri=“sip:sip:huawei.com”, nonce=“7f36dccd1bb96ec168383b1f99c7e7e6”, response="d92b507ceff746c70de7633e64abf8ac"
Expires: 400
Contact: sip:s@PUBLIC_IP1:5060
Content-Length: 0


<— SIP read from UDP:PUBLIC_IP2:5060 —>
SIP/2.0 401 Unauthorized
From: sip:MY_SIP_USER@PUBLIC_IP2;tag=as5697de04
To: sip:MY_SIP_USER@PUBLIC_IP2;tag=9e5f93e6
CSeq: 114 REGISTER
Call-ID: 1226b604535448df1baa1a0a0cf7f938@PUBLIC_IP3
Via: SIP/2.0/UDP PUBLIC_IP1:5060;branch=z9hG4bK3c211459;rport=5060
WWW-Authenticate: Digest realm=“huawei”,nonce=“6a6eb619468f3ac5172b44f373b4208a”,domain=“sip:huawei.com”,stale=false,algorithm=MD5
Content-Length: 0

<------------->
— (8 headers 0 lines) —
esponding to challenge, registration to domain/host name PUBLIC_IP2
REGISTER 11 headers, 0 lines
Reliably Transmitting (NAT) to PUBLIC_IP2:5060:
REGISTER sip:PUBLIC_IP2 SIP/2.0
Via: SIP/2.0/UDP PUBLIC_IP1:5060;branch=z9hG4bK7153ad3b;rport
Max-Forwards: 70
From: sip:MY_SIP_USER@PUBLIC_IP2;tag=as11bb64a5
To: sip:MY_SIP_USER@PUBLIC_IP2
Call-ID: 1226b604535448df1baa1a0a0cf7f938@PUBLIC_IP3
CSeq: 115 REGISTER
User-Agent: Asterisk PBX 1.8.7.0
Authorization: Digest username=“MY_SIP_USER”, realm=“huawei”, algorithm=MD5, uri=“sip:sip:huawei.com”, nonce=“6a6eb619468f3ac5172b44f373b4208a”, response="2fb32a1a5aff97cfadde074e9e8fa7a2"
Expires: 400
Contact: sip:s@PUBLIC_IP1:5060
Content-Length: 0


<— SIP read from UDP:PUBLIC_IP2:5060 —>
SIP/2.0 200 OK
From: sip:MY_SIP_USER@PUBLIC_IP2;tag=as11bb64a5
To: sip:MY_SIP_USER@PUBLIC_IP2;tag=12fbbe61
CSeq: 115 REGISTER
Call-ID: 1226b604535448df1baa1a0a0cf7f938@PUBLIC_IP3
Via: SIP/2.0/UDP PUBLIC_IP1:5060;branch=z9hG4bK7153ad3b;rport=5060
Contact: sip:MY_SIP_USER@PUBLIC_IP1:5060;user=phone;expires=400
Content-Length: 0

<------------->
— (8 headers 0 lines) —
Scheduling destruction of SIP dialog ‘1226b604535448df1baa1a0a0cf7f938@PUBLIC_IP3’ in 32000 ms (Method: REGISTER)
[Jan 21 01:43:36] NOTICE[24659]: chan_sip.c:20148 handle_response_register: Outbound Registration: Expiry for PUBLIC_IP2 is 120 sec (Scheduling reregistration in 105 s)

<— SIP read from UDP:PUBLIC_IP2:5060 —>
hello
<------------->

<— SIP read from UDP:PUBLIC_IP2:5060 —>
hello
<------------->

<— SIP read from UDP:PUBLIC_IP2:5060 —>
hello
<------------->
Really destroying SIP dialog ‘1226b604535448df1baa1a0a0cf7f938@PUBLIC_IP3’ Method: REGISTER

<— SIP read from UDP:PUBLIC_IP2:5060 —>
hello
<------------->

<— SIP read from UDP:PUBLIC_IP2:5060 —>
hello
<------------->

<— SIP read from UDP:PUBLIC_IP2:5060 —>
hello
<------------->

<— SIP read from UDP:PUBLIC_IP2:5060 —>
hello
<------------->

I think you may have the type of ISP that doesn’t want you to run servers, at least not on a cheap account, and deliberately makes changes to the dynamic address.

I asked my provider about your idea, but they said that we don’t have this policy! And they didn’t know about the PUBLIC_IP3!
Also I have a question is there any way to separate asterisk server from soft-phone?! Why 3CX soft-phone works perfectly but asterisk no?!
Is there any difference between packets that soft-phones sends to provider and asterisk packets?!
Is there any solution that for example asterisk acts like a soft phone?