獲取伺服器的IP位址和MAC位址

2021-06-19 01:20:34 字數 677 閱讀 2742

獲取伺服器的ip位址和mac位址

獲取伺服器的ip位址方法以dns法較為簡單實用,如下:

以下是引用片段:

private void buttonip_click(object sender, system.eventargs e)

else

} 以下是引用片段:

using system.management;

string stringmac = "";

string stringip = "";

managementclass mc = new managementclass "win32_networkadapterconfiguration");

managementobjectcollection moc= mc.getinstances();

foreach(managementobject mo in moc)

}  以下是引用片段:

using system.net;

textip.text=page.request.userhostaddress;

如要獲取客戶端本機的mac位址就相對複雜些,得匯入呼叫兩個api,用arp協議獲取,但這樣只能獲取到同網段機器的mac,對於跨網段的得利用ip掃瞄或cmd中nbtstat命令獲取mac位址。也可通過讀取系統登錄檔值或wmi的資料庫來獲取

獲取本地Mac位址,伺服器IP,及驗證

獲取本地mac位址 public string getmac using system.management.managementclass mc new system.management.managementclass win32 networkadapterconfiguration syst...

伺服器獲取本地Ip位址

string getlocalip char buff bufsiz struct ifconf conf conf.ifc len bufsiz conf.ifc buf buff const int s socket pf inet,sock dgram,0 ioctl s,siocgifcon...

delphi 實現通過ip位址獲取mac位址

function sendarp ipaddr ulong temp dword ulmacaddr pointer ulmacaddrleng pointer dword stdcall external iphlpapi.dll name sendarp function getmacbyip ...