How do I find my own IP address?

Joe Armstrong joe@REDACTED
Wed Jan 21 22:53:25 CET 2004

On Wed, 21 Jan 2004, Luke Gorrie wrote:

> Joe Armstrong <joe@REDACTED> writes:
> > I need to know my own IP address
> For what purpose? There's no simple answer because you don't
> necessarily just have one IP address, and there are different ways to
> find the right IP address for different purposes.

Because this is sometimes used as a key in the .Xauthority file

My problem is to write  bomb proof code to open a connection to the local
X-server - this should try to handle cases where DISPLAY etc is incorrect


> If you want to tell someone else your IP address and you already know
> theirs, it's probably best to just connect to them and let them see
> what address you used. If they have a socket connected to you then
> they can get your address from inet:peername/2.
> Alternatively you could ask the OS "what address should I use to talk
> with <other ip>?" - I'm not sure if you can do that portably, but on a
> modern Linux box you can do a manual lookup like:
>   $ ip route get
> dev eth0  src 
>       cache  mtu 1500 advmss 1460
> which says I can use source address to talk to
> Depending on what you're doing you might also want to be careful about
> NAT. Maybe the address your computer thinks you have is not the same
> one other people will see.
> Cheers,
> Luke (confident that Per will correct all my errors :-)

More information about the erlang-questions mailing list