Asterisk and Kamailio integration


#1

Hello guys,

I’m following this guide: https://kb.asipto.com/asterisk:realtime:kamailio-4.0.x-asterisk-11.3.0-astdb

And I have the following schema:

Phone A -----> Kamailio -----> Asterisk -----> Phone B
(10.0.8.249) (10.0.6.123) (10.0.3.144) (10.0.13.23)

I think the flow it is like (because when UAC register to Asterisk, the contact points to Kamailio IP):

  1. Phone A --> Kamailio --> Asterisk
  2. Asterisk --> Kamailio --> Phone B

In attachment is the pcap of the call, kamailio config.

The problem is that I never receive ACK after 200 OK and call drops after 30 seconds?

Kamailio version 5.1 and Asterisk version 15.1

Phones are grandstreams and also tested with microsip soft client and same results… Like “Phone A” never sends ACK back

I tried different approaches to change contact header in 200 OK, because is Asterisk IP. Disable NAT handling. Different “nat_uac_test” flags, but still without success :frowning:

Also tried with this NAT detection and manage routes (again without any success) - source https://github.com/sipwise/kamailio/blob/master/etc/kamailio.cfg

Caller NAT detection

route[NATDETECT] {
#!ifdef WITH_NAT
force_rport();
if (nat_uac_test(“19”)) {
if (is_method(“REGISTER”)) {
fix_nated_register();
} else {
if(is_first_hop()) {
set_contact_alias();
}
}
setflag(FLT_NATS);
}
#!endif
return;
}

RTPProxy control and signaling updates for NAT traversal

route[NATMANAGE] {
#!ifdef WITH_NAT
if (is_request()) {
if(has_totag()) {
if(check_route_param(“nat=yes”)) {
setbflag(FLB_NATB);
}
}
}
if (!(isflagset(FLT_NATS) || isbflagset(FLB_NATB))) return;

if(nat_uac_test("8")) {
	rtpproxy_manage("co");
} else {
	rtpproxy_manage("cor");
}

if (is_request()) {
	if (!has_totag()) {
		if(t_is_branch_route()) {
			add_rr_param(";nat=yes");
		}
	}
}
if (is_reply()) {
	if(isbflagset(FLB_NATB)) {
		if(is_first_hop())
			set_contact_alias();
	}
}

#!endif
return;
}

Here is the sip trace:


#2

No. Time Source Destination Protocol Length Info
1 2018-09-27 08:14:27,743676 10.0.8.249 10.0.6.123 SIP/SDP 1156 Request: INVITE sip:71010@ving3-dev-kamailio.musala.com:5566;transport=tcp |

INVITE sip:71010@ving3-dev-kamailio.musala.com:5566;transport=tcp SIP/2.0
Message Header
Via: SIP/2.0/TCP 10.0.8.249:63823;branch=z9hG4bKPj1d99be979d18418f8b8fc26c413511af;alias
Max-Forwards: 70
From: sip:61003@ving3-dev-kamailio.musala.com;tag=fd1273f0373d4241be9fd59f55da6113
To: sip:71010@ving3-dev-kamailio.musala.com
Contact: sip:61003@10.0.8.249:53505;transport=TCP;ob
Call-ID: fcf1a883ccea421d8d519ad26502f7d6
CSeq: 2184 INVITE
Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS
Supported: replaces, 100rel, timer, norefersub
Session-Expires: 1800
Min-SE: 90
User-Agent: MicroSIP/3.19.5
Content-Type: application/sdp
Content-Length: 402
Message Body
Session Description Protocol
Session Description Protocol Version (v): 0
Owner/Creator, Session Id (o): - 3747024866 3747024866 IN IP4 10.0.8.249
Session Name (s): pjmedia
Bandwidth Information (b): AS:84
Time Description, active time (t): 0 0
Session Attribute (a): X-nat:0
Media Description, name and address (m): audio 4034 RTP/AVP 9 8 0 97 101
Connection Information ©: IN IP4 10.0.8.249
Bandwidth Information (b): TIAS:64000
Media Attribute (a): rtcp:4035 IN IP4 10.0.8.249
Media Attribute (a): sendrecv
Media Attribute (a): rtpmap:9 G722/8000
Media Attribute (a): rtpmap:8 PCMA/8000
Media Attribute (a): rtpmap:0 PCMU/8000
Media Attribute (a): rtpmap:97 iLBC/8000
Media Attribute (a): fmtp:97 mode=30
Media Attribute (a): rtpmap:101 telephone-event/8000
Media Attribute (a): fmtp:101 0-16
Media Attribute (a): ssrc:186069227 cname:0b1b2d645dc864d0

