Which nat_uac_test() flags should be used for accurate NAT detection in onreply_route?

xf han via sr-users <[email protected]> Mon, 01 Jun 2026 07:24:20 -0000
Newsgroups gmane.comp.voip.ser
Message-ID <[email protected]>
Hello,

I would like to ask about the best practice for NAT detection in Kamailio, especially in `onreply_route`.

In `request_route`, I usually use the following combination:

    nat_uac_test("18")

which means `2 + 16`:

- `2`: compare the address in the top Via header with the source IP address of the SIP message. If the Via header does not contain a port, the default SIP port 5060 is used.
- `16`: test whether the source port is different from the port in the Via header. If the Via header does not contain a port, the default SIP port 5060 is used.

This is similar to the `aggressive-nat-detection` option in a FreeSWITCH SIP profile, which also checks the Via header.

I also understand that flag `64` can be used to detect whether the source connection is WebSocket, and that is fine.

However, I am not sure what the correct approach is in `onreply_route`.

For SIP replies, should I still use `nat_uac_test("18")`, or are flags `2` and `16` not reliable in `onreply_route` because the Via header and source address/port have a different meaning for replies?

Which `nat_uac_test()` flags are recommended in `onreply_route` for accurate NAT detection?

For example, should I use a different combination, such as checking the Contact header or SDP instead of Via-based tests?

Any guidance or example configuration would be appreciated.

Thank you.
__________________________________________________________
Kamailio - Users Mailing List - Non Commercial Discussions -- [email protected]
To unsubscribe send an email to [email protected]
Important: keep the mailing list in the recipients, do not reply only to the sender!