怎么获得路由的IP 我们学校是每个宿舍两个网口,每个网口有固定的IP,一个宿舍常通过路由来上网,我想获得网口的IP,有什么办法么? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 开始 运行cmdipconfig/all想办法得到里面的数据 我觉得有两个办法1是web登陆你的路由,得到它的IP,前提是路由设备可网管2是得到你自己的网关,按我的理解,你的网关和DNS都是路由的IP才对得到自己网关是完全可以做到的 是我理解错了,如果你的路由设备有DHCP,那更难得到路由上端的IP我的思路是这样:你可以写个路由跟踪的小功能,如果你的电脑直接接了路由器,路由器又直接接了你宿舍的网口,那你tracert的第2跳,就是你宿舍网口的地址,所谓第2跳不知道你是否理解,你机器是0,它的上个设备就是1,再上就是2我这有段代码,没经过测试,是路由跟踪的实现,你可以自己看下using System.Net;using System.Net.Sockets;//定义ICMP结构///在构造ICMP包时,需要首先定义几个ICMP包用到的结构。 struct ICMPConstants { public const int ICMP_ECHOREPLY= 0; public const int ICMP_TIMEEXCEEDED= 11; public const int ICMP_ECHOREQ= 8; public const int MAX_TTL= 256; } //ICMP 包头 struct ICMP { public byte type; public byte code; public ushort checksum; public ushort id; public ushort seq; // 次序 } // ICMP 应答请求 struct REQUEST { public ICMP m_icmp; public byte []m_data;}//函数CreatePacket//函数CreatePacket用来构造一个符合要求的ICMP数据包,具体实现如下:public static byte[] CreatePacket( REQUEST req ){ Byte[] ByteSend= new Byte[PACKET_SIZE+ 8]; ByteSend[0]= req.m_icmp.type; ByteSend[1]= req.m_icmp.code; Array.Copy(BitConverter.GetBytes(req.m_icmp.checksum), 0, ByteSend, 2, 2); Array.Copy(BitConverter.GetBytes(req.m_icmp.id), 0, ByteSend, 4, 2); Array.Copy(BitConverter.GetBytes(req.m_icmp.seq), 0, ByteSend, 6, 2); for(int i=0; i< req.m_data.Length; i++) ByteSend[i+8]= req.m_data[i]; //计算校验和 int iCheckSum = 0; for (int i= 0; i < ByteSend.Length; i+= 2) iCheckSum += Convert.ToInt32( BitConverter.ToUInt16(ByteSend,i)); iCheckSum = (iCheckSum >> 16) + (iCheckSum & 0xffff); iCheckSum += (iCheckSum >> 16); Array.Copy(BitConverter.GetBytes((ushort)~iCheckSum), 0, ByteSend, 2, 2); return ByteSend; } C#用Oracle提供的dll连接Oracle数据库,一定要装oracle客户端么? C# 里的sendkeys.send的实现原理 C#怎么样调用VC的DLL? 新手菜鸟问题....求教思路,一小程序实现qq的自动登陆 C#中有没有像 Java 中的 final 方法 !? 托管,委托,代理,在C++中相当于哪些知识点啊 TekTronix示波器 VISA 通讯ERROR 简单代码帮忙查一下错误! C#学习,菜鸟求助 我的InterDev6.0不能正常工作了? 求一段代码,大家帮帮忙啊!! 太多委托好累,InvokeRequired有没有通用的做法?
cmd
ipconfig/all
想办法得到里面的数据
1是web登陆你的路由,得到它的IP,前提是路由设备可网管
2是得到你自己的网关,按我的理解,你的网关和DNS都是路由的IP才对
得到自己网关是完全可以做到的
我的思路是这样:你可以写个路由跟踪的小功能,如果你的电脑直接接了路由器,路由器又直接接了你宿舍的网口,那你tracert的第2跳,就是你宿舍网口的地址,所谓第2跳不知道你是否理解,你机器是0,它的上个设备就是1,再上就是2
我这有段代码,没经过测试,是路由跟踪的实现,你可以自己看下using System.Net;using System.Net.Sockets;//定义ICMP结构/
//在构造ICMP包时,需要首先定义几个ICMP包用到的结构。 struct ICMPConstants { public const int ICMP_ECHOREPLY= 0; public const int ICMP_TIMEEXCEEDED= 11; public const int ICMP_ECHOREQ= 8; public const int MAX_TTL= 256; } //ICMP 包头 struct ICMP { public byte type; public byte code; public ushort checksum; public ushort id; public ushort seq; // 次序 } // ICMP 应答请求 struct REQUEST { public ICMP m_icmp; public byte []m_data;}//函数CreatePacket
//函数CreatePacket用来构造一个符合要求的ICMP数据包,具体实现如下:public static byte[] CreatePacket( REQUEST req ){ Byte[] ByteSend= new Byte[PACKET_SIZE+ 8]; ByteSend[0]= req.m_icmp.type; ByteSend[1]= req.m_icmp.code; Array.Copy(BitConverter.GetBytes(req.m_icmp.checksum), 0, ByteSend, 2, 2); Array.Copy(BitConverter.GetBytes(req.m_icmp.id), 0, ByteSend, 4, 2); Array.Copy(BitConverter.GetBytes(req.m_icmp.seq), 0, ByteSend, 6, 2); for(int i=0; i< req.m_data.Length; i++) ByteSend[i+8]= req.m_data[i]; //计算校验和 int iCheckSum = 0; for (int i= 0; i < ByteSend.Length; i+= 2) iCheckSum += Convert.ToInt32( BitConverter.ToUInt16(ByteSend,i)); iCheckSum = (iCheckSum >> 16) + (iCheckSum & 0xffff); iCheckSum += (iCheckSum >> 16); Array.Copy(BitConverter.GetBytes((ushort)~iCheckSum), 0, ByteSend, 2, 2); return ByteSend; }