No. Time Source Destination Protocol Length Info
2 2018-09-27 08:14:27,744941 10.0.6.123 10.0.8.249 SIP 595 Status: 401 Unauthorized |

SIP/2.0 401 Unauthorized
Message Header
Via: SIP/2.0/TCP 10.0.8.249:63823;branch=z9hG4bKPj1d99be979d18418f8b8fc26c413511af;alias;rport=63823
From: sip:61003@ving3-dev-kamailio.musala.com;tag=fd1273f0373d4241be9fd59f55da6113
To: sip:71010@ving3-dev-kamailio.musala.com;tag=d9ada26916736fe87b7a3b5aac92b749.c10a
Call-ID: fcf1a883ccea421d8d519ad26502f7d6
CSeq: 2184 INVITE
WWW-Authenticate: Digest realm=“ving3-dev-kamailio.musala.com”, nonce=“W6xoX1usZzMh9DRW7IFbVqQWKgE4SsklPzdhYIA=”, qop=“auth”, algorithm=MD5
Server: VING
Content-Length: 0

No. Time Source Destination Protocol Length Info
3 2018-09-27 08:14:27,745416 10.0.8.249 10.0.6.123 SIP 490 Request: ACK sip:71010@ving3-dev-kamailio.musala.com:5566;transport=tcp |

ACK sip:71010@ving3-dev-kamailio.musala.com:5566;transport=tcp SIP/2.0
Message Header
Via: SIP/2.0/TCP 10.0.8.249:63823;branch=z9hG4bKPj1d99be979d18418f8b8fc26c413511af;alias
Max-Forwards: 70
From: sip:61003@ving3-dev-kamailio.musala.com;tag=fd1273f0373d4241be9fd59f55da6113
To: sip:71010@ving3-dev-kamailio.musala.com;tag=d9ada26916736fe87b7a3b5aac92b749.c10a
Call-ID: fcf1a883ccea421d8d519ad26502f7d6
CSeq: 2184 ACK
Content-Length: 0

No. Time Source Destination Protocol Length Info
4 2018-09-27 08:14:27,745593 10.0.8.249 10.0.6.123 SIP/SDP 1477 Request: INVITE sip:71010@ving3-dev-kamailio.musala.com:5566;transport=tcp |

INVITE sip:71010@ving3-dev-kamailio.musala.com:5566;transport=tcp SIP/2.0
Message Header
Via: SIP/2.0/TCP 10.0.8.249:63823;branch=z9hG4bKPjdde1ae7c273d440f9fa5e53f0db5b90d;alias
Max-Forwards: 70
From: sip:61003@ving3-dev-kamailio.musala.com;tag=fd1273f0373d4241be9fd59f55da6113
To: sip:71010@ving3-dev-kamailio.musala.com
Contact: sip:61003@10.0.8.249:53505;transport=TCP;ob
Call-ID: fcf1a883ccea421d8d519ad26502f7d6
CSeq: 2185 INVITE
Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS
Supported: replaces, 100rel, timer, norefersub
Session-Expires: 1800
Min-SE: 90
User-Agent: MicroSIP/3.19.5
[truncated]Authorization: Digest username=“61003”, realm=“ving3-dev-kamailio.musala.com”, nonce=“W6xoX1usZzMh9DRW7IFbVqQWKgE4SsklPzdhYIA=”, uri=“sip:71010@ving3-dev-kamailio.musala.com:5566;transport=tcp”, response="1d9db21e7f2c01afded9d
Content-Type: application/sdp
Content-Length: 402
Message Body
Session Description Protocol
Session Description Protocol Version (v): 0
Owner/Creator, Session Id (o): - 3747024866 3747024866 IN IP4 10.0.8.249
Session Name (s): pjmedia
Bandwidth Information (b): AS:84
Time Description, active time (t): 0 0
Session Attribute (a): X-nat:0
Media Description, name and address (m): audio 4034 RTP/AVP 9 8 0 97 101
Connection Information ©: IN IP4 10.0.8.249
Bandwidth Information (b): TIAS:64000
Media Attribute (a): rtcp:4035 IN IP4 10.0.8.249
Media Attribute (a): sendrecv
Media Attribute (a): rtpmap:9 G722/8000
Media Attribute (a): rtpmap:8 PCMA/8000
Media Attribute (a): rtpmap:0 PCMU/8000
Media Attribute (a): rtpmap:97 iLBC/8000
Media Attribute (a): fmtp:97 mode=30
Media Attribute (a): rtpmap:101 telephone-event/8000
Media Attribute (a): fmtp:101 0-16
Media Attribute (a): ssrc:186069227 cname:0b1b2d645dc864d0

