0

I'm playing around with a way to find all network assets from the command line that will return an IP, a hostname, and then have a way to see all interfaces associated with that host.

I was using something like:

nmap -sP 10.40.. | grep 'is up' | cut -c5- > LiveHosts.txt

This works okay and gives me a list with hostnames and IP's, but there are cases where you might have a host with 6 NIC's in it, so I would like to be able to spit this out to a spreadsheet and then show what IP's are assigned to the host. Something sort of like:

ifconfig | grep 'inet addr' | cut -d: -f2

that way showing a list of IP's that are assigned to that host. The issue is that I'm now running something on the host and not a broad scan using something like nmap.

Has anyone done something of this nature to get a host list of assets showing that IP's they are using? Or can someone recommend something that would work in this case?

sure.

something that I can toss into a spreadsheet, but basically:

Hostname                   IP address(s)

testhost.dom.com       10.40.2.5,10.34.3.20,10.16.3.4
testhost1.dom.com     10.17.38.5
host954.dom.com       172.16.23.39,10.43.2.1

That sort of thing, where it would list IP's that it's found on each host.

I'm starting to wonder whether it would be better to output the results (just with the IP's) from the nmap to a file, and then use the file to connect to the hosts to run something like:

hostname && ifconfig | grep 'inet addr' | cut -d: -f2 | awk '{print $2}' | sed '/^$/d'

EEAA
  • 109,363
  • 18
  • 175
  • 245

1 Answers1

0

You can't get that information from the outside.

Before you go too far on the custom hack path, investigate common open source monitoring solutions. You can model your hosts in any of them and define the NICs that should be connected. Use the right tool for the job.

It also helps if your internal DNS naming convention ties various nics to its host (like eth0.sfo13.example.com, eth9.sfo13.example.com).