Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 06 Dec 2018 16:06:35 -0700
From:      JD <jd1008@gmail.com>
To:        freebsd-questions@freebsd.org
Subject:   Re: sh code to determine if host is on lan
Message-ID:  <5C09AB7B.4010001@gmail.com>
In-Reply-To: <5C099F41.2020407@gmail.com>
References:  <5C099F41.2020407@gmail.com>

Next in thread | Previous in thread | Raw E-Mail | Index | Archive | Help


On 12/06/2018 03:14 PM, Ernie Luzar wrote:
> Hello list
>
> Know that "route -n get default" will give me the nic name of the 
> interface connected upstream. That "ifconfig nic" will give me the ip 
> address. That if that ip address is one of these ranges
> 192.168/16 or 172.16/12 or 10/8 then the host is on a lan.
>
> Is this the only way to determine if the host is on a lan?
>
I you do not want to know all that info you already
stated, why don;t you ping something with a count of 1,
such as yahoo.com:
ping -c 1 yahoo.com
[ $? -ne 0 ] && echo "not on internet" || echo "On Internet"





Want to link to this message? Use this URL: <http://docs.FreeBSD.org/cgi/mid.cgi?5C09AB7B.4010001>