anchor.diff:  	{error, What} ->
   	    logger:log(debug, "Resolver: Error ~p when resolving ~p ~p", [What, Host, Family]),
   	    {error, What};
  -	{ok, HostEnt} when record(HostEnt, hostent) ->
  +	{ok, HostEnt} when is_record(HostEnt, hostent) ->
  +	    HFam = HostEnt#hostent.h_addrtype,
   	    Res = lists:map(fun(Addr) ->
  -				    case Addr of
  -					{0, 0, 0, 0, 0, 65535, _, _} ->
  +				    case {Addr, HFam} of
  +					{{0, 0, 0, 0, 0, 65535, _, _}, _} ->
   					    %% IPv4 mapped IPv6 address, ignore - we resolve
   					    %% IPv4 addresses separately
   					    [];
  -					_ ->
  -					    {Family, siphost:makeip(Addr), Port}
  +					{_, Family} ->
  +					    {Family, siphost:makeip(Addr), Port};
  +					{_, _} ->
  +					    %% HFam is not the same as Family, ignore (if we
  +					    %% call gethostbyname() on an IPv4 address, but
  +					    %% family 'inet6' it returns an IPv4 hostent)
  +					    []
   				    end
   			    end, HostEnt#hostent.h_addr_list),
   	    lists:flatten(Res)
  
positive.code: 		_ ->
  		    V6List
  	    end;
  	V4List when list(V4List) ->
  	    lists:append(V6List, V4List)
      end.
  
  
negative.code: %%              Port may also be 'none'.
  %% Returns: HostPortList
  %%--------------------------------------------------------------------
  get_ip_port(Host, Port) when is_integer(Port) ; Port == none ->
      V6List = case sipserver:get_env(enable_v6, true) of
  		 true ->
  		     case get_ip_port2(inet6, Host, Port) of
  			 {error, _} ->
  			     %% Ignore v6 errors (they are logged in get_ip_port2 though)
  