Index: channels/chan_sip.c =================================================================== --- channels/chan_sip.c (revision 279500) +++ channels/chan_sip.c (working copy) @@ -25414,14 +25414,6 @@ unref_peer(peer, "removing register expire ref")); peer->host_dynamic = FALSE; srvlookup = v->value; - if (global_dynamic_exclude_static) { - int err = 0; - sip_cfg.contact_ha = ast_append_ha("deny", ast_sockaddr_stringify(&peer->addr), - sip_cfg.contact_ha, &err); - if (err) { - ast_log(LOG_ERROR, "Bad ACL entry in configuration line %d : %s\n", v->lineno, v->value); - } - } } } else if (!strcasecmp(v->name, "defaultip")) { if (!ast_strlen_zero(v->value) && ast_get_ip(&peer->defaddr, v->value)) { @@ -25768,6 +25760,15 @@ ast_string_field_set(peer, tohost, peer->dnsmgr ? srvlookup : ast_sockaddr_stringify_host(&peer->addr)); + + if (global_dynamic_exclude_static) { + int err = 0; + sip_cfg.contact_ha = ast_append_ha("deny", ast_sockaddr_stringify_addr(&peer->addr), + sip_cfg.contact_ha, &err); + if (err) { + ast_log(LOG_ERROR, "Bad ACL entry in configuration line %d : %s\n", v->lineno, v->value); + } + } } if (port && !realtime && peer->host_dynamic) {