No. Time Source Destination Protocol Length Info
5 2018-09-27 08:14:27,764427 10.0.6.123 10.0.8.249 SIP 438 Status: 100 trying – your call is important to us |

SIP/2.0 100 trying – your call is important to us
Message Header
Via: SIP/2.0/TCP 10.0.8.249:63823;branch=z9hG4bKPjdde1ae7c273d440f9fa5e53f0db5b90d;alias;rport=63823
From: sip:61003@ving3-dev-kamailio.musala.com;tag=fd1273f0373d4241be9fd59f55da6113
To: sip:71010@ving3-dev-kamailio.musala.com
Call-ID: fcf1a883ccea421d8d519ad26502f7d6
CSeq: 2185 INVITE
Server: VING
Content-Length: 0

No. Time Source Destination Protocol Length Info
6 2018-09-27 08:14:27,783742 10.0.6.123 10.0.3.144 SIP/SDP 1420 Request: INVITE sip:71010@ving3-dev-kamailio.musala.com:5566;transport=tcp |

INVITE sip:71010@ving3-dev-kamailio.musala.com:5566;transport=tcp SIP/2.0
Message Header
Record-Route: sip:10.0.6.123:5566;transport=tcp;lr=on;ftag=fd1273f0373d4241be9fd59f55da6113;nat=yes
Via: SIP/2.0/TCP 10.0.6.123:5566;branch=z9hG4bK2d83.4d12cc34432001052415c4a2ffd521a2.0;i=2
Via: SIP/2.0/TCP 10.0.8.249:63823;rport=63823;branch=z9hG4bKPjdde1ae7c273d440f9fa5e53f0db5b90d;alias
Max-Forwards: 69
From: sip:61003@ving3-dev-kamailio.musala.com;tag=fd1273f0373d4241be9fd59f55da6113
To: sip:71010@ving3-dev-kamailio.musala.com
Contact: sip:61003@10.0.8.249:63823;transport=TCP;ob
Call-ID: fcf1a883ccea421d8d519ad26502f7d6
CSeq: 2185 INVITE
Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS
Supported: replaces, 100rel, timer, norefersub
Session-Expires: 1800
Min-SE: 90
User-Agent: MicroSIP/3.19.5
Content-Type: application/sdp
Content-Length: 410
P-hint: (3)passed thru branch_route
Message Body
Session Description Protocol
Session Description Protocol Version (v): 0
Owner/Creator, Session Id (o): - 3747024866 3747024866 IN IP4 193.17.229.80
Session Name (s): pjmedia
Bandwidth Information (b): AS:84
Time Description, active time (t): 0 0
Session Attribute (a): X-nat:0
Media Description, name and address (m): audio 50990 RTP/AVP 9 8 0 97 101
Connection Information ©: IN IP4 193.17.229.80
Bandwidth Information (b): TIAS:64000
Media Attribute (a): rtcp:50991
Media Attribute (a): sendrecv
Media Attribute (a): rtpmap:9 G722/8000
Media Attribute (a): rtpmap:8 PCMA/8000
Media Attribute (a): rtpmap:0 PCMU/8000
Media Attribute (a): rtpmap:97 iLBC/8000
Media Attribute (a): fmtp:97 mode=30
Media Attribute (a): rtpmap:101 telephone-event/8000
Media Attribute (a): fmtp:101 0-16
Media Attribute (a): ssrc:186069227 cname:0b1b2d645dc864d0
Media Attribute (a): nortpproxy:yes

