Programmatically find if iPad is on IPv4 or IPv6 network

I have a function in iOS that I need to disable if the network of user devices is in IPv6. Is there a way by which we can get the IP address of the device (iPhone / iPad) as a string programmatically, and then check if it has an IPv4 or IPv6 network (or simply indicate whether it is on an IPv4 or IPv6 network without receiving actual address)?

The closest I could get to was iPhone / iPad / OSX: how to get my IP address programmatically? (David H.), who again wants us to specify the network only in advance, therefore does not solve my goal ... By his decision, either I always get IPv4 or always IPv6.

For testing on IPv6, I use the Apple64 recommended tool NAT64 ( https://developer.apple.com/library/ios/documentation/NetworkingInternetWeb/Conceptual/NetworkingOverview/UnderstandingandPreparingfortheIPv6Transition/UnderstandingandPreparingfortheIPv6Transition.html ).

As a workaround, I use DNS to check ( https://hirooka.pro/?p=6169 ), which I believe is not the correct way, it should be based on the IP address. Also, it’s rather strange, the iPad always shows the IPv4 address (even if it is connected to the IPv6 network), but it changes only in the DNS style ... Does anyone know why this is happening?

Thanks in advance.

+7
ios objective-c xcode dns ipv6
source share

No one has answered this question yet.

See similar questions:

122
How to get my IP address programmatically on iOS / macOS?

or similar:

5
Set up IPv6 connectivity on iPhone from Mac book pro (El Capitan)
3
How to Check IPv6 IPhone Address
2
Configuring an IPv6 Environment Using OSX 10.11 Beta 5 (El Capitan)
one
Why is my WebRequest in Xamarin iOS not working in ipv6?
one
according to the apple, my application crashes on the ipv6 network on the iPad, but cannot find and resolve it
one
iOS - only ipv4 API support
0
Applications are viewed on an IPv6 network. Make sure your application supports IPv6 networks, as IPv6 compatibility is required.
0
NsurlConnections with IPv6 getaddrinfo
0
testing - unable to create IPv6 network on Mac
-one
IPV6 Application Compatibility Test for the App Store

All Articles