From owner-freebsd-questions@FreeBSD.ORG Tue Aug 19 03:13:54 2008 Return-Path: Delivered-To: questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 01BF61065678 for ; Tue, 19 Aug 2008 03:13:53 +0000 (UTC) (envelope-from Fraser@bacardi.frase.id.au) Received: from bacardi.frase.id.au (203-219-142-174.static.tpgi.com.au [203.219.142.174]) by mx1.freebsd.org (Postfix) with ESMTP id 6A2798FC08 for ; Tue, 19 Aug 2008 03:13:53 +0000 (UTC) (envelope-from Fraser@bacardi.frase.id.au) Received: from bacardi.frase.id.au (localhost [127.0.0.1]) by bacardi.frase.id.au (8.14.2/8.14.2) with ESMTP id m7J3DqWp036364; Tue, 19 Aug 2008 13:13:52 +1000 (EST) (envelope-from Fraser@bacardi.frase.id.au) Received: (from Fraser@localhost) by bacardi.frase.id.au (8.14.2/8.14.2/Submit) id m7J3DqbY036363; Tue, 19 Aug 2008 13:13:52 +1000 (EST) (envelope-from Fraser) Date: Tue, 19 Aug 2008 13:13:52 +1000 From: Fraser Tweedale To: Paul Schmehl Message-ID: <20080819031351.GD4326@bacardi.frase.id.au> References: <20080819024404.GB4326@bacardi.frase.id.au> <8B61752D0585DE4B43DE2005@Macintosh.local> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="1sNVjLsmu1MXqwQ/" Content-Disposition: inline In-Reply-To: <8B61752D0585DE4B43DE2005@Macintosh.local> User-Agent: Mutt/1.5.18 (2008-05-17) Cc: FreeBSD Questions Subject: Re: How to use dig with an ip list X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Aug 2008 03:13:54 -0000 --1sNVjLsmu1MXqwQ/ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Aug 18, 2008 at 10:05:18PM -0500, Paul Schmehl wrote: > --On August 19, 2008 12:44:05 PM +1000 Fraser Tweedale =20 > wrote: >=20 > > On Mon, Aug 18, 2008 at 09:03:36PM -0500, Paul Schmehl wrote: > >> I know I'm missing the obvious. I want to use an IP list to generate > >> an ip+hostname list. IOW, I want to go from this: > >> > >> x.x.x.x > >> y.y.y.y > >> > >> to this; > >> > >> x.x.x.x foo.domain.tld > >> y.y..y.y bar.domain.tld > >> > >> What's the best/easiest way to do this? > >> > >> Paul Schmehl (pauls@utdallas.edu) > >> Senior Information Security Analyst > >> The University of Texas at Dallas > >> http://www.utdallas.edu/ir/security/ > > > > dig(1) - see section `MULTIPLE QUERIES' > > note the -x flag to instruct dig to perform a reverse lookup > > > > see also host(1) > > >=20 > That's not a great deal of help. I, of course, had read and re-read the= =20 > man pages before posting the question here, and I'm quite familiar with= =20 > the "normal" use of dig and host, because I use them daily in my work. >=20 > The two options that man (1) dig provides are; on the commandline and in = a=20 > file. I can easily generate a list of hostnames having constructed an=20 > iplist in a file and then preceding each line with "dig +short -x IP"=20 > using vi. But that gives me a list of hostnames only. What I'm looking= =20 > for is the combination of the two. host (1), of course, doesn't even have= =20 > *those* options, so it's of no use for accomplishing what I'm attempting. >=20 > Again, I want to start with a list of IPs and end up with a list of IPs= =20 > *plus* their hostnames (on the same line). I'm quite sure someone here= =20 > has the experience and/or knowledge to do this using shell commands. I= =20 > suspect awk might be helpful but haven't yet investigated that angle. >=20 > Paul Schmehl (pauls@utdallas.edu) > Senior Information Security Analyst > The University of Texas at Dallas > http://www.utdallas.edu/ir/security/ how about =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D #!/bin/sh while read LINE do echo $LINE `dig +short -x $LINE` done =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D whack that in a file, chmod +x it and cat in the IPs HTH frase --1sNVjLsmu1MXqwQ/ Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (FreeBSD) iEYEARECAAYFAkiqOm8ACgkQPw/2FZbemTXQRgCgggk38M9eWT2X9gQ585ZJRAta AjoAmgMtcFb7JXBF3McRCGG9fG3z+q99 =/xaA -----END PGP SIGNATURE----- --1sNVjLsmu1MXqwQ/--