No. Time Source Destination Protocol Length Info
7 2018-09-27 08:14:27,796623 10.0.3.144 10.0.6.123 SIP 659 Status: 100 Trying |

SIP/2.0 100 Trying
Message Header
Via: SIP/2.0/TCP 10.0.6.123:5566;rport=33506;received=10.0.6.123;branch=z9hG4bK2d83.4d12cc34432001052415c4a2ffd521a2.0;i=2
Via: SIP/2.0/TCP 10.0.8.249:63823;rport=63823;branch=z9hG4bKPjdde1ae7c273d440f9fa5e53f0db5b90d;alias
Record-Route: sip:10.0.6.123:33506;transport=TCP;lr;ftag=fd1273f0373d4241be9fd59f55da6113;nat=yes
Call-ID: fcf1a883ccea421d8d519ad26502f7d6
From: sip:61003@ving3-dev-kamailio.musala.com;tag=fd1273f0373d4241be9fd59f55da6113
To: sip:71010@ving3-dev-kamailio.musala.com
CSeq: 2185 INVITE
Server: Asterisk PBX 15.1.2
Content-Length: 0

No. Time Source Destination Protocol Length Info
8 2018-09-27 08:14:27,817873 10.0.3.144 10.0.6.123 SIP/SDP 1444 Request: INVITE sip:71010@10.0.6.123:33506;transport=TCP |

INVITE sip:71010@10.0.6.123:33506;transport=TCP SIP/2.0
Message Header
Via: SIP/2.0/TCP 10.0.3.144:5566;rport;branch=z9hG4bKPjb2f6c5fa-af86-440d-aa56-5180ba9f11f1;alias
From: sip:10.0.3.144;tag=8acfe81e-5406-4fdd-88cd-94be97032897
To: sip:71010@10.0.6.123
Contact: sip:asterisk@10.0.3.144:5566;transport=TCP
Call-ID: f48cda08-7ddc-475a-bacb-e713cb869c3e
CSeq: 24589 INVITE
Allow: OPTIONS, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, REGISTER, MESSAGE, REFER
Supported: 100rel, timer, replaces, norefersub
Session-Expires: 1800
Min-SE: 90
Max-Forwards: 70
User-Agent: Asterisk PBX 15.1.2
Content-Type: application/sdp
Content-Length: 706
Message Body
Session Description Protocol
Session Description Protocol Version (v): 0
Owner/Creator, Session Id (o): - 553593879 553593879 IN IP4 10.0.3.144
Session Name (s): Asterisk
Connection Information ©: IN IP4 10.0.3.144
Time Description, active time (t): 0 0
Media Description, name and address (m): audio 17494 RTP/AVP 9 8 0 97 101
Media Attribute (a): ice-ufrag:0271e8d36e48c5751e044cbc1955a1c5
Media Attribute (a): ice-pwd:7f5bb8fc3aebd31922bc900438d087f3
Media Attribute (a): candidate:Hc98996dc 1 UDP 2130706431 fe80::f47f:41ff:feb8:2dc8 17494 typ host
Media Attribute (a): candidate:Ha000390 1 UDP 2130706431 10.0.3.144 17494 typ host
Media Attribute (a): candidate:Hc98996dc 2 UDP 2130706430 fe80::f47f:41ff:feb8:2dc8 17495 typ host
Media Attribute (a): candidate:Ha000390 2 UDP 2130706430 10.0.3.144 17495 typ host
Media Attribute (a): rtpmap:9 G722/8000
Media Attribute (a): rtpmap:8 PCMA/8000
Media Attribute (a): rtpmap:0 PCMU/8000
Media Attribute (a): rtpmap:97 iLBC/8000
Media Attribute (a): fmtp:97 mode=20
Media Attribute (a): rtpmap:101 telephone-event/8000
Media Attribute (a): fmtp:101 0-16
Media Attribute (a): ptime:20
Media Attribute (a): maxptime:150
Media Attribute (a): sendrecv

