Loopback adapter detection
What is the best way to determine if a network interface is a loopback adapter?
The Windows API GetAdaptersInfo and GetAdaptersAddresses specify that they will return whether the loopback interface is over Type ( MIB_IF_TYPE_LOOPBACK ). but none of them do for the Microsoft Loopback adapter, at least it is reported as a standard ethernet interface.
I could try checking the Loopback's MAC MAC address, but that can be easily spoofed.
I can check the name " Microsoft Loopback Adapter " in the description, but it may have translation issues and may lead to other issues.
IP addresses can also be changed.
What's the safest method to do this?
source to share
The Microsoft Loopback Adapter is designed to spoof the network. He lies to you because that is his goal. MSDN link .
The Microsoft Loopback Adapter is a virtual network testing tool where network access is not available. In addition, you must use the Loopback Adapter if there are conflicts with the network adapter or with the network adapter driver. You can bind network clients, protocols, and other network configuration items for the Loopback adapter, and you can install the network adapter driver or network adapter later while preserving the network configuration information. You can also install the Loopback adapter during the installation process.
source to share
Use WMI, see WMI Code Creator v1.0 for a sample :
strComputer = "."
Set objWMIService = GetObject("winmgmts:\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery( _
"SELECT * FROM Win32_PerfRawData_Tcpip_TCP",,48)
For Each objItem in colItems
Wscript.Echo "-----------------------------------"
Wscript.Echo "Win32_PerfRawData_Tcpip_TCP instance"
Wscript.Echo "-----------------------------------"
Wscript.Echo "Name: " & objItem.Name
Next
source to share