批处理获取局域网中的MAC地址

 

@echo off

mode con cols
= 50  lines = 20   &  color 1f

title
= 获取内网MAC地址

if  exist GetMAC.txt del  / / s GetMAC.txt

set  start = 1
set  top = 1
set   end = 254
set  War = 192.168 . 1
cls

echo                获取局域网中的MAC地址  
echo.
& echo                    作者:寒冰 
echo           
==============================
echo              请按照下面的提示输入数据
echo           
==============================
echo.
& echo.
set   / p War =   输入网段如( 192.168 . 1 ):
echo.
set   / p start =   输入IP地址的启始码:
echo.
set   / p top =   输入IP地址的跳越码:
echo.
set   / end =   输入IP地址结束码:

echo.
& echo. & echo.

echo       正在扫描网络上的主机!
echo.
& echo                  请稍后..


@
rem  主程序开始

for   / l %%i in (%start%,%top%,% end %)  do  ping %War%.%%i  - 1   - 1   > NUL  &   call  :Arp %War%.%%i

cls
echo.
& echo. & echo. & echo. & echo.
echo     IP与MAC查找完毕
ping 
127.0 . 0.1   - 3   > nul
start GetMAC.txt
exit


:Arp
for   / "  usebackq skip=3 tokens=1,2 delims=  "  %%i in (`arp  - a % 1 `)  do   if   NOT  %%j == 00 - 00 - 00 - 00 - 00 - 00  echo %%i   %%j  >> GetMAC.txt

转载于:https://www.cnblogs.com/madgoat/articles/983503.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在VB.NET获取局域网IP地址,可以使用System.Net.NetworkInformation命名空间的相关类和方法。 首先,可以使用NetworkInterface类来获取本地计算机上的网络接口信息。可以通过NetworkInterface.GetAllNetworkInterfaces方法获取所有网络接口的列表,并遍历该列表来获取每个网络接口的信息。 然后,可以根据每个网络接口的信息,使用IPInterfaceProperties类的UnicastAddresses属性获取每个接口的单播地址列表。从这个列表,可以筛选出是IPv4地址、非回环地址、以太网地址等符合条件的IP地址。 最后,将符合条件的IP地址存储在一个集合,并将其打印出来或进行其他处理。 以下是一个简单的示例代码: ```vb Imports System.Net.NetworkInformation Module Module1 Sub Main() Dim ipAddresses As New List(Of String)() ' 获取所有的网络接口 Dim networkInterfaces As NetworkInterface() = NetworkInterface.GetAllNetworkInterfaces() For Each networkInterface As NetworkInterface In networkInterfaces ' 获取网络接口的IP属性 Dim ipProperties As IPInterfaceProperties = networkInterface.GetIPProperties() ' 获取接口的单播地址列表 Dim unicastAddresses As UnicastIPAddressInformationCollection = ipProperties.UnicastAddresses For Each unicastAddress As UnicastIPAddressInformation In unicastAddresses ' 筛选出IPv4地址、非回环地址和以太网地址 If unicastAddress.Address.AddressFamily = System.Net.Sockets.AddressFamily.InterNetwork AndAlso Not IPAddress.IsLoopback(unicastAddress.Address) AndAlso networkInterface.NetworkInterfaceType = NetworkInterfaceType.Ethernet Then ipAddresses.Add(unicastAddress.Address.ToString()) End If Next Next ' 打印IP地址 For Each ipAddress As String In ipAddresses Console.WriteLine(ipAddress) Next Console.ReadLine() End Sub End Module ``` 运行上述代码,就可以获取局域网IP地址,并将其打印出来。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值