title: Programmatically find if the iPad is on IPv4 or an IPv6 network
body: <p>I have a functionality in iOS which I need to disable if the user's device network in IPv6. Is there a way we can get the device (iPhone/iPad) IP address as a string programmatically, and then check if it's IPv4 or IPv6 network <em>(or simply tell whether it is on IPv4 or IPv6 network without fetching the actual address)</em>?</p>
  
  <p>The closest I could get to was <a href="https://stackoverflow.com/questions/7072989/iphone-ipad-osx-how-to-get-my-ip-address-programmatically">iPhone/iPad/OSX: How to get my IP address programmatically?</a> (by David H.), which again wants us to specify the network beforehand only, hence doesn't solve my purpose...
  By his solution either I always get an IPv4 or always an IPv6.</p>
  
  <p>For testing on IPv6 I'm using the Apple's recommended NAT64 tool (<a href="https://developer.apple.com/library/ios/documentation/NetworkingInternetWeb/Conceptual/NetworkingOverview/UnderstandingandPreparingfortheIPv6Transition/UnderstandingandPreparingfortheIPv6Transition.html" rel="nofollow noreferrer">https://developer.apple.com/library/ios/documentation/NetworkingInternetWeb/Conceptual/NetworkingOverview/UnderstandingandPreparingfortheIPv6Transition/UnderstandingandPreparingfortheIPv6Transition.html</a>).</p>
  
  <p>As a workaround I'm using the DNS to check (<a href="https://hirooka.pro/?p=6169" rel="nofollow noreferrer">https://hirooka.pro/?p=6169</a>) currently, which I feel is not a proper way as it should be IP address based. 
  Also, quite weirdly, the iPad always shows an IPv4 address (even when connected to IPv6 network) but only varies in the DNS style... Anybody knows why that happens ?</p>
  
  <p>Thanks in advance.</p>