[pjsip] pjsua getting wrong IP address

Benny Prijono bennylp at pjsip.org
Tue Nov 20 22:48:45 EST 2007

tloginbr-pjsip at yahoo.com.br wrote:
> I fixed the problem for my application, I had the
> other IP address inside my "/etc/hosts" file...
> anyway, I don't know if there is really a problem with
> the API since it didn't use the ip I was choosing. I
> dont know how the pjsua_transport_confi works...

As for the IP selection, that's pretty much intentional. See
pj_gethostip() in pjlb's addr_resolv_sock.c. So first pjlib will use
the host's IP address as specified by querying
gethostbyname(gethostame()), and only when it returns, the
default interface will be used.

So if you have wrong localhost entry in /etc/hosts, it will be used
regardless since at present pjlib currently does not validate the IP
address against local interfaces' IP address.

As for rtp IP address, I'm not sure why. If you specify public_addr 
in pjsua_transport_config, then it should be used (assuming you 
don't enable STUN).


> Thiago Paiva Flores
>> Hi all,
>> I'm having pretty weird behaviour in my application.
>> It was running with no problems until I decided to
>> move it from one machine to another. Now it gets a
>> wrong ip address to listen for incoming calls and
>> rtp/rtcp sockets. I'm using UDP transport and the
>> api
>> version 0.8.0 downloaded from the site (not svn). It
>> gets one ip address that has nothing to do with my
>> machine or even the network... my network begins
>> with
>> 201.73.xxx and it is getting one ip from the network
>> 200.139.xxx. The only relationship between them is
>> that my dns server is in the 200.139.xxx network,
>> but
>> that I already had in my old machine (where the
>> application works fine). I still have the old
>> machine
>> working, so I know that the application is working
>> fine in there and I also tested in different
>> machines
>> and it works fine... just this one machine (the one
>> that I need) gives me some problems...
>> I tried to put the address in the
>> pjsua_transport_config, but it solved only half the
>> problem... Now it listens for incomming calls in the
>> correct ip, but the rtp/rtcp sockets are still in
>> this
>> other ip. I've set both public_addr and bound_addr
>> to
>> the ip of my machine (the 201.73.xxx). This wrong ip
>> (200.139.xxx) is not in my routing table or in any
>> other network configuration that I could find
>> here...
>> just to make things clear, my dns server is in the
>> same network as this ip address (the wrong one) but
>> it
>> is different, so the application is getting one IP
>> from I_dont_know_where... my machine is in a public
>> network directly, so it is not behind any firewall.
>> I'm running a debian etch (4.0) system.
>> all help is very welcome,
>> Thiago Paiva Flores

More information about the pjsip mailing list