Thanks guys, fantastic answers.<div><br></div><div>You mention that NAT detection happens before save() and the flag is set by lookup() which makes much more sense. However, if Kamailio is not the registrar, as is the case with my current project, those functions are not called, so an alternative is needed. There are clearly several options.</div>
<div><br></div><div>The solution I have gone for is to replace fix_nated_register() with fix_nated_contact() so that the REGISTER request is relayed with a modified Contact header containing the external ip:port of the client. That is then stored by the registrar (FreeSWITCH in my case) and used later to originate calls for that user. The FreeSWITCH know to send those calls to Kamailio through either use of the Path header and module in Kamailio, or through static configuration of fs_path or proxy parameters in FreeSWITCH.</div>
<div><br></div><div>The works for the first INVITE to the registered client behind NAT. But that client sends back a 200 OK with a Contact header containing its private IP address, and so fix_nated_contact() needs to be invoked on that response, and normally it would be due to FLB_NATB being set, but if Kamailio was not the registrar then that flag is not set. So I need to detect NAT on the client at the time of receiving the reply, or alternatively by having the registrar store a cookie and setting it based on that.</div>
<div><br></div><div>I suppose then my next question then is can I call nat_uac_test() on a UAS? </div><div><br></div><div>Thanks again for the great answers.</div><div><br></div><div>Regards,</div><div>Richard</div>