--- chan_sip.c.orig 2006-04-25 07:23:32.000000000 +0000 +++ chan_sip.c 2006-04-28 13:27:30.000000000 +0000 @@ -1091,10 +1091,14 @@ * apply it to their address to see if we need to substitute our * externip or can get away with our internal bindaddr */ - struct sockaddr_in theirs; + struct sockaddr_in theirs, ours; + ast_ouraddrfor(them, us); // Get 'normal' info theirs.sin_addr = *them; + ours.sin_addr = *us; if (localaddr && externip.sin_addr.s_addr && - ast_apply_ha(localaddr, &theirs)) { + ast_apply_ha(localaddr, &theirs) + && !ast_apply_ha(localaddr, &ours) + ) { char iabuf[INET_ADDRSTRLEN]; if (externexpire && (time(NULL) >= externexpire)) { struct ast_hostent ahp; @@ -1112,8 +1116,6 @@ } else if (bindaddr.sin_addr.s_addr) memcpy(us, &bindaddr.sin_addr, sizeof(struct in_addr)); - else - return ast_ouraddrfor(them, us); return 0; }