Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check network interface ip version ios

I am trying to understand what my active network interface ip version is - IPv4 or IPv6. I am using the next instructions http://www.brianjcoleman.com/tutorial-how-to-test-your-app-for-ipv6-compatibility/ to test my app for IPv6 compatibility.

I checked all resources available here (for example Swift - Get device's IP Address, how to get ip address of iphone programmatically, What exactly means iOS networking interface name? what's pdp_ip ? what's ap?), it helped to get a list of available interfaces. When my iPhone is connected to IPv4 WiFi network, the list is the next:

"awdl0/ipv6" = "fe80::14ce:f9ff:fe2a:44df";
"en0/ipv4" = "192.168.1.190";
"en0/ipv6" = "fdba:ae3c:c993::19cd:be51:e41b:632e";
"lo0/ipv4" = "127.0.0.1";
"lo0/ipv6" = "fe80::1";
"pdp_ip0/ipv4" = "100.83.148.33";
"utun0/ipv6" = "fe80::e94e:c3b6:ff73:1ded";

When it is connected to IPv6 WiFi network, the list is the next:

"awdl0/ipv6" = "fe80::14ce:f9ff:fe2a:44df";
"en0/ipv4" = "169.254.127.94";
"en0/ipv6" = "2001:2::aab1:7dd5:c5dc:16dd:b678";
"lo0/ipv4" = "127.0.0.1";
"lo0/ipv6" = "fe80::1";
"pdp_ip0/ipv4" = "100.83.148.33";
"utun0/ipv6" = "fe80::e94e:c3b6:ff73:1ded";

In both cases I have en0/ipv4 and en0/ipv6, so it is not clear for me how to make a decision programmatically what ip version of my network actually is.

Any help is very appreciated. Thanks in advance.

like image 785
Igor Nazarov Avatar asked Feb 10 '17 13:02

Igor Nazarov


People also ask

How do I find my network interface IP?

Type ipconfig /all at the command prompt to check the network card settings. The IP address and MAC address are listed under the appropriate adapter as Physical Address and IPv4 Address.

What is interface IP?

A network interface is the network-specific software that communicates with the network-specific device driver and the IP layer in order to provide the IP layer with a consistent interface to all network adapters that might be present.


1 Answers

The first, and most important, thing to understand is that you're almost always "on" both an IPv4 and IPv6 network (unless one of them has been disabled). Failure to receive a DHCP address does not mean you're not "on" a network. It just means there's no DHCP server talking to you (it is completely legitimate to have a network with no DHCP server). The fact that no one else is on this network with you doesn't mean you're not on a network, either. You can be on the network alone. And you are.

Pedantic, but important to understanding what's going on. What you usually mean is "do I have a 'publicly' routable address on this network." And what most people really mean (and is a radically different question and often very hard to answer) is "what's my 'primary' network?" (This is particularly difficult because your "primary" network might be different depending on what address you're trying to reach.)

But to the practical question that you probably want to answer, which is "do I have an assigned and probably routable IPv4/6 address?" To that, you have to look at the address you have, and see what it's assigned to. My preferred list is Wikipedia's Reserved IP addresses. Looking at that, we can consider each address above.

IPv4 network

"awdl0/ipv6" = "fe80::14ce:f9ff:fe2a:44df"; # fe80 => Link local (not routable)
"en0/ipv4" = "192.168.1.190"; # 192.168 => Private network (but *probably* NAT)
"en0/ipv6" = "fdba:ae3c:c993::19cd:be51:e41b:632e"; # fdba => Unique local address (not routable)
"lo0/ipv4" = "127.0.0.1"; # 127 => Host loopback (not routable)
"lo0/ipv6" = "fe80::1"; # fe80 => Host loopback (not routable) 
"pdp_ip0/ipv4" = "100.83.148.33"; # 100.83 => Service provider (not useful to you)
"utun0/ipv6" = "fe80::e94e:c3b6:ff73:1ded"; # fe80 => Host loopback (not routable)

IPv6 network

"awdl0/ipv6" = "fe80::14ce:f9ff:fe2a:44df"; # Loopback
"en0/ipv4" = "169.254.127.94"; # Link local (not routable)
"en0/ipv6" = "2001:2::aab1:7dd5:c5dc:16dd:b678"; # 2001 => "Teredo tunnel" (IPv6 routable over IPv4)
"lo0/ipv4" = "127.0.0.1"; # loopback
"lo0/ipv6" = "fe80::1"; # loopback
"pdp_ip0/ipv4" = "100.83.148.33"; # Service provider
"utun0/ipv6" = "fe80::e94e:c3b6:ff73:1ded"; # loopback

In particular you usually want to be looking at that en0 (first ethernet interface, which on an iPhone is WiFi). And you can see in the first case you have:

"en0/ipv4" = "192.168.1.190"; # 192.168 => Private network (but *probably* NAT)
"en0/ipv6" = "fdba:ae3c:c993::19cd:be51:e41b:632e"; # fdba => Unique local address (not routable)

And in the second case you have:

"en0/ipv4" = "169.254.127.94"; # Link local (not routable)
"en0/ipv6" = "2001:2::aab1:7dd5:c5dc:16dd:b678"; # 2001 => "Teredo tunnel" (IPv6 routable over IPv4)

And that's how you know which one is routable. You have to check what range it's in. (To the question: "Why can't it just say 'you're on the Internet?', a major part of the answer is that the spec doesn't define "the Internet." The Internet is just one particular network that happens to be very large. Also, most IPv4 addresses you see are going to be private anyway, and technically aren't on "the Internet." The network card has no idea whether or not there's a NAT somewhere that bridges from the private network to the public one.)

BTW, when I say "not routable," that doesn't mean it's not your primary address. For example, you can have an entire network based on link-local addresses (I've done it lots of times). But those addresses won't route (i.e. they won't be forwarded past the current network segment), so for most common uses it's ok to consider them "not a real address." Similarly, I've built "networks" entirely out of host-only addresses, but since they don't route past the current machine, they usually aren't what people mean by "the network."

like image 131
Rob Napier Avatar answered Sep 18 '22 14:09

Rob Napier