如何取得客户端网卡MAC地址?谢谢!

baker_gw 2004-03-24 04:04:25
我想是不是有权限问题,可能直接使用asp.net无法实现,是否需要做一个activeX程序,写activeX我又不太懂。
我还有一个想法:
1.asp.net能取得客户机IP地址
2.server里可以通过命令行nbtstat -a IP取得ip对应的网卡的IP地址
把以上两个结合起来,最终取得客户机的mac
可行吗
最主要的问题是服务端运行的asp.net程序如何执行命令行并取得结果值
从中找出mac地址
谢谢
...全文
90 20 打赏 收藏 转发到动态 举报
写回复
用AI写文章
20 条回复
切换为时间正序
请发表友善的回复…
发表回复
阿森纳2013 2004-03-26
  • 打赏
  • 举报
回复
学习
学习
再学习
baker_gw 2004-03-26
  • 打赏
  • 举报
回复
各位同志
我就是在局域网内取MAC
是为了控制系统安全
要获取登陆方的MAC地址
webdiyer 2004-03-26
  • 打赏
  • 举报
回复
try:

http://groups.google.com/groups?hl=zh-CN&lr=&ie=UTF-8&oe=UTF-8&threadm=%23wOfj%24PPCHA.1320%40tkmsftngp09&rnum=1&prev=/groups%3Fq%3Dget%2Bmac%2Baddress%2B.net%26hl%3Dzh-CN%26lr%3D%26ie%3DUTF-8%26oe%3DUTF-8%26selm%3D%2523wOfj%2524PPCHA.1320%2540tkmsftngp09%26rnum%3D1
geopower 2004-03-25
  • 打赏
  • 举报
回复
学习中......
ahui_net 2004-03-25
  • 打赏
  • 举报
回复
路由是不转发客户的mac的
conquersky 2004-03-25
  • 打赏
  • 举报
回复
webdiyer说的都是 基于广域网的! 楼主如果是在互联网上应用的话 获取mac 是不可行的
webdiyer 2004-03-25
  • 打赏
  • 举报
回复
看一个帖子:

Because of the way that the internet was designed and the way that the IP protocol works, you wouldn't be able to find a mac address of someone unless you were local to them. The post earlier about using ping and arp is correct. The mac address is put into the IP packet at the 2nd level of the OSI model, its a physical address... once you go out through a router the mac address of the reported packet is changed, and is changed each and every time.. think of the mac as a "Return" address. You send out a packet and it goes across the country, and goes through 5 routers, the mac address on the packet will change each and every time it goes through a router, where the IP address won't. It's a type of routing code that the routers use to identify where the packet came from and where to send a response to.

example

Machine A sends a packet to Machine B, and it passes through Firewall C and D. The packet does this:

Machine A sends the packet to firewall C, firwall C repackages the packet with its mac address and looks for the quickest route to machine B, it determines that firewall D is the closest to it, so it repackages the packet with its own mac address (since that is where D will send a response to if it cant get to machine B) and sends it on to D.. D does the exact same thing and sends the packet to B. Once Machine B receives the packet the entire process starts over again, the last mac address that is reported is for firewall D, but the IP points to Machine A, thats how it knows where to go.
Edifier0709 2004-03-25
  • 打赏
  • 举报
回复
using System.Management;
...
ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
ManagementObjectCollection moc = mc.GetInstances();

foreach(ManagementObject mo in moc)
{
if((bool)mo["IPEnabled"] == true)
Console.WriteLine("MAC address\t{0}", mo["MacAddress"].ToString());
mo.Dispose();
}
}
KK4 2004-03-25
  • 打赏
  • 举报
回复
UP
huangsuipeng 2004-03-24
  • 打赏
  • 举报
回复
获取网卡硬件地址
using System.Management;
...
ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
ManagementObjectCollection moc = mc.GetInstances();
foreach(ManagementObject mo in moc)
{
if((bool)mo["IPEnabled"] == true)
Console.WriteLine("MAC address\t{0}", mo["MacAddress"].ToString());
mo.Dispose();
}
}
dbattn 2004-03-24
  • 打赏
  • 举报
回复
WMI的WIN32_NETWORKADAPTERCONFIGRATION
1979xt 2004-03-24
  • 打赏
  • 举报
回复
用WMI应该可以
w777 2004-03-24
  • 打赏
  • 举报
回复
server里可以通过命令行nbtstat -a IP取得ip对应的网卡的IP地址
-----------------------------------------------------
我相信你用nbtstat是ping不到我的机器的,我上网是通过了n层代理,就连IP你也取不到吧。
bestytlds 2004-03-24
  • 打赏
  • 举报
回复
只有在局域网中,才能取到MAC地址。
huangsuipeng 2004-03-24
  • 打赏
  • 举报
回复
IP是可以的,但是MAC地址就应该不行了,况且如果不是使用802。3的话,根本不会用到MAC,
ymyy 2004-03-24
  • 打赏
  • 举报
回复
用asp.net取不到的
chieftech 2004-03-24
  • 打赏
  • 举报
回复
好像直接用命令是不能实现的
dragonwzw 2004-03-24
  • 打赏
  • 举报
回复
string sendip=Request.ServerVariables["REMOTE_ADDR"].ToString(); //取得用户IP
wudixiaocaoren 2004-03-24
  • 打赏
  • 举报
回复
http://www.csharphelp.com/archives2/archive410.html
dragonwzw 2004-03-24
  • 打赏
  • 举报
回复
string sendip=Request.ServerVariables["REMOTE_ADDR"].ToString(); //取得用户IP

62,266

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