ProCurve / ProVision-Based
cancel
Showing results for 
Search instead for 
Did you mean: 

How to get hostnames on all connected devices

crabtreecj
Occasional Advisor

How to get hostnames on all connected devices

I have a 2530 switch and was wondering, is there a way to display all the devices connected to the switch. Hopefully by hostname or by IP. I figured this would be simple but couldn't find anything after a quick Google search.

Thanks!
11 REPLIES
parnassus
Honored Contributor

Re: How to get hostnames on all connected devices

From a Switch standpoint is generally true that you can do a MAC Address <-> Switch Port mapping and then infer about known/unknown discovered MAC Addresses to understand what devices (so, eventually, which hostnames) are really connected to within your Subnet(s)...doing so you can also easily discover (even without deploying LLDP) if there are other "foreing" Switches connected to your Switch ports (sometimes Network topology become, during years, very unknown to some IT Administrators!).

Generally by examining the Switch ARP Table and its discovered MAC Addresses you can build a "Switch Port - MAC Address - IP Address - VLAN Id - Hostname" list (or sort of)...but that will happen using different discovery (manual/automatic) methods, not relaying only on your Switch internal capabilities/features.

HP-Browniee
Trusted Contributor

Re: How to get hostnames on all connected devices

Hi

"show lldp neighbors" should do the trick.

Kind regards

 

TerjeAFK
Respected Contributor

Re: How to get hostnames on all connected devices

Or "show lldp info remote-device" since this is a 2530.

parnassus
Honored Contributor

Re: How to get hostnames on all connected devices

Consider that primarily LLDP is used to collect infomation from neighboring switches and other media devices (through LLDP-MED), reference here...I personally doubt it can collect Host's hostnames (FQDNs or simply host names <- both are set on Hosts at their Operating System level), for sure it can collect neighborig switches' system names.

crabtreecj
Occasional Advisor

Re: How to get hostnames on all connected devices

I'll try the command when I get on site. I thought of another way to find what I'm needing. If I can get a list of all the mac addresses and what port their connected to, then use a program to scan my network and pull the hostname's and mac from all my devices then I can join the data in a database or excel and then I'll have my Hostname, port number, and mac address. I just have to find the software that can do all this and the command to see what mac is on what port. I currently use a solar winds product to scan my network, but I don't believe it lists mac addresses, just IP and hostname. I was just hoping there was a way to do it from the CLI, but it looks like I'm going to have to add in a couple more steps. 

But I'll try what you all have said and see if it's what I need. I'll etl you know how it turns out. If you can think of anything else or if anyone knows of a good freeware, or cheap software that will scan my network and give me Hostname, and mac, please let me know. 

parnassus
Honored Contributor

Re: How to get hostnames on all connected devices

If Linux terminal doesn't scare you, nmap and arp-scan are your friends to do an ARP scan on your subnet(s).

zenmap, eventually, is the GUI frontend of nmap if you use a graphical desktop environment.
crabtreecj
Occasional Advisor

Re: How to get hostnames on all connected devices

When using "show lldp info remote-device" I'm given 3 devices which shows me 3 mac addresses. It appears that the 3 devices are 3 other switches on the same network, but it doesn't list any of the other devices plugged into the switch. Why wouldn't it list everything plugged into the switch?

Vince-Whirlwind
Honored Contributor

Re: How to get hostnames on all connected devices

You need to carry out 3 operations to produce this list:

1/ On the switch:
show mac-address table.
This give you the switchport to MAC address mapping.

2/ On the layer3 switch/router:
show arp
This gives you the MAC address to IP address mapping 

3/ use nslookup to resolve IP address to hostname.

You could write scripts to gather the info and pass the results to the next script and eventually output the whole thing as a list or table.

Alternatively, get hold of tool such as Solarwinds "Switchport mapper" to do it for you.

parnassus
Honored Contributor

Re: How to get hostnames on all connected devices


crabtreecj wrote: ...but it doesn't list any of the other devices plugged into the switch. Why wouldn't it list everything plugged into the switch?

Please, re-read replies provided above: answers given were plain clear, already in front of your eyes.

crabtreecj
Occasional Advisor

Re: How to get hostnames on all connected devices

otice when I ping an adress then use "show arp" I then get the mac and port like I'm looking for. I'm guessing theres no command that will ping a range of Ip's are there? I'm downloading nmap to try to use it for this but I couldn't find a command to ping a particular range. 

parnassus
Honored Contributor

Re: How to get hostnames on all connected devices

From an Host supporting nmap the command below should do what you want:

nmap -sP subnet-ip-address/subnet-mask

As example:

nmap -sP 192.168.100.0/24

Will perform a ping scan against 192.168.100.0/24 subnet.