Multiple interfaces routing issue (INVITE)

I know there have been a dozen of topics about this, but most are a already a few years old. It seems that no matter how I configure the IP routes in linux, asterisk doesn’t seem to follow them at all.

Extensions.conf on 1st server (incoming):

[internal] exten => _41040,1,dial(PJSIP/41040,10)
-> so if the exten 41040 is called, it should accordingly ring the device which is connected to this same server.

Extensions.conf on 2nd server (outgoing):

[internal] exten => 41040,1,Verbose(Callerid is ${CALLERID(number)}) same => n,dial(PJSIP/firstserver/sip:41040@192.168.87.11:5060)
-> When a call to 41040 is set up, redirect it to the 2nd server.

I setup a call from the first device (42680 registered on 2nd server) to the second one (41040 registered on 1st server). It rings on the second device; but I’m not able to pickup the call. Eventually the second device displays “488 Not acceptable here”. Codec (ulaw) should be alright. [color=#FF0000]A trace shows that the INVITE contains the IP of NIC 2 (while it should be NIC 1!)[/color]

Transports do have their correct binds?

[transport-udp] type=transport protocol=udp bind=192.168.89.1:5060
and

[transport-udp-out] type=transport protocol=udp bind=195.162.X.X:5060

<--- Transmitting SIP request (901 bytes) to UDP:172.17.107.67:5060 ---> INVITE sip:42680@172.17.107.67:5060 SIP/2.0 From: "41040" <sip:41040@195.162.X.X>;tag=232682be-1f81-4398-bafe-4b4a5beba777 --> moet hier IP van astp3 zijn!

What does work:

  • Calls using the second trunk (195.162.X.X). Not described in the scenario above.

What doesn’t work:

  • Calls from 42680 (1st server) to 41040 (2nd server)

This is the output of “ip route list” on the 1st machine:

default via 192.168.87.254 dev em1 proto static metric 1024 169.254.0.0/16 dev em2 scope link metric 1003 192.168.87.0/24 dev em1 proto kernel scope link src 192.168.87.11 192.168.89.0/24 via 192.168.87.254 dev em1 195.162.X.X/29 dev em2 proto kernel scope link src 195.162.X.X
Output on the 2nd machine:

[root@astp4 asterisk]# ip route list default via 192.168.89.254 dev em1 proto static metric 1024 169.254.0.0/16 dev em2 scope link metric 1003 192.168.87.0/24 via 192.168.89.254 dev em1 192.168.89.0/24 dev em1 proto kernel scope link src 192.168.89.1 195.162.X.X/29 dev em2 proto kernel scope link src 195.162.X.X

Am I missing something in my routing? Or should I look in pjsip.conf instead? I think I have the correct matches with each identify section though…

Without seeing the complete SIP traces, console output, and configuration it’s hard to understand what is going on. I’d suggest providing those.

As requested the content of pjsip.conf (1st server):

; GLOBAL
[global]
debug=no

[transport-udp]
type=transport
protocol=udp
bind=192.168.87.11:5060
local_net=192.168.0.0/16

[astp4]
type=registration
transport=transport-udp
server_uri=sip:192.168.87.11:5060
client_uri=sip:astp4@192.168.89.1:5060

[astp4]
type=endpoint
transport=transport-udp
context=internal
direct_media=no
disallow=all
allow=alaw
aors=astp4
rewrite_contact=yes

[astp4]
type=aor
qualify_frequency=30
max_contacts=5

[astp4]
type=identify
endpoint=astp4
match=192.168.89.1
match=192.168.87.11

[astp4]
type=contact
uri=sip:192.168.89.1:5060

[transport-udp-out]
type=transport
protocol=udp
bind=195.162.X.X:5060
local_net=195.162.X.X/29

[outtrunk]
type=endpoint
transport=transport-udp-out
context=internal
allow=alaw
aors=outtrunk

[outtrunk]
type=aor
qualify_frequency=30
max_contacts=5
contact=sip:195.162.X.X:5060

[outtrunk]
type=identify
endpoint=outtrunk
match=195.162.X.X
match=195.162.X.X

[outtrunk]
type=contact
uri=sip:195.162.X.X:5060

[42680]
type=aor
max_contacts=5

[42680]
type=endpoint
context=internal
disallow=all
allow=alaw
auth=auth42680
aors=42680

[auth42680]
type=auth
auth_type=md5
md5_cred=c1faea51dfbaf89c2616c8269a47f0da
username=42680

[41040]
type=aor
max_contacts=5

[41040]
type=endpoint
context=internal
disallow=all
allow=alaw
auth=auth41040
aors=41040

[auth41040]
type=auth
auth_type=md5
md5_cred=
username=41040

extensions.conf of 1st server:

[code][general]
static = yes
writeprotect = no
autofallthrough = yes
clearglobalvars = no
priorityjumping = no

[internal]
; External TEST
exten => 93985010,1,Verbose(Callerid is ${CALLERID(number)})
same => n,dial(PJSIP/astp4/sip:X@192.168.89.1:5060)
same => n,Hangup()

; Internal TEST
exten => _41040,1,dial(PJSIP/41040,10)[/code]

pjsip.conf of 2nd server:

[code]; GLOBAL
[global]
debug=no

[transport-udp]
type=transport
protocol=udp
bind=192.168.89.1:5060
local_net=192.168.0.0/16

[transport-udp-out]
type=transport
protocol=udp
bind=195.162.X.X:5060
local_net=195.162.X.X/29

[astp3]
type=registration
transport=transport-udp
server_uri=sip:192.168.89.1:5060
client_uri=sip:astp3@192.168.87.11:5060

[astp3]
type=endpoint
transport=transport-udp
context=internal
direct_media=no
disallow=all
allow=alaw
aors=astp3
rewrite_contact=yes

[astp3]
type=aor
qualify_frequency=30
max_contacts=5

[astp3]
type=identify
endpoint=astp3
match=192.168.87.11
match=192.168.89.1

[astp3]
type=contact
uri=sip:192.168.87.11:5060

[outtrunk]
type=endpoint
transport=transport-udp-out
context=internal
allow=alaw
aors=outtrunk

[outtrunk]
type=aor
qualify_frequency=30
max_contacts=5
contact=sip:195.162.X.X:5060

[outtrunk]
type=identify
endpoint=outtrunk
match=195.162.X.X
match=195.162.X.X

[outtrunk]
type=contact
uri=sip:195.162.X.X:5060

[42680]
type=aor
max_contacts=5

[42680]
type=endpoint
context=internal
disallow=all
allow=alaw
auth=auth42680
aors=42680

[auth42680]
type=auth
auth_type=md5
md5_cred=
username=42680

[41040]
type=aor
max_contacts=5

[41040]
type=endpoint
context=internal
disallow=all
allow=alaw
auth=auth41040
aors=41040

[auth41040]
type=auth
auth_type=md5
md5_cred=
username=41040
[/code]
extensions.conf of 2nd server:

[code][general]
static = yes
writeprotect = no
autofallthrough = yes
clearglobalvars = no
priorityjumping = no

[via-out]
exten => _939850XX,1,Verbose(Call via outtrunk van ${EXTEN}.)
same => n,Gosub(internal,${EXTEN},1)

[internal]
; Internal TEST
exten => 41040,1,Verbose(Callerid is ${CALLERID(number)})
same => n,dial(PJSIP/astp3/sip:41040@192.168.87.11:5060)

; External TEST
exten => 93985010,1,Verbose(Callerid is ${CALLERID(number)})
same => n,answer()
same => n,playback(demo-congrats)
same => n,hangup()[/code]

Internal call between 42268 and 41104 (as above, which fails)

logger of 1st server:

[code]astp3*CLI> pjsip set logger on
PJSIP Logging enabled
<— Transmitting SIP request (433 bytes) to UDP:195.162.X.X:5060 —>
OPTIONS sip:195.162.X.X:5060 SIP/2.0
Via: SIP/2.0/UDP 195.162.X.X:5060;rport;branch=z9hG4bKPj19db1586-ec33-42ef-a512-b89fc8254369
From: sip:asterisk@195.162.X.X;tag=9de71359-6536-4d17-977c-6e13d1ed69cf
To: sip:195.162.X.X
Contact: sip:asterisk@195.162.X.X:5060
Call-ID: 239f576b-8ef8-4877-9fe3-4b9fa9898fbf
CSeq: 52721 OPTIONS
Max-Forwards: 70
User-Agent: Asterisk PBX 13.6.0
Content-Length: 0

<— Received SIP response (586 bytes) from UDP:195.162.X.X:5060 —>
SIP/2.0 200 OK
Via: SIP/2.0/UDP 195.162.X.X:5060;branch=z9hG4bKPj19db1586-ec33-42ef-a512-b89fc8254369;rport=5060
From: sip:asterisk@195.162.X.X;tag=9de71359-6536-4d17-977c-6e13d1ed69cf
To: sip:195.162.X.X
Call-ID: 239f576b-8ef8-4877-9fe3-4b9fa9898fbf
CSeq: 52721 OPTIONS
Contact: sip:ANONYMOUS@195.162.X.X:5060
Allow: INVITE,ACK,CANCEL,BYE,REGISTER,REFER,INFO,SUBSCRIBE,NOTIFY,PRACK,UPDATE,OPTIONS
Accept: application/sdp, application/isup, application/dtmf, application/dtmf-relay, multipart/mixed
Supported: timer,100rel,replaces
Content-Length: 0

<— Received SIP request (897 bytes) from UDP:192.168.89.1:5060 —>
INVITE sip:41040@192.168.87.11:5060 SIP/2.0
Via: SIP/2.0/UDP 192.168.89.1:5060;rport;branch=z9hG4bKPj679978e7-6540-4948-b80b-2847af0be15e
From: “42680” sip:42680@192.168.89.1;tag=87e98043-a980-4501-ab3c-c7d411e32224
To: sip:41040@192.168.87.11
Contact: sip:asterisk@192.168.89.1:5060
Call-ID: 190bb3f3-912d-4719-9da1-e7c9a369fa88
CSeq: 2619 INVITE
Allow: OPTIONS, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, REFER, MESSAGE, REGISTER
Supported: 100rel, timer, replaces, norefersub
Session-Expires: 1800
Min-SE: 90
Max-Forwards: 70
User-Agent: Asterisk PBX 13.6.0
Content-Type: application/sdp
Content-Length: 235

v=0
o=- 343162209 343162209 IN IP4 192.168.89.1
s=Asterisk
c=IN IP4 192.168.89.1
t=0 0
m=audio 10416 RTP/AVP 8 101
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=maxptime:150
a=sendrecv

<— Transmitting SIP response (371 bytes) to UDP:192.168.89.1:5060 —>
SIP/2.0 100 Trying
Via: SIP/2.0/UDP 192.168.89.1:5060;rport=5060;received=192.168.89.1;branch=z9hG4bKPj679978e7-6540-4948-b80b-2847af0be15e
Call-ID: 190bb3f3-912d-4719-9da1-e7c9a369fa88
From: “42680” sip:42680@192.168.89.1;tag=87e98043-a980-4501-ab3c-c7d411e32224
To: sip:41040@192.168.87.11
CSeq: 2619 INVITE
Server: Asterisk PBX 13.6.0
Content-Length: 0

<— Transmitting SIP request (907 bytes) to UDP:172.17.105.102:5062 —>
INVITE sip:41040@172.17.105.102:5062 SIP/2.0
Via: SIP/2.0/UDP 192.168.87.11:5060;rport;branch=z9hG4bKPjefd66edb-d39d-49f0-ae1c-b79075e257ff
From: “42680” sip:42680@195.162.X.X;tag=af72ecb9-442f-47a6-9424-dd57cc46d7ea
To: sip:41040@172.17.105.102
Contact: sip:asterisk@192.168.87.11:5060
Call-ID: cb814e4c-4ae1-497c-9dcf-309485df58f8
CSeq: 11902 INVITE
Allow: OPTIONS, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, MESSAGE, REFER, REGISTER
Supported: 100rel, timer, replaces, norefersub
Session-Expires: 1800
Min-SE: 90
Max-Forwards: 70
User-Agent: Asterisk PBX 13.6.0
Content-Type: application/sdp
Content-Length: 237

v=0
o=- 583048194 583048194 IN IP4 192.168.87.11
s=Asterisk
c=IN IP4 192.168.87.11
t=0 0
m=audio 13988 RTP/AVP 8 101
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=maxptime:150
a=sendrecv

<— Transmitting SIP request (907 bytes) to UDP:172.17.105.102:5062 —>
INVITE sip:41040@172.17.105.102:5062 SIP/2.0
Via: SIP/2.0/UDP 192.168.87.11:5060;rport;branch=z9hG4bKPjefd66edb-d39d-49f0-ae1c-b79075e257ff
From: “42680” sip:42680@195.162.X.X;tag=af72ecb9-442f-47a6-9424-dd57cc46d7ea
To: sip:41040@172.17.105.102
Contact: sip:asterisk@192.168.87.11:5060
Call-ID: cb814e4c-4ae1-497c-9dcf-309485df58f8
CSeq: 11902 INVITE
Allow: OPTIONS, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, MESSAGE, REFER, REGISTER
Supported: 100rel, timer, replaces, norefersub
Session-Expires: 1800
Min-SE: 90
Max-Forwards: 70
User-Agent: Asterisk PBX 13.6.0
Content-Type: application/sdp
Content-Length: 237

v=0
o=- 583048194 583048194 IN IP4 192.168.87.11
s=Asterisk
c=IN IP4 192.168.87.11
t=0 0
m=audio 13988 RTP/AVP 8 101
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=maxptime:150
a=sendrecv

<— Transmitting SIP request (907 bytes) to UDP:172.17.105.102:5062 —>
INVITE sip:41040@172.17.105.102:5062 SIP/2.0
Via: SIP/2.0/UDP 192.168.87.11:5060;rport;branch=z9hG4bKPjefd66edb-d39d-49f0-ae1c-b79075e257ff
From: “42680” sip:42680@195.162.X.X;tag=af72ecb9-442f-47a6-9424-dd57cc46d7ea
To: sip:41040@172.17.105.102
Contact: sip:asterisk@192.168.87.11:5060
Call-ID: cb814e4c-4ae1-497c-9dcf-309485df58f8
CSeq: 11902 INVITE
Allow: OPTIONS, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, MESSAGE, REFER, REGISTER
Supported: 100rel, timer, replaces, norefersub
Session-Expires: 1800
Min-SE: 90
Max-Forwards: 70
User-Agent: Asterisk PBX 13.6.0
Content-Type: application/sdp
Content-Length: 237

v=0
o=- 583048194 583048194 IN IP4 192.168.87.11
s=Asterisk
c=IN IP4 192.168.87.11
t=0 0
m=audio 13988 RTP/AVP 8 101
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=maxptime:150
a=sendrecv

<— Transmitting SIP request (429 bytes) to UDP:192.168.87.11:5060 —>
OPTIONS sip:s@192.168.87.11:5060 SIP/2.0
Via: SIP/2.0/UDP 192.168.87.11:5060;rport;branch=z9hG4bKPjed994413-eab3-42f9-9e1b-bc09f8575312
From: sip:asterisk@195.162.X.X;tag=ba0ef886-be48-40a0-9684-c94036607eee
To: sip:s@192.168.87.11
Contact: sip:asterisk@192.168.87.11:5060
Call-ID: e49296f6-52f0-44c1-99b3-a5a48c5a2c92
CSeq: 41921 OPTIONS
Max-Forwards: 70
User-Agent: Asterisk PBX 13.6.0
Content-Length: 0

<— Received SIP request (429 bytes) from UDP:195.162.X.X:5060 —>
OPTIONS sip:s@192.168.87.11:5060 SIP/2.0
Via: SIP/2.0/UDP 192.168.87.11:5060;rport;branch=z9hG4bKPjed994413-eab3-42f9-9e1b-bc09f8575312
From: sip:asterisk@195.162.X.X;tag=ba0ef886-be48-40a0-9684-c94036607eee
To: sip:s@192.168.87.11
Contact: sip:asterisk@192.168.87.11:5060
Call-ID: e49296f6-52f0-44c1-99b3-a5a48c5a2c92
CSeq: 41921 OPTIONS
Max-Forwards: 70
User-Agent: Asterisk PBX 13.6.0
Content-Length: 0

<— Transmitting SIP response (911 bytes) to UDP:195.162.X.X:5060 —>
SIP/2.0 404 Not Found
Via: SIP/2.0/UDP 192.168.87.11:5060;rport=5060;received=195.162.X.X;branch=z9hG4bKPjed994413-eab3-42f9-9e1b-bc09f8575312
Call-ID: e49296f6-52f0-44c1-99b3-a5a48c5a2c92
From: sip:asterisk@195.162.X.X;tag=ba0ef886-be48-40a0-9684-c94036607eee
To: sip:s@192.168.87.11;tag=z9hG4bKPjed994413-eab3-42f9-9e1b-bc09f8575312
CSeq: 41921 OPTIONS
Accept: application/sdp, application/dialog-info+xml, application/pidf+xml, application/dialog-info+xml, application/simple-message-summary, application/pidf+xml, application/xpidf+xml, application/cpim-pidf+xml, application/simple-message-summary, message/sipfrag;version=2.0
Allow: OPTIONS, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, MESSAGE, REFER, REGISTER
Supported: 100rel, timer, replaces, norefersub
Accept-Encoding: text/plain
Accept-Language: en
Server: Asterisk PBX 13.6.0
Content-Length: 0

<— Received SIP response (911 bytes) from UDP:192.168.87.11:5060 —>
SIP/2.0 404 Not Found
Via: SIP/2.0/UDP 192.168.87.11:5060;rport=5060;received=195.162.X.X;branch=z9hG4bKPjed994413-eab3-42f9-9e1b-bc09f8575312
Call-ID: e49296f6-52f0-44c1-99b3-a5a48c5a2c92
From: sip:asterisk@195.162.X.X;tag=ba0ef886-be48-40a0-9684-c94036607eee
To: sip:s@192.168.87.11;tag=z9hG4bKPjed994413-eab3-42f9-9e1b-bc09f8575312
CSeq: 41921 OPTIONS
Accept: application/sdp, application/dialog-info+xml, application/pidf+xml, application/dialog-info+xml, application/simple-message-summary, application/pidf+xml, application/xpidf+xml, application/cpim-pidf+xml, application/simple-message-summary, message/sipfrag;version=2.0
Allow: OPTIONS, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, MESSAGE, REFER, REGISTER
Supported: 100rel, timer, replaces, norefersub
Accept-Encoding: text/plain
Accept-Language: en
Server: Asterisk PBX 13.6.0
Content-Length: 0

<— Transmitting SIP request (907 bytes) to UDP:172.17.105.102:5062 —>
INVITE sip:41040@172.17.105.102:5062 SIP/2.0
Via: SIP/2.0/UDP 192.168.87.11:5060;rport;branch=z9hG4bKPjefd66edb-d39d-49f0-ae1c-b79075e257ff
From: “42680” sip:42680@195.162.X.X;tag=af72ecb9-442f-47a6-9424-dd57cc46d7ea
To: sip:41040@172.17.105.102
Contact: sip:asterisk@192.168.87.11:5060
Call-ID: cb814e4c-4ae1-497c-9dcf-309485df58f8
CSeq: 11902 INVITE
Allow: OPTIONS, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, MESSAGE, REFER, REGISTER
Supported: 100rel, timer, replaces, norefersub
Session-Expires: 1800
Min-SE: 90
Max-Forwards: 70
User-Agent: Asterisk PBX 13.6.0
Content-Type: application/sdp
Content-Length: 237

v=0
o=- 583048194 583048194 IN IP4 192.168.87.11
s=Asterisk
c=IN IP4 192.168.87.11
t=0 0
m=audio 13988 RTP/AVP 8 101
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=maxptime:150
a=sendrecv

<— Transmitting SIP request (907 bytes) to UDP:172.17.105.102:5062 —>
INVITE sip:41040@172.17.105.102:5062 SIP/2.0
Via: SIP/2.0/UDP 192.168.87.11:5060;rport;branch=z9hG4bKPjefd66edb-d39d-49f0-ae1c-b79075e257ff
From: “42680” sip:42680@195.162.X.X;tag=af72ecb9-442f-47a6-9424-dd57cc46d7ea
To: sip:41040@172.17.105.102
Contact: sip:asterisk@192.168.87.11:5060
Call-ID: cb814e4c-4ae1-497c-9dcf-309485df58f8
CSeq: 11902 INVITE
Allow: OPTIONS, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, MESSAGE, REFER, REGISTER
Supported: 100rel, timer, replaces, norefersub
Session-Expires: 1800
Min-SE: 90
Max-Forwards: 70
User-Agent: Asterisk PBX 13.6.0
Content-Type: application/sdp
Content-Length: 237

v=0
o=- 583048194 583048194 IN IP4 192.168.87.11
s=Asterisk
c=IN IP4 192.168.87.11
t=0 0
m=audio 13988 RTP/AVP 8 101
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=maxptime:150
a=sendrecv

<— Transmitting SIP response (436 bytes) to UDP:192.168.89.1:5060 —>
SIP/2.0 603 Decline
Via: SIP/2.0/UDP 192.168.89.1:5060;rport=5060;received=192.168.89.1;branch=z9hG4bKPj679978e7-6540-4948-b80b-2847af0be15e
Call-ID: 190bb3f3-912d-4719-9da1-e7c9a369fa88
From: “42680” sip:42680@192.168.89.1;tag=87e98043-a980-4501-ab3c-c7d411e32224
To: sip:41040@192.168.87.11;tag=6bafac6f-5432-4bc6-b8ef-513a85ca1115
CSeq: 2619 INVITE
Server: Asterisk PBX 13.6.0
Reason: Q.850;cause=0
Content-Length: 0

<— Received SIP request (426 bytes) from UDP:192.168.89.1:5060 —>
ACK sip:41040@192.168.87.11:5060 SIP/2.0
Via: SIP/2.0/UDP 192.168.89.1:5060;rport;branch=z9hG4bKPj679978e7-6540-4948-b80b-2847af0be15e
From: “42680” sip:42680@192.168.89.1;tag=87e98043-a980-4501-ab3c-c7d411e32224
To: sip:41040@192.168.87.11;tag=6bafac6f-5432-4bc6-b8ef-513a85ca1115
Call-ID: 190bb3f3-912d-4719-9da1-e7c9a369fa88
CSeq: 2619 ACK
Max-Forwards: 70
User-Agent: Asterisk PBX 13.6.0
Content-Length: 0

<— Transmitting SIP request (907 bytes) to UDP:172.17.105.102:5062 —>
INVITE sip:41040@172.17.105.102:5062 SIP/2.0
Via: SIP/2.0/UDP 192.168.87.11:5060;rport;branch=z9hG4bKPjefd66edb-d39d-49f0-ae1c-b79075e257ff
From: “42680” sip:42680@195.162.X.X;tag=af72ecb9-442f-47a6-9424-dd57cc46d7ea
To: sip:41040@172.17.105.102
Contact: sip:asterisk@192.168.87.11:5060
Call-ID: cb814e4c-4ae1-497c-9dcf-309485df58f8
CSeq: 11902 INVITE
Allow: OPTIONS, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, MESSAGE, REFER, REGISTER
Supported: 100rel, timer, replaces, norefersub
Session-Expires: 1800
Min-SE: 90
Max-Forwards: 70
User-Agent: Asterisk PBX 13.6.0
Content-Type: application/sdp
Content-Length: 237

v=0
o=- 583048194 583048194 IN IP4 192.168.87.11
s=Asterisk
c=IN IP4 192.168.87.11
t=0 0
m=audio 13988 RTP/AVP 8 101
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=maxptime:150
a=sendrecv

astp3*CLI>
Disconnected from Asterisk server
[/code]

logger of 2nd server:

[code]astp4*CLI> pjsip set logger on
PJSIP Logging enabled
<— Received SIP request (1077 bytes) from UDP:172.17.107.67:5060 —>
INVITE sip:41040@astp4.internal.xyz SIP/2.0
Via: SIP/2.0/UDP 172.17.107.67:5060;branch=z9hG4bK1802527485;rport
From: “42680” sip:42680@astp4.internal.xyz;tag=992053134
To: sip:41040@astp4.internal.xyz
Call-ID: 1485638553-5060-45@BHC.BH.BAH.GH
CSeq: 440 INVITE
Contact: “42680” sip:42680@172.17.107.67:5060
Max-Forwards: 70
User-Agent: Grandstream GXV3240 1.0.3.46
Privacy: none
P-Preferred-Identity: “42680” sip:42680@astp4.internal.xyz
Supported: replaces, path, timer, eventlist
Allow: INVITE, ACK, OPTIONS, CANCEL, BYE, SUBSCRIBE, NOTIFY, INFO, REFER, UPDATE, MESSAGE
Content-Type: application/sdp
Accept: application/sdp, application/dtmf-relay
Content-Length: 356

v=0
o=42680 8000 8000 IN IP4 172.17.107.67
s=SIP Call
c=IN IP4 172.17.107.67
t=0 0
m=audio 5004 RTP/AVP 0 8 4 18 9 3 101
a=sendrecv
a=rtpmap:0 PCMU/8000
a=ptime:20
a=rtpmap:8 PCMA/8000
a=rtpmap:4 G723/8000
a=rtpmap:18 G729/8000
a=fmtp:18 annexb=no
a=rtpmap:9 G722/8000
a=rtpmap:3 GSM/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-15

<— Transmitting SIP response (511 bytes) to UDP:172.17.107.67:5060 —>
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 172.17.107.67:5060;rport=5060;received=172.17.107.67;branch=z9hG4bK1802527485
Call-ID: 1485638553-5060-45@BHC.BH.BAH.GH
From: “42680” sip:42680@astp4.internal.xyz;tag=992053134
To: sip:41040@astp4.internal.xyz;tag=z9hG4bK1802527485
CSeq: 440 INVITE
WWW-Authenticate: Digest realm=“asterisk”,nonce=“1450787925/4e0b3993127aeb702c01841b1273c2a8”,opaque=“216bbc505d1f5e42”,algorithm=md5,qop="auth"
Server: Asterisk PBX 13.6.0
Content-Length: 0

<— Received SIP request (325 bytes) from UDP:172.17.107.67:5060 —>
ACK sip:41040@astp4.internal.xyz SIP/2.0
Via: SIP/2.0/UDP 172.17.107.67:5060;branch=z9hG4bK1802527485;rport
From: “42680” sip:42680@astp4.internal.xyz;tag=992053134
To: sip:41040@astp4.internal.xyz;tag=z9hG4bK1802527485
Call-ID: 1485638553-5060-45@BHC.BH.BAH.GH
CSeq: 440 ACK
Content-Length: 0

<— Received SIP request (1359 bytes) from UDP:172.17.107.67:5060 —>
INVITE sip:41040@astp4.internal.xyz SIP/2.0
Via: SIP/2.0/UDP 172.17.107.67:5060;branch=z9hG4bK1721025199;rport
From: “42680” sip:42680@astp4.internal.xyz;tag=992053134
To: sip:41040@astp4.internal.xyz
Call-ID: 1485638553-5060-45@BHC.BH.BAH.GH
CSeq: 441 INVITE
Contact: “42680” sip:42680@172.17.107.67:5060
Authorization: Digest username=“42680”, realm=“asterisk”, nonce=“1450787925/4e0b3993127aeb702c01841b1273c2a8”, uri=“sip:41040@astp4.internal.xyz”, response=“7168835c38e7a7e7f4dbd311c21a97b9”, algorithm=md5, cnonce=“14144175”, opaque=“216bbc505d1f5e42”, qop=auth, nc=00000002
Max-Forwards: 70
User-Agent: Grandstream GXV3240 1.0.3.46
Privacy: none
P-Preferred-Identity: “42680” sip:42680@astp4.internal.xyz
Supported: replaces, path, timer, eventlist
Allow: INVITE, ACK, OPTIONS, CANCEL, BYE, SUBSCRIBE, NOTIFY, INFO, REFER, UPDATE, MESSAGE
Content-Type: application/sdp
Accept: application/sdp, application/dtmf-relay
Content-Length: 356

v=0
o=42680 8000 8000 IN IP4 172.17.107.67
s=SIP Call
c=IN IP4 172.17.107.67
t=0 0
m=audio 5004 RTP/AVP 0 8 4 18 9 3 101
a=sendrecv
a=rtpmap:0 PCMU/8000
a=ptime:20
a=rtpmap:8 PCMA/8000
a=rtpmap:4 G723/8000
a=rtpmap:18 G729/8000
a=fmtp:18 annexb=no
a=rtpmap:9 G722/8000
a=rtpmap:3 GSM/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-15

<— Transmitting SIP response (336 bytes) to UDP:172.17.107.67:5060 —>
SIP/2.0 100 Trying
Via: SIP/2.0/UDP 172.17.107.67:5060;rport=5060;received=172.17.107.67;branch=z9hG4bK1721025199
Call-ID: 1485638553-5060-45@BHC.BH.BAH.GH
From: “42680” sip:42680@astp4.internal.xyz;tag=992053134
To: sip:41040@astp4.internal.xyz
CSeq: 441 INVITE
Server: Asterisk PBX 13.6.0
Content-Length: 0

Callerid is 42680
<— Transmitting SIP request (897 bytes) to UDP:192.168.87.11:5060 —>
INVITE sip:41040@192.168.87.11:5060 SIP/2.0
Via: SIP/2.0/UDP 192.168.89.1:5060;rport;branch=z9hG4bKPj679978e7-6540-4948-b80b-2847af0be15e
From: “42680” sip:42680@192.168.89.1;tag=87e98043-a980-4501-ab3c-c7d411e32224
To: sip:41040@192.168.87.11
Contact: sip:asterisk@192.168.89.1:5060
Call-ID: 190bb3f3-912d-4719-9da1-e7c9a369fa88
CSeq: 2619 INVITE
Allow: OPTIONS, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, REFER, MESSAGE, REGISTER
Supported: 100rel, timer, replaces, norefersub
Session-Expires: 1800
Min-SE: 90
Max-Forwards: 70
User-Agent: Asterisk PBX 13.6.0
Content-Type: application/sdp
Content-Length: 235

v=0
o=- 343162209 343162209 IN IP4 192.168.89.1
s=Asterisk
c=IN IP4 192.168.89.1
t=0 0
m=audio 10416 RTP/AVP 8 101
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=maxptime:150
a=sendrecv

<— Received SIP response (371 bytes) from UDP:192.168.87.11:5060 —>
SIP/2.0 100 Trying
Via: SIP/2.0/UDP 192.168.89.1:5060;rport=5060;received=192.168.89.1;branch=z9hG4bKPj679978e7-6540-4948-b80b-2847af0be15e
Call-ID: 190bb3f3-912d-4719-9da1-e7c9a369fa88
From: “42680” sip:42680@192.168.89.1;tag=87e98043-a980-4501-ab3c-c7d411e32224
To: sip:41040@192.168.87.11
CSeq: 2619 INVITE
Server: Asterisk PBX 13.6.0
Content-Length: 0

<— Transmitting SIP request (432 bytes) to UDP:195.162.X.X:5060 —>
OPTIONS sip:195.162.X.X:5060 SIP/2.0
Via: SIP/2.0/UDP 195.162.X.X:5060;rport;branch=z9hG4bKPj34e71d17-504d-43e4-b7de-9a0653905c4f
From: sip:asterisk@195.162.X.X;tag=3901a13a-8815-417e-a1ed-6144cc865b56
To: sip:195.162.X.X
Contact: sip:asterisk@195.162.X.X:5060
Call-ID: 957f0c3d-5409-4c56-b303-fe7f8e6477c2
CSeq: 1261 OPTIONS
Max-Forwards: 70
User-Agent: Asterisk PBX 13.6.0
Content-Length: 0

<— Transmitting SIP request (432 bytes) to UDP:195.162.X.X:5060 —>
OPTIONS sip:195.162.X.X:5060 SIP/2.0
Via: SIP/2.0/UDP 195.162.X.X:5060;rport;branch=z9hG4bKPj34e71d17-504d-43e4-b7de-9a0653905c4f
From: sip:asterisk@195.162.X.X;tag=3901a13a-8815-417e-a1ed-6144cc865b56
To: sip:195.162.X.X
Contact: sip:asterisk@195.162.X.X:5060
Call-ID: 957f0c3d-5409-4c56-b303-fe7f8e6477c2
CSeq: 1261 OPTIONS
Max-Forwards: 70
User-Agent: Asterisk PBX 13.6.0
Content-Length: 0

<— Received SIP response (585 bytes) from UDP:195.162.X.X:5060 —>
SIP/2.0 200 OK
Via: SIP/2.0/UDP 195.162.X.X:5060;branch=z9hG4bKPj34e71d17-504d-43e4-b7de-9a0653905c4f;rport=5060
From: sip:asterisk@195.162.X.X;tag=3901a13a-8815-417e-a1ed-6144cc865b56
To: sip:195.162.X.X
Call-ID: 957f0c3d-5409-4c56-b303-fe7f8e6477c2
CSeq: 1261 OPTIONS
Contact: sip:ANONYMOUS@195.162.X.X:5060
Allow: INVITE,ACK,CANCEL,BYE,REGISTER,REFER,INFO,SUBSCRIBE,NOTIFY,PRACK,UPDATE,OPTIONS
Accept: application/sdp, application/isup, application/dtmf, application/dtmf-relay, multipart/mixed
Supported: timer,100rel,replaces
Content-Length: 0

<— Received SIP response (585 bytes) from UDP:195.162.X.X:5060 —>
SIP/2.0 200 OK
Via: SIP/2.0/UDP 195.162.X.X:5060;branch=z9hG4bKPj34e71d17-504d-43e4-b7de-9a0653905c4f;rport=5060
From: sip:asterisk@195.162.X.X;tag=3901a13a-8815-417e-a1ed-6144cc865b56
To: sip:195.162.X.X
Call-ID: 957f0c3d-5409-4c56-b303-fe7f8e6477c2
CSeq: 1261 OPTIONS
Contact: sip:ANONYMOUS@195.162.X.X:5060
Allow: INVITE,ACK,CANCEL,BYE,REGISTER,REFER,INFO,SUBSCRIBE,NOTIFY,PRACK,UPDATE,OPTIONS
Accept: application/sdp, application/isup, application/dtmf, application/dtmf-relay, multipart/mixed
Supported: timer,100rel,replaces
Content-Length: 0

<— Received SIP response (436 bytes) from UDP:192.168.87.11:5060 —>
SIP/2.0 603 Decline
Via: SIP/2.0/UDP 192.168.89.1:5060;rport=5060;received=192.168.89.1;branch=z9hG4bKPj679978e7-6540-4948-b80b-2847af0be15e
Call-ID: 190bb3f3-912d-4719-9da1-e7c9a369fa88
From: “42680” sip:42680@192.168.89.1;tag=87e98043-a980-4501-ab3c-c7d411e32224
To: sip:41040@192.168.87.11;tag=6bafac6f-5432-4bc6-b8ef-513a85ca1115
CSeq: 2619 INVITE
Server: Asterisk PBX 13.6.0
Reason: Q.850;cause=0
Content-Length: 0

<— Transmitting SIP request (426 bytes) to UDP:192.168.87.11:5060 —>
ACK sip:41040@192.168.87.11:5060 SIP/2.0
Via: SIP/2.0/UDP 192.168.89.1:5060;rport;branch=z9hG4bKPj679978e7-6540-4948-b80b-2847af0be15e
From: “42680” sip:42680@192.168.89.1;tag=87e98043-a980-4501-ab3c-c7d411e32224
To: sip:41040@192.168.87.11;tag=6bafac6f-5432-4bc6-b8ef-513a85ca1115
Call-ID: 190bb3f3-912d-4719-9da1-e7c9a369fa88
CSeq: 2619 ACK
Max-Forwards: 70
User-Agent: Asterisk PBX 13.6.0
Content-Length: 0

<— Transmitting SIP response (414 bytes) to UDP:172.17.107.67:5060 —>
SIP/2.0 503 Service Unavailable
Via: SIP/2.0/UDP 172.17.107.67:5060;rport=5060;received=172.17.107.67;branch=z9hG4bK1721025199
Call-ID: 1485638553-5060-45@BHC.BH.BAH.GH
From: “42680” sip:42680@astp4.internal.xyz;tag=992053134
To: sip:41040@astp4.internal.xyz;tag=b5eb7e81-29ba-4e17-9239-268d00057f6a
CSeq: 441 INVITE
Server: Asterisk PBX 13.6.0
Reason: Q.850;cause=34
Content-Length: 0

<— Received SIP request (344 bytes) from UDP:172.17.107.67:5060 —>
ACK sip:41040@astp4.internal.xyz SIP/2.0
Via: SIP/2.0/UDP 172.17.107.67:5060;branch=z9hG4bK1721025199;rport
From: “42680” sip:42680@astp4.internal.xyz;tag=992053134
To: sip:41040@astp4.internal.x;tag=b5eb7e81-29ba-4e17-9239-268d00057f6a
Call-ID: 1485638553-5060-45@BHC.BH.BAH.GH
CSeq: 441 ACK
Content-Length: 0

astp4*CLI>
Disconnected from Asterisk server[/code]

I have a more detailed trace when a call is received on the 2nd server:

*CLI> -- Executing [41040@internal:1] Verbose("PJSIP/astp4-00000006", "Incoming callerid is 42680 naar 41040.") in new stack Incoming callerid is 42680 naar 41040. -- Executing [41040@internal:2] Answer("PJSIP/astp4-00000006", "") in new stack -- Executing [41040@internal:3] Dial("PJSIP/astp4-00000006", "PJSIP/41040,25") in new stack -- Called PJSIP/41040 -- PJSIP/astp4-00000006 requested media update control 26, passing it to PJSIP/41040-00000007 == Spawn extension (internal, 41040, 3) exited non-zero on 'PJSIP/astp4-00000006' Asterisk cleanly ending (0).

26 => AST_CONTROL_SRCCHANGE

So Asterisk knows that the source IP has changed?

Your second server appears to be binding explicitly to “192.168.89.1” which is the interface it would then default to sending traffic over, since it’s not bound to an 192.168.87.0/24 address on the system. Since it’s an alias the system would still end up sending it out fine but the SIP contents would have the “192.168.89.1” address in it causing subsequent requests from the other party to not be received. If you add another transport explicitly binding to an address in 192.168.87.0/24 on the system does stuff then work as expected?

I’ve created a dummy transport on the second server (192.168.89.1) as you requested. I now have 3 transports.

[code]
[transport-udp]
type=transport
protocol=udp
bind=192.168.89.1:5060
local_net=192.168.89.0/24

[transport-dummy]
type=transport
protocol=udp
bind=192.168.87.1:5060
local_net=192.168.87.0/24

[transport-udp-out]
type=transport
protocol=udp
bind=195.162.X.X:5060
local_net=195.162.X.X/29[/code]
Since a client can’t bind to transport-dummy (since the IP is not an actual interface on this server), it doesn’t seem to show up with “pjsip show transports”?

Transport: transport-udp udp 0 0 192.168.89.1:5060 Transport: transport-udp-out udp 0 0 195.162.X.X:5060

Eventually the following is shown during a trace on the initiating host (connected 2nd server):

[code]
<— Transmitting SIP response (909 bytes) to UDP:195.162.X.X:5060 —>
SIP/2.0 404 Not Found
Via: SIP/2.0/UDP 192.168.89.1:5060;rport=5060;received=195.162.X.X;branch=z9hG4bKPj2835eb03-0070-46f8-9430-9d741a3371f4
Call-ID: 434a73a3-b537-45e9-9c22-d7b8cc09f42a
From: sip:asterisk@195.162.X.X;tag=5aa8b918-1d08-4662-9b2b-b9c0ed5cb3e4
To: sip:s@192.168.89.1;tag=z9hG4bKPj2835eb03-0070-46f8-9430-9d741a3371f4
CSeq: 39864 OPTIONS
Accept: application/sdp, application/xpidf+xml, application/cpim-pidf+xml, application/dialog-info+xml, application/simple-message-summary, application/pidf+xml, application/dialog-info+xml, application/pidf+xml, application/simple-message-summary, message/sipfrag;version=2.0
Allow: OPTIONS, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, REFER, MESSAGE, REGISTER
Supported: 100rel, timer, replaces, norefersub
Accept-Encoding: text/plain
Accept-Language: en
Server: Asterisk PBX 13.6.0
Content-Length: 0

<— Received SIP response (909 bytes) from UDP:192.168.89.1:5060 —>
SIP/2.0 404 Not Found
Via: SIP/2.0/UDP 192.168.89.1:5060;rport=5060;received=195.162.X.X;branch=z9hG4bKPj2835eb03-0070-46f8-9430-9d741a3371f4
Call-ID: 434a73a3-b537-45e9-9c22-d7b8cc09f42a
From: sip:asterisk@195.162.X.X;tag=5aa8b918-1d08-4662-9b2b-b9c0ed5cb3e4
To: sip:s@192.168.89.1;tag=z9hG4bKPj2835eb03-0070-46f8-9430-9d741a3371f4
CSeq: 39864 OPTIONS
Accept: application/sdp, application/xpidf+xml, application/cpim-pidf+xml, application/dialog-info+xml, application/simple-message-summary, application/pidf+xml, application/dialog-info+xml, application/pidf+xml, application/simple-message-summary, message/sipfrag;version=2.0
Allow: OPTIONS, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, REFER, MESSAGE, REGISTER
Supported: 100rel, timer, replaces, norefersub
Accept-Encoding: text/plain
Accept-Language: en
Server: Asterisk PBX 13.6.0
Content-Length: 0[/code]

The problem still remains…

I’m confused at your network layout and what you want to occur then…

Can you step back and tell me exactly what it is you are expecting to happen/see that is not?

Thanks for your help. Let me clarify some things…

I have 2 asterisk servers (192.168.87.11) and (192.168.89.1) both connected to the internal network on em1. Then, I have a SIP trunk that is connected to each server on em2 (layer 2 network). The IP’s of the provider’s PBX are: 195.162.X.X and 195.162.X.X.

I’ve tried the following scenario’s.

Calls from external --> inbound (via provider’s trunk): Working
So the call comes in at 195.162.X.X or 195.162.X.X on em2 of one of the 2 asteriskservers (random).

Calls between internal devices (which are NOT supposed to use the providers trunk), NOT working.
In the scenario’s above, I’ve described a device 1 (172.17.107.67, number 42680) registered on 2nd server (192.168.89.1) which is trying to call to device 2 (172.17.105.102, number 41040) registered on 1st server (192.168.87.11). This call doesn’t work. The second device starts ringing, but I’m not able to pickup the phone. Errors above are shown. The INVITE contains the provider’s SIP trunk, which is not supposed to be mentioned at all.

[color=#008000]EDIT: looks like I’ve found the solution. Direct_media had to be set to “no” on the regular server trunks.[/color]