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

Chris Green cl at isbd.net
Wed Feb 22 15:25:41 GMT 2017


On Wed, Feb 22, 2017 at 02:22:17PM +0000, Laurie Brown wrote:
> On 22/02/17 13:50, Chris Green wrote:
> > 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.  
> 
> [SNIP]
> 
> ---- cut here ----
> ~ $ nmap -sn 10.0.1.254
> 
> Starting Nmap 6.40 ( http://nmap.org ) at 2017-02-22 14:16 GMT
> Nmap scan report for 10.0.1.254
> Host is up (0.00078s latency).
> Nmap done: 1 IP address (1 host up) scanned in 0.00 seconds
> 
>  ~ $ nmap -sn 10.0.1.80
> 
> Starting Nmap 6.40 ( http://nmap.org ) at 2017-02-22 14:17 GMT
> Note: Host seems down. If it is really up, but blocking our ping probes,
> try -Pn
> Nmap done: 1 IP address (0 hosts up) scanned in 3.00 seconds
> 
> ---- cut here ----
> 
> If it's there it's faster, so just change your logic...
> 
You've illustrated my problem perfectly!  That 3 seconds delay is the
same delay I see using my original ping method.

I need to find out, fast, if 192.168.0.104 isn't on the LAN I'm
connected to.  To do this I have to run your second case above which
takes, like my ping, 3 seconds to execute.

It's not possible to 'change the logic'.  The ssh config file has the
following in it:-

    Match host odin exec "hostNotLocal 192.168.0.104"
        ProxyCommand ssh cheddar nc -q0 localhost 51234

    Host odin
        HostName 192.168.0.104

Simply reversing the logic to:-

    Match host odin exec "hostIsLocal 192.168.0.104"
        HostName 192.168.0.104

    Host odin
        ProxyCommand ssh cheddar nc -q0 localhost 51234

Makes no difference at all.  The hostIsLocal command will take 3
seconds to fail when it's not local and I'm no better off.

-- 
Chris Green



More information about the main mailing list