windows 如何获取 LAN 上活动 IP 地址、MAC 地址和 NetBIOS 名称的列表?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/90755/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 05:19:07  来源:igfitidea点击:

How do I get a list of the active IP-addresses, MAC-addresses and NetBIOS names on the LAN?

windowsnetworkingpowershellsysadminwsh

提问by agnul

How do I get a list of the active IP-addresses, MAC-addresses and NetBIOSnames on the LAN?

如何获取LAN 上活动 IP 地址、MAC 地址和NetBIOS名称的列表?

I'd like to get NetBIOS name, IP and MAC addressesfor every host on the LAN, preferably not having to walk to every single PC and take note of the stuff myself.

我想获得LAN 上每台主机的NetBIOS 名称、IP 和MAC 地址,最好不必走到每台 PC 并自己记下这些内容。

How to do that with Windows Script Host/PowerShell/whatever?

如何使用Windows Script Host/PowerShell/whatever来做到这一点?

回答by mana

As Daren Thomas said, use nmap.

正如达伦托马斯所说,使用 nmap。

 nmap -sP 192.168.1.1/24

to scan the network 192.168.1.*

扫描网络 192.168.1.*

 nmap -O 192.168.1.1/24

to get the operating system of the user. For more information, read the manpage

获取用户的操作系统。有关更多信息,请阅读联机帮助页

 man nmap

regards

问候

回答by Matthew Schinckel

arp -a

That gets everything the current machine knows about on the network.

这获得了当前机器在网络上知道的一切。

(I'm putting this up there as a second option, since nmap isn't universally installed).

(我把它作为第二个选择,因为 nmap 没有普遍安装)。

回答by Tubs

If you're using DHCP then the server will give you a list of all that information.

如果您使用的是 DHCP,那么服务器将为您提供所有信息的列表。

This website has a good tutorial on using powershell to get networking information http://www.powershellpro.com/powershell-tutorial-introduction/powershell-scripting-with-wmi/

这个网站有一个很好的使用powershell获取网络信息的教程http://www.powershellpro.com/powershell-tutorial-introduction/powershell-scripting-with-wmi/

If you neet to get quick list of computer names you can use "net view". Also have a look at nbmac although I'm unsure of it's working status under XP. Another option could be to use nbtstat -a (once you've used net view to list workstations)

如果您需要快速获取计算机名称列表,您可以使用“网络视图”。也看看 nbmac 虽然我不确定它在 XP 下的工作状态。另一种选择是使用 nbtstat -a(一旦您使用 net view 列出工作站)

回答by Shay Levy

In PowerShell you can do something like:

在 PowerShell 中,您可以执行以下操作:

$computers = "server1","server2","server3"

$computers = "server1","server2","server3"

Get-WmiObject Win32_NetworkAdapterConfiguration -computer $computers -filter "IPEnabled ='true'" | select __Server,IPAddress,MACAddress

Get-WmiObject Win32_NetworkAdapterConfiguration -computer $computers -filter "IPEnabled ='true'" | 选择 __Server,IPAddress,MACAddress

回答by mjsr

In PowerShell:

在 PowerShell 中:

function Explore-Net($subnet, [int[]]$range){
    $range | % { test-connection "$subnet.$_" -count 1 -erroraction silentlycontinue} | select -Property address | % {[net.dns]::gethostbyaddress($_.address)}
}

Example:

例子:

Explore-Net 192.168.2 @(3..10)