From owner-freebsd-questions@FreeBSD.ORG Sat Aug 3 13:37:13 2013 Return-Path: Delivered-To: questions@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 5F685C58; Sat, 3 Aug 2013 13:37:13 +0000 (UTC) (envelope-from Devin.Teske@fisglobal.com) Received: from mx1.fisglobal.com (mx1.fisglobal.com [199.200.24.190]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 253AA22F7; Sat, 3 Aug 2013 13:37:12 +0000 (UTC) Received: from smtp.fisglobal.com ([10.132.206.31]) by ltcfislmsgpa03.fnfis.com (8.14.5/8.14.5) with ESMTP id r73DbB0D022435 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NOT); Sat, 3 Aug 2013 08:37:11 -0500 Received: from LTCFISWMSGMB21.FNFIS.com ([169.254.1.135]) by LTCFISWMSGHT03.FNFIS.com ([10.132.206.31]) with mapi id 14.02.0309.002; Sat, 3 Aug 2013 08:37:10 -0500 From: "Teske, Devin" To: Fbsd8 Subject: Re: .sh script code to determine IPv4 or IPv6 Thread-Topic: .sh script code to determine IPv4 or IPv6 Thread-Index: AQHOkDzj3H/8RokAXEKdt073gODRzpmD0HKA Date: Sat, 3 Aug 2013 13:37:09 +0000 Message-ID: <13CA24D6AB415D428143D44749F57D7202002127@ltcfiswmsgmb21> References: <51FCE9C7.7020407@a1poweruser.com> In-Reply-To: <51FCE9C7.7020407@a1poweruser.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.132.253.126] Content-Type: text/plain; charset="us-ascii" Content-ID: <295A7AB30A6A364DAED4A7AB71441AC1@fisglobal.com> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.10.8794, 1.0.431, 0.0.0000 definitions=2013-08-03_04:2013-08-02,2013-08-03,1970-01-01 signatures=0 Cc: Devin Teske , questions X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: Devin Teske List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 03 Aug 2013 13:37:13 -0000 On Aug 3, 2013, at 4:30 AM, Fbsd8 wrote: > I have a .sh script that I need to determine if the entered IP address > is IPv4 or IPv6. >=20 > Is there some .sh command that does this? >=20 In RELENG_9, soon to be released 9.2-R: =3D=3D=3D FILE: wis =3D=3D=3D #!/bin/sh DEVICE_SELF_SCAN_ALL=3D . /usr/share/bsdconfig/media/tcpip.subr if f_validate_ipaddr6 "$1"; then echo "Hey, nice IPv6 addr, great job!" elif f_validate_ipaddr "$1"; then echo "Hey, nice IPv4 addr; smiles" elif f_validate_hostname "$1"; then echo "Hey, nice hostname" else echo "What on Earth wast, _that_?!" exit 1 fi =3D=3D=3D END FILE =3D=3D=3D dteske@scribe9.vicor.com ~ $ ./wis ::1 Hey, nice IPv6 addr, great job! dteske@scribe9.vicor.com ~ $ ./wis 0::1 Hey, nice IPv6 addr, great job! dteske@scribe9.vicor.com ~ $ ./wis 0:::1 What on Earth wast, _that_?! dteske@scribe9.vicor.com ~ $ ./wis 1.2.3.4 Hey, nice IPv4 addr; smiles dteske@scribe9.vicor.com ~ $ ./wis 0.2.3.4 Hey, nice IPv4 addr; smiles dteske@scribe9.vicor.com ~ $ ./wis 256.2.3.4 Hey, nice hostname dteske@scribe9.vicor.com ~ $ ./wis foo.bar.com Hey, nice hostname dteske@scribe9.vicor.com ~ $ ./wis abc-123 Hey, nice hostname dteske@scribe9.vicor.com ~ $ ./wis abc_123 What on Earth wast, _that_?! --=20 Cheers, Devin _____________ The information contained in this message is proprietary and/or confidentia= l. If you are not the intended recipient, please: (i) delete the message an= d all copies; (ii) do not disclose, distribute or use the message in any ma= nner; and (iii) notify the sender immediately. In addition, please be aware= that any message addressed to our domain is subject to archiving and revie= w by persons other than the intended recipient. Thank you.