How to retrieve the permanent and temporary ipv6 address of iOS device??

Hi,


I know that in iOS device we have a mixture of ip address which contains ipv4 and ipv6 addresses. Now the ipv6 addresses can be of type permanent(based on device mac address) and temporary(used for outgoing connection).


Is there a way we can differentiate between the two and actually find out which one is permanent and which one is temporary ipv6 address?

Replies

I don’t know of any way to determine whether an address is temporary on iOS [1]. Why does it matter to you?

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

[1] On macOS you can see the state of the address using the

ifconfig
tool. You can rummage through the
ifconfig
source code to see how that works, but it’s based on a mechanism (
IN6_IFF_TEMPORARY
) that’s only public API on macOS.

I have a VOIP application, now in case of ipv6 only networks i.e T-Mobile , we need to be able to establish a socket connection with our device ipv6 ip, but we don't know if we are binding with the permanent one or the temporary one, we just get the list of addresses and bind with the 1st one now if at all that turns out to be permanent one that could turn out to be a security violation since permanent ip is made up of devices MAC address and we are exposing this permanent ip to the outside world which is not what we want, only the temporary addresses should be used for outgoing connections.


So this was the reason i needed a point of differentiation b/w the 2 i.e permanent and temporary ipv6 addresses.

That’s a very interesting edge case. In practice I don’t think this will make a difference because the permanent address does not contain the MAC address but a hash of the MAC address. However, it’s still a valid concern.

we need to be able to establish a socket connection with our device ipv6 ip

What sort of connection are we talking about here? Presumably this is UDP? Is it an outgoing ‘connection’ or an ‘incoming’ one?

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

What sort of connection are we talking about here? Presumably this is UDP? Is it an outgoing ‘connection’ or an ‘incoming’ one?

This is a TCP connection we are talking about and that too an outgoing one.

This is a TCP connection we are talking about and that too an outgoing one.

You don’t need to worry about this for an outgoing TCP connection. The system will choose a source address that’s appropriate automatically.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"
You don’t need to worry about this for an outgoing TCP connection.  The system will choose a source address that’s appropriate automatically.


On device, we have both Cellular data as well as wifi ON. And our application forces the traffic to go over cellular network instead of wifi.

To do that we are explicitly binding to an IPv6 address on a cellular network interface. In order to bind to the specific IPv6 address, wanted to understand if we are binding to right V6 address.

And our application forces the traffic to go over cellular network …

The best way to do this is using the Network framework. It gives you explicit control over the interface uses by your connection.

If you have to stick with BSD Sockets for some reason — say, you have a large existing source base that depends on it — you should check out the

IP_BOUND_IF
/
IPV6_BOUND_IF
socket options. These let you force a connection to run over a specific interface. I’ve never actually used it with TCP — most of the time folks ask this question in the context of UDP — but it should work.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

We are able to force the connection to run over a specific interface i.e cellular in this case. But for cellular interface, we would get approx 2 - 3 IPv6 addresses (link local, global etc.) So out of those addresses we want to bind to a specific address which should not be the permanent ipv6 address. How do we achieve this?

My point is that you shouldn’t be choosing a specific source address, you should let the system choose that address for you. If you bind the source interface using

IPV6_BOUND_IF
, does the system choose the right address?

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"