No. Time Source Destination Protocol Length Info
9 2018-09-27 08:14:27,819100 10.0.6.123 10.0.3.144 SIP 437 Status: 100 trying – your call is important to us |

SIP/2.0 100 trying – your call is important to us
Message Header
Via: SIP/2.0/TCP 10.0.3.144:5566;rport=5566;branch=z9hG4bKPjb2f6c5fa-af86-440d-aa56-5180ba9f11f1;alias;received=10.0.3.144
From: sip:10.0.3.144;tag=8acfe81e-5406-4fdd-88cd-94be97032897
To: sip:71010@10.0.6.123
Call-ID: f48cda08-7ddc-475a-bacb-e713cb869c3e
CSeq: 24589 INVITE
Server: VING
Content-Length: 0

No. Time Source Destination Protocol Length Info
10 2018-09-27 08:14:27,883793 10.0.6.123 10.0.13.23 SIP/SDP 1728 Request: INVITE sip:71010@10.0.13.23:5060;transport=tcp |

INVITE sip:71010@10.0.13.23:5060;transport=tcp SIP/2.0
Message Header
Record-Route: sip:10.0.6.123:5566;transport=tcp;lr=on;ftag=8acfe81e-5406-4fdd-88cd-94be97032897;nat=yes
Via: SIP/2.0/TCP 10.0.6.123:5566;branch=z9hG4bK7213.f3002b09662ea2ed11fec68e8340bb56.0;i=3
Via: SIP/2.0/TCP 10.0.3.144:5566;received=10.0.3.144;rport=5566;branch=z9hG4bKPjb2f6c5fa-af86-440d-aa56-5180ba9f11f1;alias
From: sip:10.0.3.144;tag=8acfe81e-5406-4fdd-88cd-94be97032897
To: sip:71010@10.0.6.123
Contact: sip:asterisk@10.0.3.144:5566;transport=TCP
Call-ID: f48cda08-7ddc-475a-bacb-e713cb869c3e
CSeq: 24589 INVITE
Allow: OPTIONS, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, REGISTER, MESSAGE, REFER
Supported: 100rel, timer, replaces, norefersub
Session-Expires: 1800
Min-SE: 90
Max-Forwards: 69
User-Agent: Asterisk PBX 15.1.2
Content-Type: application/sdp
Content-Length: 730
P-hint: (3)passed thru branch_route
Message Body
Session Description Protocol
Session Description Protocol Version (v): 0
Owner/Creator, Session Id (o): - 553593879 553593879 IN IP4 193.17.229.80
Session Name (s): Asterisk
Connection Information ©: IN IP4 193.17.229.80
Time Description, active time (t): 0 0
Media Description, name and address (m): audio 50928 RTP/AVP 9 8 0 97 101
Media Attribute (a): ice-ufrag:0271e8d36e48c5751e044cbc1955a1c5
Media Attribute (a): ice-pwd:7f5bb8fc3aebd31922bc900438d087f3
Media Attribute (a): candidate:Hc98996dc 1 UDP 2130706431 fe80::f47f:41ff:feb8:2dc8 17494 typ host
Media Attribute (a): candidate:Ha000390 1 UDP 2130706431 10.0.3.144 17494 typ host
Media Attribute (a): candidate:Hc98996dc 2 UDP 2130706430 fe80::f47f:41ff:feb8:2dc8 17495 typ host
Media Attribute (a): candidate:Ha000390 2 UDP 2130706430 10.0.3.144 17495 typ host
Media Attribute (a): rtpmap:9 G722/8000
Media Attribute (a): rtpmap:8 PCMA/8000
Media Attribute (a): rtpmap:0 PCMU/8000
Media Attribute (a): rtpmap:97 iLBC/8000
Media Attribute (a): fmtp:97 mode=20
Media Attribute (a): rtpmap:101 telephone-event/8000
Media Attribute (a): fmtp:101 0-16
Media Attribute (a): ptime:20
Media Attribute (a): maxptime:150
Media Attribute (a): sendrecv
Media Attribute (a): nortpproxy:yes

