[ALUG] What's a fast way to check for something on LAN?

Chris Green cl at isbd.net
Wed Feb 22 13:50:28 GMT 2017

I want a fast (as in less than a second, not 'computer fast') way of
checking if a particular private IP is present on the LAN.  

I need this for use in a match construct in an SSH config file, e.g.:-

# odin may be remote or local from t430
Match host odin exec "sh -c 'hostNotLocal'"
    ProxyCommand ssh cheddar nc -q0 localhost 51234

Currently 'hostNotLocal' is:-

# Test if specified host is ping'able
! ping -c 1 $1 >>/dev/null 2>&1

The problem with this is that on any LAN except one using
192.168.0.xxx it takes several seconds to decide that
isn't there.

For any nit-pickers, yes I know if I just happen to be connected to a
LAN which isn't where 'my' is I'll get a false positive
but I can live with that.  I just want a fast way of knowing that *isn't* there.

Chris Green

More information about the main mailing list