Uri i = new Uri("http://www.baidu.com");   //可获取属性

             UriBuilder u = new UriBuilder("http://www.baidu.com");  //可获取、设置属性

             IPAddress ipAddress = IPAddress.Parse("192.168.31.34");  //ip地址转换
byte[] address = ipAddress.GetAddressBytes();
string ipString = ipAddress.ToString(); IPHostEntry host = Dns.Resolve("www.baidu.com"); //获取IPHostEntry对象
IPHostEntry whost = Dns.GetHostByAddress("192.168.31.114");

根据域名、地址,查询主机信息

Form

 public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void button1_Click(object sender, EventArgs e)
{
try
{
IPHostEntry iphost = Dns.GetHostEntry(textBox1.Text);
foreach(var ip in iphost.AddressList)
{
string ipaddress = ip.AddressFamily.ToString();
listBox1.Items.Add(ipaddress);
listBox1.Items.Add(" " + ip.ToString());
}
textBox2.Text = iphost.HostName; }
catch (Exception ex)
{
MessageBox.Show("Unable to process the request because the following problem occurred:\n" + ex.Message + " Exception occurred"); }
}
}

Designer

    partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null; /// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
} #region Windows Form Designer generated code /// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.textBox1 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.listBox1 = new System.Windows.Forms.ListBox();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(, );
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(, );
this.label1.TabIndex = ;
this.label1.Text = "Enter name to resolve and click Resolve button";
//
// button1
//
this.button1.Location = new System.Drawing.Point(, );
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(, );
this.button1.TabIndex = ;
this.button1.Text = "Resolve";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(, );
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(, );
this.textBox1.TabIndex = ;
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(, );
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(, );
this.textBox2.TabIndex = ;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(, );
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(, );
this.label2.TabIndex = ;
this.label2.Text = "HostName";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(, );
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(, );
this.label3.TabIndex = ;
this.label3.Text = "IP Addresses";
//
// listBox1
//
this.listBox1.FormattingEnabled = true;
this.listBox1.ItemHeight = ;
this.listBox1.Location = new System.Drawing.Point(, );
this.listBox1.Name = "listBox1";
this.listBox1.Size = new System.Drawing.Size(, );
this.listBox1.TabIndex = ;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(, );
this.Controls.Add(this.listBox1);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.button1);
this.Controls.Add(this.label1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
this.PerformLayout(); } #endregion private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.ListBox listBox1;
}

C# IP地址和DNS 网络(三)的更多相关文章

  1. MSF魔鬼训练营-3.1.1信息收集-通过DNS和IP地址挖掘目标网络信息

    情报搜集环境站渗透测试全过程的80%~90%   一.外围信息搜集(公开渠道信息搜集OSINT  open source intelligence) 3.1.1信息收集-通过DNS和IP地址挖掘目标网 ...

  2. Windows下使用命令行设置ip地址的DNS服务器

    使用命令行或者编写bat批处理设置网络连接的IP地址以及DNS服务器地址有时候会比手动更加方便,IP地址和DNS的设置一般是配合的,常用到的几个状态是: 1.IP地址动态获取,DNS也动态 2.IP地 ...

  3. ip地址中的网络号,主机号

    当前使用的IP地址有4个字节(32bit)组成,即IPV4编码方式.每个IP地址包括两部分:网络号和主机号.当分配给主机号的二进制位越多,则能标识的主机数就越多,相应地能标识的网络数就越少,反之同理. ...

  4. Debian静态IP地址和DNS

    Debian静态IP地址和DNS 一.配置文件及路径 /etc/network/interfaces 二.IP地址1. DHCP的IP配置如下 # The primary network interf ...

  5. android开发工具类之获得WIFI IP地址或者手机网络IP

    有的时候我们需要获得WIFI的IP地址获得手机网络的IP地址,这是一个工具类,专门解决这个问题,这里需要两个权限: <uses-permission android:name="and ...

  6. linux c++ curl 根据IP地址获得当前网络的所在的地理位置

    注意: 可能每个电脑的默认中文编码格式不同,有时会出现乱码,需要对返回内容进行编码转换,或者换成可指定编码格式的接口.如  搜狐IP地址查询接口(可设置编码):http://pv.sohu.com/c ...

  7. linux 虚拟机设置好固定ip 修改了 dns 网络需要设置成桥接模式

    linux  虚拟机设置好固定ip 修改了 dns  网络需要设置成桥接模式  可以修复网络连接(浏览器返回 server not  found)

  8. Linux下修改主机IP地址、DNS、主机名的三种方法

    使用root用户登录进入linux,打开进去终端 在终端中输入:vi /etc/sysconfig/network-scripts/ifcfg-eth0 (最后的eth0是网卡名,我的是Auto_et ...

  9. IP 地址 与 DNS

    IP地址转化 192.168.10.1 十进制,点分十进制地址 32位二进制数字序列,四段,八位 十进制与二进制转换00000000 = 000000001 = 2 * 0 = 100000010 = ...

随机推荐

  1. HanLP-基于HMM-Viterbi的人名识别原理介绍

    Hanlp自然语言处理包中的基于HMM-Viterbi处理人名识别的内容大概在年初的有分享过这类的文章,时间稍微久了一点,有点忘记了.看了 baiziyu 分享的这篇比我之前分享的要简单明了的多.下面 ...

  2. rownum伪行号-排行榜-分页

    rownum伪行号-排行榜-分页 1.rownum 是oracle数据库特有的一个特性,它针对每一个查询(包括子查询),都会生成一个rownum用于对该次查询进行编号 2.每个rownum只针对当前s ...

  3. MySQL中的触发器应用

    直接上代码: /*数据库 - udi_ems_test*********************************************************************内容:在 ...

  4. springboot通过slf4j配置日志

    原因:SpringBoot默认使用slf4j日志,引入其他框架的时候,只需要把这个框架依赖的日志框架排除掉: 而我今天想引入log4j的时候,pom文件一直报错,显示找不到log4j的jar包,应当是 ...

  5. docker-get拉取镜像

    docker-get Let you get all docker images without having network problem. Install curl -kLO https://s ...

  6. Jmeter博文索引~基础知识和实践操作汇总

    所有Jmeter笔记的目录/索引 一,基础操作和常用操作 Jmeter入门(一)理论基础 Jmeter安装及配置(含JDK安装) Jmeter之设置线程组运行次数/时间 Jmeter之参数化(4种设置 ...

  7. k8s之网络插件flannel及基于Calico的网络策略

    1.k8s网络通信 a.容器间通信:同一个pod内的多个容器间的通信,通过lo即可实现; b.pod之间的通信:pod ip <---> pod ip,pod和pod之间不经过任何转换即可 ...

  8. 复习二叉数 pat l2-006 数的遍历

    L2-006. 树的遍历   给定一棵二叉树的后序遍历和中序遍历,请你输出其层序遍历的序列.这里假设键值都是互不相等的正整数. 输入格式: 输入第一行给出一个正整数N(<=30),是二叉树中结点 ...

  9. ArrayList插入1000w条数据的时间比较分析

    一分钟系列: 读懂GC日志 ArrayList插入1000w条数据之后,我怀疑了jvm... Java JIT性能调优 Java性能优化指南系列(三):理解JIT编译器 准备:调试程序加入VM Opt ...

  10. Django rest-framework框架-版本控制

    第一版: from rest_framework.versioning import BaseVersioning class ParamVersion(object): def determine_ ...