Re: How to use dig with an ip list
On Mon, 2008-08-18 at 22:52 -0500, Paul Schmehl wrote: --On August 18, 2008 10:13:54 PM -0500 Jeffrey Goldberg [EMAIL PROTECTED] wrote: On Aug 18, 2008, at 9:03 PM, 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? Easiest: $ for i in `cat ip-list`; do echo -n $i dig +short -x $i done Don't know why I didn't think of that. I ended up using this: for ip in `cat public_linux_ips`; do echo ${ip} `dig +short -x ${ip}`; done public_linux_ips_resolved Which gave me the output I wanted. Thanks for the pointer. Easiestest? # host www.freebsd.org www.freebsd.org has address 69.147.83.33 www.freebsd.org has IPv6 address 2001:4f8:fff6::21 www.freebsd.org mail is handled by 0 . # host ftp.freebsd.org ftp.freebsd.org has address 62.243.72.50 ftp.freebsd.org has address 204.152.184.73 ftp.freebsd.org has IPv6 address 2001:6c8:6:4::7 ftp.freebsd.org has IPv6 address 2001:4f8:0:2::e # cat freebsd.ips 69.147.83.33 62.243.72.50 204.152.184.73 # host 69.147.83.33 33.83.147.69.in-addr.arpa domain name pointer www.freebsd.org. # awk '{ip=$1; host ip | getline; print ip,$NF }' freebsd.ips 69.147.83.33 www.freebsd.org. 62.243.72.50 ftp.beastie.tdk.net. 204.152.184.73 freebsd.isc.org. s/host/dig/ to taste The middle command - host ip | getline; - executes the 'cmd' part on the left side of the pipe, getline parses the output, hence $NF now gives the last field in the output from host. Wayne (You don't know the power of the awk side!) ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: How to use dig with an ip list
On Aug 18, 2008, at 10:25 PM, Fraser Tweedale wrote: On Mon, Aug 18, 2008 at 10:18:07PM -0500, Jeffrey Goldberg wrote: You'll want to change line four to echo $LINE `dig +short -x $LINE` for a cleaner output. The original works fine for me in ash. Definitely nothing wrong with yours though. What have I overlooked? Sorry, I misread what you actually wrote for what I would have written (before correction). What you have is perfectly correct. Or, in the words of Emily Latela: Nevermind. Cheers, -j ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
How to use dig with an ip list
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 ([EMAIL PROTECTED]) Senior Information Security Analyst The University of Texas at Dallas http://www.utdallas.edu/ir/security/
Re: How to use dig with an ip list
--On August 19, 2008 12:44:05 PM +1000 Fraser Tweedale [EMAIL PROTECTED] wrote: 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 ([EMAIL PROTECTED]) 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) That's not a great deal of help. I, of course, had read and re-read the man pages before posting the question here, and I'm quite familiar with the normal use of dig and host, because I use them daily in my work. The two options that man (1) dig provides are; on the commandline and in a file. I can easily generate a list of hostnames having constructed an iplist in a file and then preceding each line with dig +short -x IP using vi. But that gives me a list of hostnames only. What I'm looking for is the combination of the two. host (1), of course, doesn't even have *those* options, so it's of no use for accomplishing what I'm attempting. Again, I want to start with a list of IPs and end up with a list of IPs *plus* their hostnames (on the same line). I'm quite sure someone here has the experience and/or knowledge to do this using shell commands. I suspect awk might be helpful but haven't yet investigated that angle. Paul Schmehl ([EMAIL PROTECTED]) Senior Information Security Analyst The University of Texas at Dallas http://www.utdallas.edu/ir/security/
Re: How to use dig with an ip list
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 ([EMAIL PROTECTED]) 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) frase pgp07Hd0weEn3.pgp Description: PGP signature
Re: How to use dig with an ip list
On Mon, Aug 18, 2008 at 10:05:18PM -0500, Paul Schmehl wrote: --On August 19, 2008 12:44:05 PM +1000 Fraser Tweedale [EMAIL PROTECTED] wrote: 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 ([EMAIL PROTECTED]) 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) That's not a great deal of help. I, of course, had read and re-read the man pages before posting the question here, and I'm quite familiar with the normal use of dig and host, because I use them daily in my work. The two options that man (1) dig provides are; on the commandline and in a file. I can easily generate a list of hostnames having constructed an iplist in a file and then preceding each line with dig +short -x IP using vi. But that gives me a list of hostnames only. What I'm looking for is the combination of the two. host (1), of course, doesn't even have *those* options, so it's of no use for accomplishing what I'm attempting. Again, I want to start with a list of IPs and end up with a list of IPs *plus* their hostnames (on the same line). I'm quite sure someone here has the experience and/or knowledge to do this using shell commands. I suspect awk might be helpful but haven't yet investigated that angle. Paul Schmehl ([EMAIL PROTECTED]) Senior Information Security Analyst The University of Texas at Dallas http://www.utdallas.edu/ir/security/ how about == #!/bin/sh while read LINE do echo $LINE `dig +short -x $LINE` done === whack that in a file, chmod +x it and cat in the IPs HTH frase pgpUcTGrjq53p.pgp Description: PGP signature
Re: How to use dig with an ip list
On Mon, Aug 18, 2008 at 10:18:07PM -0500, Jeffrey Goldberg wrote: On Aug 18, 2008, at 10:13 PM, Fraser Tweedale wrote: == #!/bin/sh while read LINE do echo $LINE `dig +short -x $LINE` done === You'll want to change line four to echo $LINE `dig +short -x $LINE` for a cleaner output. -j -- Jeffrey Goldberghttp://www.goldmark.org/jeff/ The original works fine for me in ash. Definitely nothing wrong with yours though. What have I overlooked? frase pgpiijgjRBw3E.pgp Description: PGP signature
Re: How to use dig with an ip list
On Aug 18, 2008, at 10:13 PM, Fraser Tweedale wrote: == #!/bin/sh while read LINE do echo $LINE `dig +short -x $LINE` done === You'll want to change line four to echo $LINE `dig +short -x $LINE` for a cleaner output. -j -- Jeffrey Goldberghttp://www.goldmark.org/jeff/ ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: How to use dig with an ip list
On Aug 18, 2008, at 9:03 PM, 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? Easiest: $ for i in `cat ip-list`; do echo -n $i dig +short -x $i done Better might be to use something in p5-net-DNS so that you don't make N separate calls to dig. Cheers, -j -- Jeffrey Goldberghttp://www.goldmark.org/jeff/ ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: How to use dig with an ip list
On Mon, 18 Aug 2008 21:03:36 -0500 Paul Schmehl [EMAIL PROTECTED] 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? You could pipe it through: while read ip;do echo ${ip} `dig +short -x ${ip}`;done ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: How to use dig with an ip list
--On August 18, 2008 10:13:54 PM -0500 Jeffrey Goldberg [EMAIL PROTECTED] wrote: On Aug 18, 2008, at 9:03 PM, 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? Easiest: $ for i in `cat ip-list`; do echo -n $i dig +short -x $i done Don't know why I didn't think of that. I ended up using this: for ip in `cat public_linux_ips`; do echo ${ip} `dig +short -x ${ip}`; done public_linux_ips_resolved Which gave me the output I wanted. Thanks for the pointer. Paul Schmehl ([EMAIL PROTECTED]) Senior Information Security Analyst The University of Texas at Dallas http://www.utdallas.edu/ir/security/