From owner-freebsd-questions@freebsd.org Thu Dec 6 23:05:47 2018 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DE4A913179C5 for ; Thu, 6 Dec 2018 23:05:46 +0000 (UTC) (envelope-from jd1008@gmail.com) Received: from mail-io1-xd2a.google.com (mail-io1-xd2a.google.com [IPv6:2607:f8b0:4864:20::d2a]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id DCE1786CE9 for ; Thu, 6 Dec 2018 23:05:45 +0000 (UTC) (envelope-from jd1008@gmail.com) Received: by mail-io1-xd2a.google.com with SMTP id n9so1789524ioh.7 for ; Thu, 06 Dec 2018 15:05:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-transfer-encoding; bh=+CH6QtHbczU9sh7ZMH9lMIUjbmxbB7ZoArp+IxcjIzE=; b=gqTi+ivlqjcC7NbfjStNlaGrAyAoJ5QeNMX1L4ja6xEwob+mSbvzoc/vYPjHtw7TdP e6EU1Qi7WR1/4K75+1d0ELKk5qlwpHGNDqsHVrJ5bOXqY6xCrTRUsqeENVzRtpRzyXqz C8Old2K9FkX87oI6ZfCsIKelLQ3yTMXKVLytKjIXemU89xm5XA50SMuaAqb6EexsFFtI SG/I/f9bmZgC+k1n6h62l8zzu05gntOHyRooXojX76YsxF9eVitI4b5L2g+GnNBtxk0K C35EAK2cRnqpXUSuOygDWfh0oclfPwF6kzWGy0NPLrWUyiGA8uJBYlc8LszATnciqUZ4 rh0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :subject:references:in-reply-to:content-transfer-encoding; bh=+CH6QtHbczU9sh7ZMH9lMIUjbmxbB7ZoArp+IxcjIzE=; b=lVKH3W96kBHFeAiWve/OGkz/jMgB6Ld5b9O+oIusbh3Jm0j/XhQysJvnAww0nCwl8v IrWaOpPs12xByGF6XPPS8d731Q2ROUd4zaJ+A+vnFdho7iHP4BX/p6CxeJnKwPXAAEX7 bsVZXlbRnrBwzJeocEDDGmFnTFFV45ip5W8+H0sDy96P63VS2b6TIZzYX49cLM+8tHxZ MwEp1WRi40P0/4j/S9uPaupd4quHKFnFg1d5tMdCwh1W/Otlab/jWAB4NcABCs9vSNXu GSqfNX/Wipf8J5s/vIU4QIavxwpA+xhZ64jb0+9d0KsFlphb9+9aGoCCtDVwML+R56AL MlWA== X-Gm-Message-State: AA+aEWbBApKTPVVVgHlN7xUxzI8ILPufK0tHc0mS25N/14mrAs7ksn/6 2ZGA4S3h92CJgryM8oQ0b2QEgG2j X-Google-Smtp-Source: AFSGD/W/tq+07vrLw8ERGVBDQ7+9jsfw2cv8UhOCVyd2HSCFcOOChuNGZ4acGDpKbu4oFwdMdsKrgQ== X-Received: by 2002:a6b:6309:: with SMTP id p9mr23582665iog.203.1544137544993; Thu, 06 Dec 2018 15:05:44 -0800 (PST) Received: from localhost.localdomain (50-243-4-3-static.hfc.comcastbusiness.net. [50.243.4.3]) by smtp.googlemail.com with ESMTPSA id u18sm800535iom.15.2018.12.06.15.05.43 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Dec 2018 15:05:44 -0800 (PST) Message-ID: <5C09AB7B.4010001@gmail.com> Date: Thu, 06 Dec 2018 16:06:35 -0700 From: JD User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: freebsd-questions@freebsd.org Subject: Re: sh code to determine if host is on lan References: <5C099F41.2020407@gmail.com> In-Reply-To: <5C099F41.2020407@gmail.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: DCE1786CE9 X-Spamd-Result: default: False [-6.24 / 15.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_DKIM_ALLOW(-0.20)[gmail.com]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; FROM_HAS_DN(0.00)[]; R_SPF_ALLOW(-0.20)[+ip6:2607:f8b0:4000::/36]; FREEMAIL_FROM(0.00)[gmail.com]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-questions@freebsd.org]; TO_DN_NONE(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; RCVD_COUNT_THREE(0.00)[3]; IP_SCORE(-2.24)[ip: (-8.27), ipnet: 2607:f8b0::/32(-1.54), asn: 15169(-1.31), country: US(-0.09)]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DKIM_TRACE(0.00)[gmail.com:+]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; RCVD_IN_DNSWL_NONE(0.00)[a.2.d.0.0.0.0.0.0.0.0.0.0.0.0.0.0.2.0.0.4.6.8.4.0.b.8.f.7.0.6.2.list.dnswl.org : 127.0.5.0]; MX_GOOD(-0.01)[cached: alt3.gmail-smtp-in.l.google.com]; NEURAL_HAM_SHORT(-0.99)[-0.991,0]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_LAST(0.00)[]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; MID_RHS_MATCH_FROM(0.00)[] X-Rspamd-Server: mx1.freebsd.org X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Dec 2018 23:05:47 -0000 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"