Re: [SLUG] Unknown command

From: Eben King (eben1@tampabay.rr.com)
Date: Sun Nov 06 2005 - 21:38:53 EST


On Sun, 6 Nov 2005, Paul M Foster wrote:

> Anyone know of a command that will cause other machines on a subnet to
> echo back their IPs and names? Obviously, this wouldn't work if you had
> to know the names of the machines first. So it would have to be like a
> broadcast command that used ICMP or something to cause others to answer.
> Anyone know of such a beast? Seems like I should know this, but I don't.

>From what I hear, you used to be able to ping the broadcast address and have
every host in that subnet respond, but that must have been before my time.
Something like this might work. (Untested, though its components have been
lightly tested; use at your own risk.)

ping_subnet () {
 # Usage: ping_subnet 192.168.1
 # Slow, but it should work
 for host in `seq 1 254` ; do
  ping -c 1 "$1".$host -w 1
 done | grep 'bytes from' | cut -f 4 -d ' ' | tr -d :
}

Up to someone else to provide IP addr -> hostname mapping. "host" doesn't
work for me for names in /etc/hosts .

-- 
-eben    ebQenW1@EtaRmpTabYayU.rIr.OcoPm    home.tampabay.rr.com/hactar
CAPRICORN:  The stars say you're an exciting and wonderful person...
but you know they're lying.  If I were you, I'd lock my doors and
windows and never never never never leave my house again.  -- Weird Al

----------------------------------------------------------------------- This list is provided as an unmoderated internet service by Networked Knowledge Systems (NKS). Views and opinions expressed in messages posted are those of the author and do not necessarily reflect the official policy or position of NKS or any of its employees.



This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 19:50:14 EDT