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
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)
It reports Macs as "Mac OS X" (although Apple actually calls it "macOS", starting with version 10.12).
Unfortunately the nmap -A command is able to give only the service information of my router (192.168.0.1) but it is not showing the service info of the other real windows or mac hosts on the network.
@Raman Sailopal Thank you for the answer, this command is working to find mac os x, some reasons it is not working to find windows machines. "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 } }'" ➡️➡️ Please edit your answer accordingly, you have to replace string from "Windows" to "Mac OS X" in your command in the answer.
No worries. Changed.