No. Time Source Destination Protocol Length Info
11 2018-09-27 08:14:27,910483 10.0.13.23 10.0.6.123 SIP 651 Status: 100 Trying |

SIP/2.0 100 Trying
Message Header
Via: SIP/2.0/TCP 10.0.6.123:5566;branch=z9hG4bK7213.f3002b09662ea2ed11fec68e8340bb56.0;i=3
Via: SIP/2.0/TCP 10.0.3.144:5566;received=10.0.3.144;rport=5566;branch=z9hG4bKPjb2f6c5fa-af86-440d-aa56-5180ba9f11f1;alias
From: sip:10.0.3.144;tag=8acfe81e-5406-4fdd-88cd-94be97032897
To: sip:71010@10.0.6.123
Call-ID: f48cda08-7ddc-475a-bacb-e713cb869c3e
CSeq: 24589 INVITE
Supported: replaces, path, timer
User-Agent: Grandstream GXP1620 1.0.4.128
Allow: INVITE, ACK, OPTIONS, CANCEL, BYE, SUBSCRIBE, NOTIFY, INFO, REFER, UPDATE, MESSAGE
Content-Length: 0

No. Time Source Destination Protocol Length Info
12 2018-09-27 08:14:27,950979 10.0.13.23 10.0.6.123 SIP 851 Status: 180 Ringing |

SIP/2.0 180 Ringing
Message Header
Via: SIP/2.0/TCP 10.0.6.123:5566;branch=z9hG4bK7213.f3002b09662ea2ed11fec68e8340bb56.0;i=3
Via: SIP/2.0/TCP 10.0.3.144:5566;received=10.0.3.144;rport=5566;branch=z9hG4bKPjb2f6c5fa-af86-440d-aa56-5180ba9f11f1;alias
Record-Route: sip:10.0.6.123:5566;transport=tcp;lr=on;ftag=8acfe81e-5406-4fdd-88cd-94be97032897;nat=yes
From: sip:10.0.3.144;tag=8acfe81e-5406-4fdd-88cd-94be97032897
To: sip:71010@10.0.6.123;tag=271292769
Call-ID: f48cda08-7ddc-475a-bacb-e713cb869c3e
CSeq: 24589 INVITE
Contact: sip:71010@10.0.13.23:5060;transport=tcp
Supported: replaces, path, timer
User-Agent: Grandstream GXP1620 1.0.4.128
Allow-Events: talk, hold
Allow: INVITE, ACK, OPTIONS, CANCEL, BYE, SUBSCRIBE, NOTIFY, INFO, REFER, UPDATE, MESSAGE
Content-Length: 0

No. Time Source Destination Protocol Length Info
13 2018-09-27 08:14:27,951605 10.0.6.123 10.0.3.144 SIP 799 Status: 180 Ringing |

SIP/2.0 180 Ringing
Message Header
Via: SIP/2.0/TCP 10.0.3.144:5566;received=10.0.3.144;rport=5566;branch=z9hG4bKPjb2f6c5fa-af86-440d-aa56-5180ba9f11f1;alias
Record-Route: sip:10.0.6.123:5566;transport=tcp;lr=on;ftag=8acfe81e-5406-4fdd-88cd-94be97032897;nat=yes
From: sip:10.0.3.144;tag=8acfe81e-5406-4fdd-88cd-94be97032897
To: sip:71010@10.0.6.123;tag=271292769
Call-ID: f48cda08-7ddc-475a-bacb-e713cb869c3e
CSeq: 24589 INVITE
Contact: sip:71010@10.0.13.23:47790;transport=tcp
Supported: replaces, path, timer
User-Agent: Grandstream GXP1620 1.0.4.128
Allow-Events: talk, hold
Allow: INVITE, ACK, OPTIONS, CANCEL, BYE, SUBSCRIBE, NOTIFY, INFO, REFER, UPDATE, MESSAGE
Content-Length: 0
P-hint: (3)passed thru onreplay_route

No. Time Source Destination Protocol Length Info
14 2018-09-27 08:14:27,956687 10.0.3.144 10.0.6.123 SIP 858 Status: 180 Ringing |

