finding my own IPv6 address
Tony Rogvall
tony@REDACTED
Mon Apr 19 13:53:22 CEST 2004
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]).
> {ok,#Port<0.29>}
> 2> inet:ifget(S, "vr0", [addr, flags]).
>
> {ok,[{addr,{130,237,95,62}},{flags,[up,broadcast,running,multicast]}]}
> 3>
>
For some reason this does not work (even if using a ipv6 socket) My
guess is that
the code in the inet_drv for getting ipv6 interface address is not
correct. (The IPv6
support code was written in a early phase of IPv6, names and interfaces
was non standard...)
To get an interface address inet_drv is using SIOCGIFADDR ioctl, this
does not
work with IPv6 (tried solaris/linux/mac os X).
Since IPv6 use a different method for adding and deleting addresses
the interface must be changed to handle that. I assume that this goes
for bsd/solairs virtual
addresses as well, where you add/del slave interfaces.
In linux it used to be simple (still is but changing?) just add a
virtual interface say eth0:15 and set the address :-)
I know that some people on the list has more input on this :-)
(The work around? is as always to walk into the os:cmd swamp :-)
os:cmd("ifconfig eth0 | grep \"inet6 addr:\"").
Then start parsing)
/Tony
More information about the erlang-questions
mailing list