Skip to content

Conversation

@sobomax
Copy link
Contributor

@sobomax sobomax commented Dec 1, 2025

Summary
Port add_contact_alias() and handle_ruri_alias() functions

Details
Those are slightly better version of the fix_nated_contact() originating from Kamailio.

The problem with fix_nated_contact() is that it could cause RURI for in-dialog requests contain a different IP address as compared to the Contact in the initial INVITE.

Most endpoints are fine with that, however tere are some, notably MS Teams, which would reject such request with:

SIP/2.0 500 Internal Server Error
Reason: Q.850;cause=47;text="76a7afc3-d033-4988-9000-f70b41e4db1b;RURI in request has invalid FQDN value"

The full exchange when using fix_nated_contact() is as follows:

UA->OpenSIPS (initial INVITE):

opensips[NNNN]: RECEIVED message from 10.2.80.32:5060:
INVITE sip:[...]
Contact: <sip:[...]@10.2.80.22:5060>
                    ^^^^^^^^^^

OpenSIPS->UA:

SIP/2.0 100 Giving it a try
SIP/2.0 200 OK

UA->OpenSIPS:

ACK sip:[...]

OpenSIPS->UA (re-INVITE):

opensips[NNNN]: SENDING message to 10.2.80.32:5060:
INVITE sip:[...]@10.2.80.32:5060 SIP/2.0
                 ^^^^^^^^^^

UA->OpenSIPS:

SIP/2.0 500 Internal Server Error

Solution
Use add_contact_alias() in the INVITE/200 OK paths and handle_ruri_alias() in in-dialog request path.

UA->OpenSIPS (initial INVITE):

opensips[NNNN]: RECEIVED message from 10.2.80.32:5060:
INVITE sip:[...]
Contact: <sip:[...]@10.2.80.22:5060>
                    ^^^^^^^^^^

OpenSIPS->UA:

SIP/2.0 100 Giving it a try

OpenSIPS->B2BUA (initial INVITE):

opensips[NNNN]: SENDING message to [...]:
INVITE sip:[...]
Contact: <sip:[...]@10.2.80.22:5060;alias=10.2.80.32~5060~1>
                    ^^^^^^^^^^

B2BUA->OpenSIPS (re-INVITE):

opensips[NNNN]: RECEIVED message from [...]:
INVITE sip:[...]@10.2.80.22:5060;alias=10.2.80.32~5060~1 SIP/2.0
                 ^^^^^^^^^^

OpenSIPS->UA (re-INVITE):

opensips[NNNN]: SENDING message to 10.2.80.32:5060:
                                   ^^^^^^^^^^
INVITE sip:[...]@10.2.80.22:5060 SIP/2.0
                 ^^^^^^^^^^

Compatibility
Should not be any if used correctly. Special test case for the voiptests has been created and will be enabled once the change is merged into the opensips/master.

Those are slightly better version of the fix_nated_contact()
originating from Kamailio.

The problem with fix_nated_contact() is that it could cause
RURI for in-dialog requests contain a different IP address as
compared to the Contact in the initial INVITE.

Most endpoints are fine with that, however tere are some,
notably MS Teams, which would reject such request with:

SIP/2.0 500 Internal Server Error
Reason: Q.850;cause=47;text="76a7afc3-d033-4988-9000-f70b41e4db1b;RURI in request has invalid FQDN value"

The full exchange when using fix_nated_contact() is as follows:

UA->OpenSIPS (initial INVITE):

opensips[42757]: RECEIVED message from 10.2.80.32:5060:
INVITE sip:[...]
Contact: <sip:[...]@10.2.80.22:5060>
                    ^^^^^^^^^^

OpenSIPS->UA:

SIP/2.0 100 Giving it a try

SIP/2.0 200 OK

UA->OpenSIPS:

ACK sip:[...]

OpenSIPS->UA (re-INVITE):

opensips[42759]: SENDING message to 10.2.80.32:5060:
INVITE sip:[...]@10.2.80.32:5060 SIP/2.0
                 ^^^^^^^^^^

UA->OpenSIPS:

SIP/2.0 500 Internal Server Error
@sobomax sobomax requested a review from liviuchircu December 1, 2025 20:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant