Hi! Do you have any idea why Kamailio fills incorrect address into Contact header? And how to avoid it?
On Sunday 30 June 2019 23:11:22 Pali Rohár wrote:
Hi!
I detected strange problem that sip.linphone.org refuse to accept presence information re-transmitted by kamailio 4.4.4 server.
I debug this problem with tcpdump and I found out that problem is in kamailio which fills IPv6 address into UDP datagram and that datagram is sent via IPv4 socket to IPv4 address, to sip.linphone.org server. And sip.linphone.org server does not have IPv6 connectivity, so correctly return over IPv4 to sender just "400 Bad Contact Header" error.
On my server is running kamailio 4.4.4 from Debian Stretch and I can 100% reproduce this problem against public sip.linphone.org server.
My server has both IPv4 and IPv6 connectivity and kamailio is listening for both IPv4 and IPv6 connections.
So why is kamailio sending IPv6 address over IPv4 and therefore makes it impossible to communicate with non-IPv6 enabled servers? Looks like a problem with choosing default/correct socket for Contact header.
And how to fix this problem? Can you help me? I would like to have working interconnection with linphone servers.
Just to note I'm seeing this problem only for presence information packets. Other requests, like INVITE or MESSAGE seems to work.
Below is relevant tcpdump output. Some parts were replaced by {VAR}.
PS: I'm not subscribed to list, so please CC my address when sending reply. Thank you!
17:22:58.121719 IP (tos 0x10, ttl 64, id 21629, offset 0, flags [none], proto UDP (17), length 1266) {MY_IPV4_ADDRESS}.5060 > 91.121.209.194.5060: [bad udp cksum 0xa099 -> 0x9825!] SIP, length: 1238 NOTIFY sip:{REMOTE_NAME}@{REMOTE_USER_IPV4_ADDRESS}:5060;registering_acc=sip_linphone_org SIP/2.0 Via: SIP/2.0/UDP {MY_IPV4_ADDRESS};branch=z9hG4bK2b55.88f93c20000000000000000000000000.0 To: sip:{REMOTE_NAME}@sip.linphone.org;tag=75559182 From: sip:{MY_SIP_URI};tag=97d8e785fdf42bf9622a64c13c504961-2708 CSeq: 2 NOTIFY Call-ID: 26cf9d5c019af2dc3302b770887bcc2e@0:0:0:0:0:0:0:0 Route: sip:91.121.209.194:5060;lr Content-Length: 597 User-Agent: kamailio (4.4.4 (x86_64/linux)) Max-Forwards: 70 Event: presence Contact: sip:{MY_IPV6_ADDRESS}:5060;transport=udp Subscription-State: active;expires=3600 Content-Type: application/pidf+xml
<?xml version="1.0" encoding="UTF-8"?> <presence xmlns="urn:ietf:params:xml:ns:pidf" xmlns:dm="urn:ietf:params:xml:ns:pidf:data-model" xmlns:rpid="urn:ietf:params:xml:ns:pidf:rpid" entity="Pali <sip:{MY_SIP_URI}>"> <tuple id="sg89ae"> <status><basic>open</basic></status> <contact priority="0.8">Pali <sip:{MY_SIP_URI}></contact> </tuple> <tuple xmlns="urn:ietf:params:xml:ns:pidf" id="TA0C538B2"> <status> <basic>closed</basic> </status> <contact priority="1">sip:{MY_SIP_URI}</contact> <timestamp>2019-04-19T17:20:36+02:00</timestamp> </tuple> </presence>
17:22:58.151188 IP (tos 0x0, ttl 52, id 22949, offset 0, flags [none], proto UDP (17), length 373) 91.121.209.194.5060 > {MY_IPV4_ADDRESS}.5060: [udp sum ok] SIP, length: 345 SIP/2.0 400 Bad Contact Header Via: SIP/2.0/UDP {MY_IPV4_ADDRESS};branch=z9hG4bK2b55.88f93c20000000000000000000000000.0;rport=5060 From: sip:{MY_SIP_URI};tag=97d8e785fdf42bf9622a64c13c504961-2708 To: sip:{REMOTE_NAME}@sip.linphone.org;tag=75559182 Call-ID: 26cf9d5c019af2dc3302b770887bcc2e@0:0:0:0:0:0:0:0 CSeq: 2 NOTIFY Content-Length: 0