SIP/2.0 180 Ringing
Message Header
Via: SIP/2.0/TCP 10.0.6.123:5566;rport=33506;received=10.0.6.123;branch=z9hG4bK2d83.4d12cc34432001052415c4a2ffd521a2.0;i=2
Via: SIP/2.0/TCP 10.0.8.249:63823;rport=63823;branch=z9hG4bKPjdde1ae7c273d440f9fa5e53f0db5b90d;alias
Record-Route: sip:10.0.6.123:33506;transport=TCP;lr;ftag=fd1273f0373d4241be9fd59f55da6113;nat=yes
Call-ID: fcf1a883ccea421d8d519ad26502f7d6
From: sip:61003@ving3-dev-kamailio.musala.com;tag=fd1273f0373d4241be9fd59f55da6113
To: sip:71010@ving3-dev-kamailio.musala.com;tag=c58be9d7-5cfa-48dc-a29e-c85b2e008a2e
CSeq: 2185 INVITE
Server: Asterisk PBX 15.1.2
Contact: sip:10.0.3.144:5566;transport=TCP
Allow: OPTIONS, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, REGISTER, MESSAGE, REFER
Content-Length: 0

No. Time Source Destination Protocol Length Info
15 2018-09-27 08:14:27,957079 10.0.6.123 10.0.8.249 SIP 761 Status: 180 Ringing |

SIP/2.0 180 Ringing
Message Header
Via: SIP/2.0/TCP 10.0.8.249:63823;rport=63823;branch=z9hG4bKPjdde1ae7c273d440f9fa5e53f0db5b90d;alias
Record-Route: sip:10.0.6.123:33506;transport=TCP;lr;ftag=fd1273f0373d4241be9fd59f55da6113;nat=yes
Call-ID: fcf1a883ccea421d8d519ad26502f7d6
From: sip:61003@ving3-dev-kamailio.musala.com;tag=fd1273f0373d4241be9fd59f55da6113
To: sip:71010@ving3-dev-kamailio.musala.com;tag=c58be9d7-5cfa-48dc-a29e-c85b2e008a2e
CSeq: 2185 INVITE
Server: Asterisk PBX 15.1.2
Contact: sip:10.0.3.144:5566;transport=TCP
Allow: OPTIONS, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, REGISTER, MESSAGE, REFER
Content-Length: 0
P-hint: (3)passed thru onreplay_route

No. Time Source Destination Protocol Length Info
16 2018-09-27 08:14:29,569114 10.0.13.23 10.0.6.123 SIP/SDP 1209 Status: 200 OK |

SIP/2.0 200 OK
Message Header
Via: SIP/2.0/TCP 10.0.6.123:5566;branch=z9hG4bK7213.f3002b09662ea2ed11fec68e8340bb56.0;i=3
Via: SIP/2.0/TCP 10.0.3.144:5566;received=10.0.3.144;rport=5566;branch=z9hG4bKPjb2f6c5fa-af86-440d-aa56-5180ba9f11f1;alias
Record-Route: sip:10.0.6.123:5566;transport=tcp;lr=on;ftag=8acfe81e-5406-4fdd-88cd-94be97032897;nat=yes
From: sip:10.0.3.144;tag=8acfe81e-5406-4fdd-88cd-94be97032897
To: sip:71010@10.0.6.123;tag=271292769
Call-ID: f48cda08-7ddc-475a-bacb-e713cb869c3e
CSeq: 24589 INVITE
Contact: sip:71010@10.0.13.23:5060;transport=tcp
Supported: replaces, path, timer
User-Agent: Grandstream GXP1620 1.0.4.128
Session-Expires: 1800;refresher=uac
Require: timer
Allow: INVITE, ACK, OPTIONS, CANCEL, BYE, SUBSCRIBE, NOTIFY, INFO, REFER, UPDATE, MESSAGE
Content-Type: application/sdp
Content-Length: 301
Message Body
Session Description Protocol
Session Description Protocol Version (v): 0
Owner/Creator, Session Id (o): 71010 8000 8000 IN IP4 10.0.13.23
Session Name (s): SIP Call
Connection Information ©: IN IP4 10.0.13.23
Time Description, active time (t): 0 0
Media Description, name and address (m): audio 5004 RTP/AVP 9 0 8 97 101
Media Attribute (a): sendrecv
Media Attribute (a): rtpmap:9 G722/8000
Media Attribute (a): ptime:20
Media Attribute (a): rtpmap:0 PCMU/8000
Media Attribute (a): rtpmap:8 PCMA/8000
Media Attribute (a): rtpmap:97 iLBC/8000
Media Attribute (a): fmtp:97 mode=30
Media Attribute (a): rtpmap:101 telephone-event/8000
Media Attribute (a): fmtp:101 0-15

