Index: pbx/pbx_dundi.c =================================================================== --- pbx/pbx_dundi.c (revision 8996) +++ pbx/pbx_dundi.c (working copy) @@ -4474,10 +4474,7 @@ char *cat; int format; int x; - char hn[MAXHOSTNAMELEN] = ""; - struct ast_hostent he; - struct hostent *hp; - struct sockaddr_in sin2; + struct in_addr addr; static int last_port = 0; int globalpcmodel = 0; dundi_eid testeid; @@ -4491,16 +4488,7 @@ ast_log(LOG_ERROR, "Unable to load config %s\n", config_file); return -1; } - ipaddr[0] = '\0'; - if (!gethostname(hn, sizeof(hn)-1)) { - hp = ast_gethostbyname(hn, &he); - if (hp) { - memcpy(&sin2.sin_addr, hp->h_addr, sizeof(sin2.sin_addr)); - ast_inet_ntoa(ipaddr, sizeof(ipaddr), sin2.sin_addr); - } else - ast_log(LOG_WARNING, "Unable to look up host '%s'\n", hn); - } else - ast_log(LOG_WARNING, "Unable to get host name!\n"); + ast_mutex_lock(&peerlock); reset_global_eid(); global_storehistory = 0; @@ -4594,6 +4582,12 @@ v = v->next; } ast_mutex_unlock(&peerlock); + /* We need to do this after reading the bindaddr option */ + ipaddr[0] = '\0'; + if (ast_find_ourip(&addr, *sin)) + ast_log(LOG_WARNING, "Unable to determine IP Address for this host!\n"); + else + ast_inet_ntoa(ipaddr, sizeof(ipaddr), addr); mark_mappings(); v = ast_variable_browse(cfg, "mappings"); while(v) {