获取本机的ip
https://4sysops.com/archives/ipv6-tutorial-part-6-site-local-addresses-and-link-local-addresses/
In IPv6, link-local addresses always begin with 1111111010 (FE80).
internal class Program
{
private static void Main()
{
try
{
var ipAddress = GetIpAddresses();
foreach (var item in ipAddress)
{
Console.WriteLine(item.ToString());
} }
catch (Exception ex)
{
while (ex != null)
{
Console.WriteLine(ex.Message);
ex = ex.InnerException;
}
}
Console.ReadLine();
} /// <summary>
/// 获取指定地址族的ip地址
/// </summary>
/// <param name="addressFamily"></param>
/// <returns></returns>
public static IPAddress[] GetSpecifiedIpAddress(AddressFamily addressFamily)
{
var addressList = GetIpAddresses();
var ipv4Addresses = addressList.Where(x => x.AddressFamily == addressFamily).ToArray();
return ipv4Addresses;
} /// <summary>
/// 获取本机的所有ip地址
/// </summary>
/// <returns></returns>
public static IPAddress[] GetIpAddresses()
{
var hostName = Dns.GetHostName();
var hostEntry = Dns.GetHostEntry(hostName);
return hostEntry.AddressList;
}
}
IPAddress |
AddressFamily | IsIPv6LinkLocal | IsIPv6Teredo | iScopeId |
fe80::844b:b9e:ee74:566b%11 |
InterNetworkV6 | True | False | 11 |
fe80::18de:188f:3f57:feed%13 |
InterNetworkV6 | True | False | 13 |
192.168.0.18 |
InterNetwork | False | False | 不支持 |
192.168.1.18 |
InterNetwork | False | False | 不支持 |
2001:0:b4a8:29af:18de:188f:3f57:feed |
InterNetworkV6 | False | True | 0 |
网卡的本地IPv6地址
隧道适配器的本地IPv6地址
本地的IPv4
本地的IPv4
隧道适配器的IPv6地址
上面的5个地址:
IPv6: 语法参见http://www.cnblogs.com/chucklu/p/4838147.html
fe80::844b:b9e:ee74:566b%11
fe80::14c8:c62:3f57:feed%13
中间的双冒号,缺省了3组0
%后面的是zone id
IPv4:
192.168.0.18
192.168.1.18
最后一个地址2001:0:b4a8:29af:14c8:c62:3f57:feed也是属于隧道适配器的
fe80::14c8:c62:3f57:feed%13
这个IPv6地址是属于隧道适配器的(6to4) 6to4 addresses
隧道适配器 Teredo Tunneling Pseudo-Interface:
连接特定的 DNS 后缀 . . . . . . . :
描述. . . . . . . . . . . . . . . : Teredo Tunneling Pseudo-Interface
物理地址. . . . . . . . . . . . . : 00-00-00-00-00-00-00-E0
DHCP 已启用 . . . . . . . . . . . : 否
自动配置已启用. . . . . . . . . . : 是
IPv6 地址 . . . . . . . . . . . . : 2001:0:b4a8:29af:86a:789:3f57:feed(首选)
本地链接 IPv6 地址. . . . . . . . : fe80::86a:789:3f57:feed%13(首选)
默认网关. . . . . . . . . . . . . : ::
TCPIP 上的 NetBIOS . . . . . . . : 已禁用
Global unicast addresses
A global unicast address is simply what we call a public IP address in IPv4—that is, an IP address that is routed across the whole Internet.
You can make out a global unicast address easily: The first three bits are set to 001.
Thus, the address prefix of a global IPv6 address is 2000::/3 because 0010000000000000 is 2000 in hex.
However, in the future, the IANA (Internet Assigned Numbers Authority) might delegate currently unassigned portions of the IPv6 address space.
Hence, 2000::/3 won’t always be the prefix for global unicast addresses.
(Note: The diagram is from Microsoft’s “Introduction to IP Version 6.”)
以0x2001 ,前面3个bit是001 Global Routing Prefix 是 0 0000 0000 0001 +4个字节(32位)
In computer networking, Teredo is a transition technology that gives full IPv6 connectivity for IPv6-capable hosts that are on the IPv4 Internet but have no native connection to an IPv6 network.
Unlike similar protocols, it can perform its function even from behind network address translation (NAT) devices such as home routers.
Teredo operates using a platform independent tunneling protocol that provides IPv6 (Internet Protocol version 6) connectivity by encapsulating IPv6 datagram packets within IPv4 User Datagram Protocol (UDP) packets.
Teredo routes these datagrams on the IPv4 Internet and through NAT devices.
Teredo nodes elsewhere on the IPv6 network (called Teredo relays) receive the packets, un-encapsulate them, and pass them on.
Teredo is a temporary measure.
In the long term, all IPv6 hosts should use native IPv6 connectivity.
Teredo should be disabled when native IPv6 connectivity becomes available.
Christian Huitema developed Teredo at Microsoft, and the IETF standardized it as RFC 4380.
The Teredo server listens on UDP port 3544.
Smart way to get the public Internet IP address/geo loc
I prefer http://icanhazip.com. It returns a simple text string. No HTML parsing required.
string myIp = new WebClient().DownloadString(@"http://icanhazip.com").Trim();
获取本机的ip的更多相关文章
- 【Win 10 应用开发】获取本机的IP地址
按照老规矩,也是朋友的建议,老周今天在吹牛之前,先讲一个小故事. 有朋友问我,老周,你现在还发短信吗,你每个月用多少电话费?唉,实话说,现在真的发短信不多了,套餐送的130条短信,每月都发不了一条.至 ...
- C#获取本机公网IP
/// <summary> /// 获取本机公网IP /// </summary> /// <returns></returns> public sta ...
- 获取本机的IP地址(局域网)与主机名称
编写内容保存为bat @echo off &setlocal enabledelayedexpansion Rem '/*========获取本机的IP地址(局域网)=========*/ e ...
- python3脚本获取本机公网ip
python脚本获取本机公网ip 1.获取公网IP地址方式,访问:http://txt.go.sohu.com/ip/soip 2.代码实现 import requests import re r ...
- 获取本机的IP地址和mac地址
1. 以前一直用ipconfig来查看ip地址,哈哈哈,现在发现挺好玩 #获取本机的IP地址和mac地址 import uuid import socket def get_mac_address() ...
- python获取本机的IP
转载:https://www.cnblogs.com/whu-2017/p/8986842.html 方法一: 通常使用socket.gethostbyname()方法即可获取本机IP地址,但有时候获 ...
- Java 工具类 IpUtil - 获取本机所有 IP 地址,LocalHost 对应地址 IP
Java 工具类 IpUtil - 获取本机所有 IP 地址,LocalHost 对应地址 IP IP 工具类 源代码: /** * <p> * * @author XiaoPengwei ...
- Linux获取本机公网IP,调整双节点主从服务的RPC调用逻辑
简单记录一次双节点的之间的服务调用叭 ~ 现有: 服务A的双节点A1.A2 服务B的双节点B1.B2 服务A 和服务B 通过 Netty 实现 RPC 通信,可能会导致比较玄学的问题.如图: 要做到 ...
- 怎样获取本机的ip地址
首先介绍一下用到的结构体 struct hostent { const char *h_name; // official name of host char **h_aliases; // alia ...
- android获取本机的IP地址和mac物理地址
/获取本机IP地址 public String getLocalIpAddress() { WifiManager wifiManager = (WifiManager) getSystemServi ...
随机推荐
- Golang中解析json,构造json
json解析是如今(网络)应用程序开发中最不可或缺的一环了.许多语言需要库支持才可以解析.构造json,但Golang凭借着原生库就可以很好地做到这一点. json的基本表现形式有两个:struct与 ...
- Python(Django) 连接MySQL(Mac环境)
看django的文档,详细的一塌糊涂,这对文档来时倒是好事,可是数据库连接你别一带而过啊.感觉什么都想说又啥都没说明白,最有用的一句就是推荐mysqlclient.展开一个Django项目首先就是成功 ...
- 最短路 dijkstra and floyd
二:最短路算法分析报告 背景 最短路问题(short-path problem):若网络中的每条边都有一个数值(长度.成本.时间等),则找出两节点(通常是源节点和阱节点)之间总权和最小的路径就是最短路 ...
- Java异常(1)
一.要达到的效果 如果出现错误而是某些操作没有完成,程序应该: (1)返回到一种安全状态,并能够让用户执行一些其他的命令. (2)允许用户保存所有操作的结果,并以适当的方式终止程序. 异常处理的任 ...
- centos 6.4 安装php-fpm 及常用扩展,(转)
今天又装了一次开发环境,以前忘记记录了 这次记录一下 ---------------------------------------- centos6 yum安装nginx.php-fpm 时间201 ...
- hdu 5009 Paint Pearls
首先把具有相同颜色的点缩成一个点,即数据离散化. 然后使用dp[i]表示涂满前i个点的最小代价.对于第i+1个点,有两种情况: 1)自己单独涂,即dp[i+1] = dp[i] + 1 2)从第k个节 ...
- mysql---整体备份和增量备份
整体备份: 对整张表或者整个数据库甚至所有数据库进行备份. 增量备份: 对某一范围内的数据进行备份. 1.整体备份: 对表进行备份: 针对存储引擎为myisam的表,可以直接复制frm.myd.myi ...
- lucene 4.0学习
一:官方文件 http://lucene.apache.org/core/4_0_0/ ps:网上参考文章:http://www.cnblogs.com/xing901022/p/3933675.ht ...
- Aspose.Words 总结
生成答题卡 try { string tempPath = @"D:\moban\ttt.doc"; //Open document and create Documentbuil ...
- 客户端获取服务器SessionID (Asp.net SessionID)
SessionID是客户端首次访问某个方法或页面, 并且这个方法中设置了Session["xxx"]=xx; 此时服务器返回的响应头(HttpResponse.Headers)中会 ...