有喜欢用tcpdump/windump抓包工具的筒子们吗?其自带的-D参数可列出可用网卡列表,但显示的结果不够友好,不知道与网络连接中的网卡名称、IP地址、MAC地址等如何对应,所以编写了这个辅助脚本。- :: nic.bat by wscript @ www.bathome.net
- @echo off
- setlocal enableDelayedExpansion
- echo Network Interface Card
- echo -------------------------------------------------------------------------------
- for /f "tokens=1,3* delims=.{}" %%a in ('windump -D') do (
- for /f "delims=" %%i in ('
- wmic nicconfig where "SettingID='{%%b}'" get Index^,IPAddress^,MACAddress /value ^| find "="
- ') do set %%i
-
- for /f "delims=" %%i in ('
- wmic nic !Index! get NetConnectionID /value ^| find "="
- ') do set %%i
-
- set Adapter=%%c
- set "Adapter=!Adapter:* =!"
- set "Adapter=!Adapter:~1,-1!"
- echo %%a.!Adapter!
- echo Name = !NetConnectionID!
- echo MACAddress = !MACAddress!
- echo IPAddress = !IPAddress!
- echo;
- )
- endlocal
复制代码 结果对比
# windump -D
1.\Device\NPF_{4C4FE84D-A851-4891-A16B-92F3C94621A7} (Broadcom 802.11n Q?Mh (Mic
rosoft's Packet Scheduler) )
2.\Device\NPF_{A7CAE752-C73F-42E4-9783-83548F12EB17} (MS LoopBack Driver)
3.\Device\NPF_{58F72805-2DD4-4AC2-AECB-481FFF504375} (VMware Virtual Ethernet Ad
apter)
# nic.bat
Network Interface Card
-------------------------------------------------------------------------------
1.Broadcom 802.11n Q?Mh (Microsoft's Packet Scheduler)
Name = 无线网络连接 2
MACAddress = 4C:EDE:90:D6:30
IPAddress = {"192.168.1.11"}
2.MS LoopBack Driver
Name = Microsoft Loopback Adapter
MACAddress = 02:00:4C:4F:4F:50
IPAddress = {"172.16.100.1","172.16.100.11"}
3.VMware Virtual Ethernet Adapter
Name = VMnet1-Host-Only
MACAddress = 00:50:56:C0:00:01
IPAddress = {"192.168.174.1"} |