No. Time Source Destination Protocol Length Info
17 2018-09-27 08:14:29,583295 10.0.6.123 10.0.3.144 SIP/SDP 1182 [TCP ACKed unseen segment] [TCP Previous segment not captured] Status: 200 OK |

SIP/2.0 200 OK
Message Header
Via: SIP/2.0/TCP 10.0.3.144:5566;received=10.0.3.144;rport=5566;branch=z9hG4bKPjb2f6c5fa-af86-440d-aa56-5180ba9f11f1;alias
Record-Route: sip:10.0.6.123:5566;transport=tcp;lr=on;ftag=8acfe81e-5406-4fdd-88cd-94be97032897;nat=yes
From: sip:10.0.3.144;tag=8acfe81e-5406-4fdd-88cd-94be97032897
To: sip:71010@10.0.6.123;tag=271292769
Call-ID: f48cda08-7ddc-475a-bacb-e713cb869c3e
CSeq: 24589 INVITE
Contact: sip:71010@10.0.13.23:47790;transport=tcp
Supported: replaces, path, timer
User-Agent: Grandstream GXP1620 1.0.4.128
Session-Expires: 1800;refresher=uac
Require: timer
Allow: INVITE, ACK, OPTIONS, CANCEL, BYE, SUBSCRIBE, NOTIFY, INFO, REFER, UPDATE, MESSAGE
Content-Type: application/sdp
Content-Length: 326
P-hint: (3)passed thru onreplay_route
Message Body
Session Description Protocol
Session Description Protocol Version (v): 0
Owner/Creator, Session Id (o): 71010 8000 8000 IN IP4 193.17.229.80
Session Name (s): SIP Call
Connection Information ©: IN IP4 193.17.229.80
Time Description, active time (t): 0 0
Media Description, name and address (m): audio 50166 RTP/AVP 9 0 8 97 101
Media Attribute (a): sendrecv
Media Attribute (a): rtpmap:9 G722/8000
Media Attribute (a): ptime:20
Media Attribute (a): rtpmap:0 PCMU/8000
Media Attribute (a): rtpmap:8 PCMA/8000
Media Attribute (a): rtpmap:97 iLBC/8000
Media Attribute (a): fmtp:97 mode=30
Media Attribute (a): rtpmap:101 telephone-event/8000
Media Attribute (a): fmtp:101 0-15
Media Attribute (a): nortpproxy:yes


#3

Hello,

I somehow managed with this situations. Asterisk changed port in “Record-Route” field and the phone was trying to connect to kamailio trough thas port. So somehow I fixed it.

Is there any method to “make connection” between Kamailio and Asterisk?

My setup is:

  1. All phones are register to Kamailio
  2. On every REGISTER request, Kamailio send new REGISTER (from scratch) to Asterisk and all phones (endpoints) have Contact: <sip_number>@<kamailio_ip>:<kamailio_port>
  3. In Asterisk configuration I have one endpoint “kamailio” that had a AORs of all other endpoints

Example:
[ving3-dev-kamailio]
type=endpoint
transport=transport-tcp
context=simple-pjsip
disallow=all
allow=g722
allow=alaw
allow=ulaw
aors=ving3-dev-kamailio,71001,71002,71003,71004
direct_media=no
rewrite_contact=yes

Is there any other way to make such a setup?

Thanks in advance.

Best regards


#4

In order to help you further, post your whole kamailio.cfg from Kamailio and extensions.conf from Asterisk. For obvious reasons change the passwdos and real credentials that you will post.


#5

maybe you can refer this as a reference:
https://dsiprouter.readthedocs.io/en/latest/configuring.html