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

5

5

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

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

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

Abernathy answered 18/9, 2008 at 7:42 Comment(0)
R
10

As Daren Thomas said, use nmap.

 nmap -sP 192.168.1.1/24

to scan the network 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

Rayburn answered 18/9, 2008 at 8:7 Comment(2)
I can't find an option to make nmap return MAC addresses.Eugenol
@Eugenol : As mana mentionned: nmap -O 192.168.1.1/24 returns the MAC addresses (and other informations as well), note that you may need to be root or to sudo in order to be able to do that.Disjointed
N
8
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).

Nucleolated answered 18/9, 2008 at 8:14 Comment(2)
However arp will only work if you have routes to every PC on that segment of the network; so you need to ping every IP first!Chericheria
You probably could use a broadcast ping first, but that relies on machines responding to pings.Nucleolated
C
2

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

This website has a good tutorial on using powershell to get networking information 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)

Collincolline answered 18/9, 2008 at 7:53 Comment(0)
B
1

In PowerShell you can do something like:

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

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

Bubal answered 18/9, 2008 at 16:59 Comment(1)
Turns out that in my specific LAN setup using nmap on a linux box is much easier, even if nmap can't figure out netbios names. Of course I should take some time to learn powershell and WMI, just for fun.Abernathy
I
1

In 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)
Immolation answered 27/2, 2011 at 19:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.