Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
316 views
in Technique[技术] by (71.8m points)

linux - nmap command to list the Mac OS x machines in network

I know the Nmap command using terminal to list all the live hosts in my WiFi network. How to tell Namp to list only mac ox IP address only.

This is possible using Nmap?. I guess it should be possible. Since Finder -> Network is able to show the hostnames of other machines on the network.

nmap -sP 192.168.0.0/24

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can use the -A flag of nmap and then pipe through to awk to print only the IP addresses you need. I have no Mac machines on my network but taking Windows machines as an alternate example:

nmap -A 192.168.0.0/24 | awk '/^Nmap scan report for/ { ip=$5 } /^Service Info:/ { split($0,map,":");if ( map[3] ~ "Mac OS X" ) { print ip } }'

Take the output of nmap and then, for each line starting with "Nmap scan report for", store the 5th space delimited field in the variable ip. Then when a line starts with "Service Info:", split the line into an array map based on ":" as the delimiter. Print the variable ip if the 3rd index of the map field pattern matches "Windows" (Change this to what ever text shows for Mac machines)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...