diff -Nur a/res/res_pjsip_nat.c b/res/res_pjsip_nat.c --- a/res/res_pjsip_nat.c 2023-04-03 17:47:51.000000000 +0200 +++ b/res/res_pjsip_nat.c 2023-04-06 11:39:14.706883902 +0200 @@ -444,10 +444,19 @@ pjsip_method_cmp(&cseq->method, &pjsip_register_method)) { /* We can only rewrite the URI when one is present */ if (uri || (uri = nat_get_contact_sip_uri(tdata))) { - pj_strdup2(tdata->pool, &uri->host, ast_sockaddr_stringify_host(&transport_state->external_signaling_address)); - if (transport->external_signaling_port) { - uri->port = transport->external_signaling_port; - ast_debug(4, "Re-wrote Contact URI port to %d\n", uri->port); + /* Don't update Contact header if 302 Response to INVITE + * Request + */ + if ( !(tdata->msg->type == PJSIP_RESPONSE_MSG && + !pjsip_method_cmp(&cseq->method, &pjsip_invite_method) && + tdata->msg->line.status.code == PJSIP_SC_MOVED_TEMPORARILY)) { + pj_strdup2(tdata->pool, &uri->host, ast_sockaddr_stringify_host(&transport_state->external_signaling_address)); + if (transport->external_signaling_port) { + uri->port = transport->external_signaling_port; + ast_debug(4, "Re-wrote Contact URI port to %d\n", uri->port); + } + } else { + ast_debug(4, "Redirect (302), no NAT handling\n"); } } }