finding my own IPv6 address

Fredrik Thulin ft@REDACTED
Mon Apr 19 14:02:58 CEST 2004


On Monday 19 April 2004 13.53, Tony Rogvall wrote:
> måndagen den 19 april 2004 kl 08.33 skrev Fredrik Thulin:
> > Hi
> >
> > In SIP, it is (unfortunately) necessary for you to know your own IP
> > address
> > from time to time. For IPv4 we (Yxa SIP-server/stack) have been using
> > the
> > undocumented and unsupported function inet:get_if() with great
> > success. Now
> > I'm wondering if there is maybe an equally undocumented and
> > unsupported way
> > of finding your own IPv6 address (without querying DNS for your
> > hostname)?
> >
> > I tried the following :
> >
> >   1> {ok, S} = inet_udp:open(0,[inet6]).
>
> Should be inet6_udp:open(0, [])
> or gen_udp:open(0, [inet6]).

Silly me, I knew that. Should not test things before coffee on a monday 
morning ;)

I then get another result. Less missguiding, but still not what I needed :

  1> {ok, S} = gen_udp:open(0, [inet6]).
  {ok,#Port<0.31>}
  2> inet:ifget(S, "vr0", [addr, flags]).
  {error,einval}
  3>

...
> (The work around? is as always to walk into the os:cmd swamp :-)
>     os:cmd("ifconfig eth0 | grep \"inet6 addr:\"").
> Then start parsing)

I don't want to go there, but thanks for your reply.

/Fredrik




More information about the erlang-questions mailing list