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?

+2


source to share


4 answers


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.

0


source


MIB_IF_TYPE_LOOPBACK

probably refers to the loopback address 127.0.0.1. It should be possible to find out if the adapter is a Microsoft Loopback adapter if it received a static (or configurable) MAC address (Ethernet address). Or maybe he doesn't have it?



0


source


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

      



0


source


You can use WMI to check the driver for each network interface.

-1


source







All Articles