Index: channels/chan_sip.c =================================================================== --- channels/chan_sip.c (revision 13388) +++ channels/chan_sip.c (working copy) @@ -459,7 +459,9 @@ #define DEC_CALL_LIMIT 0 #define INC_CALL_LIMIT 1 +char reg_dialstring[64] = ""; + /*! \brief sip_request: The data grabbed from the UDP socket */ struct sip_request { char *rlPart1; /*!< SIP Method Name or "SIP/2.0" protocol version */ @@ -1661,9 +1663,11 @@ snprintf(port, sizeof(port), "%d", ntohs(sin->sin_port)); if (fullcontact) - ast_update_realtime("sippeers", "name", peername, "ipaddr", ipaddr, "port", port, "regseconds", regseconds, "username", username, "fullcontact", fullcontact, NULL); + ast_update_realtime("sippeers", "name", peername, "ipaddr", ipaddr, "port", port, "regseconds", regseconds, "username", username, + "reg_dialstring", reg_dialstring, "fullcontact", fullcontact, NULL); else - ast_update_realtime("sippeers", "name", peername, "ipaddr", ipaddr, "port", port, "regseconds", regseconds, "username", username, NULL); + ast_update_realtime("sippeers", "name", peername, "ipaddr", ipaddr, "port", port, "regseconds", regseconds, "username", username, + "reg_dialstring", reg_dialstring, NULL); } /*! \brief Automatically add peer extension to dial plan */ @@ -5781,7 +5785,8 @@ { if (!ast_test_flag((&global_flags_page2), SIP_PAGE2_IGNOREREGEXPIRE)) { if (ast_test_flag(&(peer->flags_page2), SIP_PAGE2_RT_FROMCONTACT)) { - ast_update_realtime("sippeers", "name", peer->name, "fullcontact", "", "ipaddr", "", "port", "", "regseconds", "0", "username", "", NULL); + ast_update_realtime("sippeers", "name", peer->name, "fullcontact", "", "ipaddr", "", "port", "", "regseconds", "0", "username", "", + "reg_dialstring", "", NULL); } else { ast_db_del("SIP/Registry", peer->name); } @@ -12663,6 +12668,9 @@ } } else if (!strcasecmp(v->name, "callevents")) { global_callevents = ast_true(v->value); + } else if (!strcasecmp(v->name, "reg-dialstring")) { + ast_copy_string(reg_dialstring, v->value, sizeof reg_dialstring); + ast_verbose(VERBOSE_PREFIX_2 "Got SIP registrar dialstring \"%s\"\n", reg_dialstring); } } Index: configs/sip.conf.sample =================================================================== --- configs/sip.conf.sample (revision 13388) +++ configs/sip.conf.sample (working copy) @@ -112,6 +112,14 @@ ;notifyringing = yes ; Notify subscriptions on RINGING state ;callevents=no ; generate manager events when sip ua performs events (e.g. hold) +;reg-dialstring=SIP/myname ; If using a two-tire model with n sip/sip gateways in front with DNS + ; roundrobin and a bunch of sip/pstn gateways in the back, the sip/pstn + ; gateways should dial this server on incoming. This field is updated on SIP + ; REGISTER and ensures that calls from PSTN are directed through the correct sip + ; gateway in front to avoid NAT problems (if using the wrong sip gateway, + ; client's nat router will not accept the packets since that sip gateway's IP is + ; not in NAT cache). + ; ; If regcontext is specified, Asterisk will dynamically create and destroy a ; NoOp priority 1 extension for a given peer who registers or unregisters with