检查网络接口 ip 版本 ios
Check network interface ip version ios
我想了解我的活动网络接口 IP 版本是什么 - IPv4 或 IPv6。我正在使用下一个说明 http://www.brianjcoleman.com/tutorial-how-to-test-your-app-for-ipv6-compatibility/ 来测试我的应用程序的 IPv6 兼容性。
我检查了这里所有可用的资源(例如 , how to get ip address of iphone programmatically, What exactly means iOS networking interface name? what's pdp_ip ? what's ap?),它有助于获得可用接口的列表。当我的 iPhone 连接到 IPv4 WiFi 网络时,列表是下一个:
"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";
当连接到IPv6 WiFi网络时,列表是下一个:
"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";
在这两种情况下,我都有 en0/ipv4 和 en0/ipv6,所以我不清楚如何以编程方式决定我的网络实际是什么 ip 版本。
非常感谢任何帮助。提前致谢。
首先也是最重要的一点是,您几乎总是 "on" 同时使用 IPv4 和 IPv6 网络(除非其中一个已被禁用)。未能收到 DHCP 地址并不意味着您不是 "on" 网络。这只是意味着没有 DHCP 服务器与您通信(拥有没有 DHCP 服务器的网络是完全合法的)。没有其他人与您一起在该网络上这一事实并不意味着您也不在网络上。你可以独自在网络上。而你是。
迂腐,但对于理解正在发生的事情很重要。您通常的意思是 "do I have a 'publicly' routable address on this network." 而大多数人 真正 的意思(这是一个完全不同的问题,通常很难回答)是 "what's my 'primary' network?"(这尤其很难,因为您的 "primary" 网络可能因您尝试访问的地址而异。)
但是对于您可能想要回答的实际问题,即 "do I have an assigned and probably routable IPv4/6 address?" 为此,您必须查看您拥有的地址,并查看它分配给了什么。我的首选列表是维基百科的 Reserved IP addresses。看着那个,我们可以考虑上面的每个地址。
IPv4 网络
"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 网络
"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
特别是您通常希望查看 en0
(第一个以太网接口,在 iPhone 上是 WiFi)。你可以在第一种情况下看到:
"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)
在第二种情况下你有:
"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)
这就是您知道哪一个是可路由的方式。你必须检查它在什么范围内。(问题:"Why can't it just say 'you're on the Internet?', a major part of the answer is that the spec doesn't define "互联网。“互联网只是一个特定的网络,它恰好非常大。而且,你看到的大多数 IPv4 地址无论如何都会是私有的,并且技术上不在 "the Internet." 上网卡不知道某处是否存在从专用网络桥接到 public 的 NAT。)
顺便说一句,当我说 "not routable," 时,并不意味着它不是您的主要地址。例如,您可以拥有基于 link-local 个地址的整个网络(我已经做过很多次)。但是这些地址不会路由(即它们不会被转发到当前网段),所以对于大多数常见用途来说,考虑它们是可以的 "not a real address." 同样,我完全构建了 "networks" host-only 个地址,但由于它们不会经过当前机器,因此它们通常不是人们所说的 "the network."
我想了解我的活动网络接口 IP 版本是什么 - IPv4 或 IPv6。我正在使用下一个说明 http://www.brianjcoleman.com/tutorial-how-to-test-your-app-for-ipv6-compatibility/ 来测试我的应用程序的 IPv6 兼容性。
我检查了这里所有可用的资源(例如
"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";
当连接到IPv6 WiFi网络时,列表是下一个:
"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";
在这两种情况下,我都有 en0/ipv4 和 en0/ipv6,所以我不清楚如何以编程方式决定我的网络实际是什么 ip 版本。
非常感谢任何帮助。提前致谢。
首先也是最重要的一点是,您几乎总是 "on" 同时使用 IPv4 和 IPv6 网络(除非其中一个已被禁用)。未能收到 DHCP 地址并不意味着您不是 "on" 网络。这只是意味着没有 DHCP 服务器与您通信(拥有没有 DHCP 服务器的网络是完全合法的)。没有其他人与您一起在该网络上这一事实并不意味着您也不在网络上。你可以独自在网络上。而你是。
迂腐,但对于理解正在发生的事情很重要。您通常的意思是 "do I have a 'publicly' routable address on this network." 而大多数人 真正 的意思(这是一个完全不同的问题,通常很难回答)是 "what's my 'primary' network?"(这尤其很难,因为您的 "primary" 网络可能因您尝试访问的地址而异。)
但是对于您可能想要回答的实际问题,即 "do I have an assigned and probably routable IPv4/6 address?" 为此,您必须查看您拥有的地址,并查看它分配给了什么。我的首选列表是维基百科的 Reserved IP addresses。看着那个,我们可以考虑上面的每个地址。
IPv4 网络
"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 网络
"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
特别是您通常希望查看 en0
(第一个以太网接口,在 iPhone 上是 WiFi)。你可以在第一种情况下看到:
"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)
在第二种情况下你有:
"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)
这就是您知道哪一个是可路由的方式。你必须检查它在什么范围内。(问题:"Why can't it just say 'you're on the Internet?', a major part of the answer is that the spec doesn't define "互联网。“互联网只是一个特定的网络,它恰好非常大。而且,你看到的大多数 IPv4 地址无论如何都会是私有的,并且技术上不在 "the Internet." 上网卡不知道某处是否存在从专用网络桥接到 public 的 NAT。)
顺便说一句,当我说 "not routable," 时,并不意味着它不是您的主要地址。例如,您可以拥有基于 link-local 个地址的整个网络(我已经做过很多次)。但是这些地址不会路由(即它们不会被转发到当前网段),所以对于大多数常见用途来说,考虑它们是可以的 "not a real address." 同样,我完全构建了 "networks" host-only 个地址,但由于它们不会经过当前机器,因此它们通常不是人们所说的 "the network."