0

I want an output like this:

IP Address: 192.168.1.1
Hostname:Test-PC

This is what I have done:

test(){  
        ping -c 1 $1 > /dev/null      
        [ $? -eq 0 ] && echo "IP Address": $i is online.  
}

for i in 192.168.1.{1..255}  
do  
test $i & disown  
done  

I added this line to collect the hostname, which failed. How could I get the hostname?

nmap -sU --script nbstat.nse -p137 192.168.11.*  
  • 2
    For the Nmap scan try 192.168.11.0/24 – Nordlys Jeger Jan 25 at 18:56
  • 1
    Why not just use host, nslookup or dig? – Thomas Jan 26 at 10:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.