Re: Which nat_uac_test() flags should be used for accurate NAT detection in onreply_route?
Henning Westerholt via sr-users <[email protected]> Mon, 1 Jun 2026 12:30:35 +0000
| Newsgroups | gmane.comp.voip.ser |
|---|---|
| Message-ID | <AS8PR07MB72218BCFCE4028ADAE5765EABF152@AS8PR07MB7221.eurprd07.prod.outlook.com> |
Hello, Usually, you can do only limited NAT detection in the reply handling path, as you rely on the request route to detect it for you and then store it e.g. in some flags or a database column. Compare to the default configuration for an example. Cheers, Henning > -----Original Message----- > From: xf han via sr-users <[email protected]> > Sent: Montag, 1. Juni 2026 09:24 > To: [email protected] > Cc: xf han <[email protected]> > Subject: [SR-Users] Which nat_uac_test() flags should be used for accurate > NAT detection in onreply_route? > > 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 -- sr- > [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! __________________________________________________________ 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!