Print all Host on local network

Hello guys,

I would like to develop a script which takes a host name as argument and displays a message whether the host is on the local network or not. How can I accomplish that? Is there a file or command that I can use to list all host on the local network? :confused:

you can ping the host can compare it to you ip. If is is different than it is not local.

But this involves IP addresses, or is that also possible with a string host name i.e "UNIX01"?

This pertains to linux machines, may be different on others:
arp -a dumps your machine's "Address Resolution Protocol" cache, i.e. your active connections.
ping -b pings the entire local network BUT machines have to be setup to answer.

Hi,

You can try this;

$ for ip in `echo '[1+pd254>aq]sa0 1-lax' | dc`; do ping -c 1 10.176.128.$ip>/dev/null; [ $? -eq 0 ] && echo "10.176.128.$ip UP" ; nslookup 10.176.128.$ip || : ; done

Where the XXX.XXX.XXX is your first three octets.

Regards

Dave