Re: Digging to the final IP

2014-10-21 Thread Warren Kumari
On Mon, Oct 20, 2014 at 1:19 PM, Mark Andrews  wrote:
>
> Why do we need to have a option to dig to massage the results into
> every possible different form?
>
> dig A $name | awk '$0 ~ /status/ && $0 !~ /status: NOERROR,/ {
> sub(",", "", $6 ); print $6; x=1
>}
>$4 == "A" { print $5; x=1 }
>END { if (!x) print "TIMEOUT" }'


Because, not everyone is as stunningly brilliant as you?

To a non-zero population of this list the above looks like line-noise...

W

>
> Mark
>
>
> In message <54451077.8030...@imperial.ac.uk>, Phil Mayers writes:
>> On 20/10/14 14:22, Frank Bulk (iname.com) wrote:
>> > We=92re using this in a bash shell script.  I don=92t think there=92s a n=
>> ative
>> > shell command to get the IP, so I=92ll use a mixture of host and dig as
>> > necessary.
>>
>> If your system has it, try "getent" e.g.
>>
>> getent ahosts hostname
>> ___
>> Please visit https://lists.isc.org/mailman/listinfo/bind-users to unsubscri=
>> be from this list
>>
>> bind-users mailing list
>> bind-users@lists.isc.org
>> https://lists.isc.org/mailman/listinfo/bind-users
> --
> Mark Andrews, ISC
> 1 Seymour St., Dundas Valley, NSW 2117, Australia
> PHONE: +61 2 9871 4742 INTERNET: ma...@isc.org
> ___
> Please visit https://lists.isc.org/mailman/listinfo/bind-users to unsubscribe 
> from this list
>
> bind-users mailing list
> bind-users@lists.isc.org
> https://lists.isc.org/mailman/listinfo/bind-users



-- 
I don't think the execution is relevant when it was obviously a bad
idea in the first place.
This is like putting rabid weasels in your pants, and later expressing
regret at having chosen those particular rabid weasels and that pair
of pants.
   ---maf
___
Please visit https://lists.isc.org/mailman/listinfo/bind-users to unsubscribe 
from this list

bind-users mailing list
bind-users@lists.isc.org
https://lists.isc.org/mailman/listinfo/bind-users


Re: Digging to the final IP

2014-10-21 Thread Evan Hunt
On Tue, Oct 21, 2014 at 12:07:15PM -0700, Warren Kumari wrote:
> > dig A $name | awk '$0 ~ /status/ && $0 !~ /status: NOERROR,/ {
> > sub(",", "", $6 ); print $6; x=1
> >}
> >$4 == "A" { print $5; x=1 }
> >END { if (!x) print "TIMEOUT" }'
> 
> 
> Because, not everyone is as stunningly brilliant as you?
> 
> To a non-zero population of this list the above looks like line-noise...

Could be worse, could be perl.  In any case, filtering the existing
output does seem better than adding every imaginable formatting option
to dig.

... I *could* maybe see adding a formatting option to produce an
easier-to-parse output header, though, such as:

; OPCODE=QUERY
; RCODE=NOERROR
; QRFLAG=1
; AAFLAG=0
; TCFLAG=0
; RDFLAG=1
; RAFLAG=1
; ADFLAG=0
; CDFLAG=0
[... etc ...]

-- 
Evan Hunt -- e...@isc.org
Internet Systems Consortium, Inc.
___
Please visit https://lists.isc.org/mailman/listinfo/bind-users to unsubscribe 
from this list

bind-users mailing list
bind-users@lists.isc.org
https://lists.isc.org/mailman/listinfo/bind-users


RE: Digging to the final IP

2014-10-21 Thread Darcy Kevin (FCA)
We have people on this list who are incapable of programming simple text 
extraction in *at*least*one*language*? Really?

No-one said a _scripting_ language had to be used. Feel free to use C (with 
"sharp" or "plusplus", if you wish), or Pascal, or Smalltalk, or LISP, or 
Fortran, or S/370 Assembler. Whatever floats your boat. Whatever doesn't look 
like "line-noise" to you, nor has a requirement of "stunning brilliance" to 
use. Feel free to format it in pretty ways (if the language allows you to do 
that) and/or comment it liberally.

(Personally, I'd probably use Perl with the Net::DNS module, but that's only 
because I've written about a million of those scripts and so wouldn't have to 
think too hard about it).


- Kevin

-Original Message-
From: bind-users-boun...@lists.isc.org 
[mailto:bind-users-boun...@lists.isc.org] On Behalf Of Warren Kumari
Sent: Tuesday, October 21, 2014 3:07 PM
To: Mark Andrews
Cc: bind-us...@isc.org
Subject: Re: Digging to the final IP

On Mon, Oct 20, 2014 at 1:19 PM, Mark Andrews  wrote:
>
> Why do we need to have a option to dig to massage the results into 
> every possible different form?
>
> dig A $name | awk '$0 ~ /status/ && $0 !~ /status: NOERROR,/ {
> sub(",", "", $6 ); print $6; x=1
>}
>$4 == "A" { print $5; x=1 }
>END { if (!x) print "TIMEOUT" }'


Because, not everyone is as stunningly brilliant as you?

To a non-zero population of this list the above looks like line-noise...

W

>
> Mark
>
>
> In message <54451077.8030...@imperial.ac.uk>, Phil Mayers writes:
>> On 20/10/14 14:22, Frank Bulk (iname.com) wrote:
>> > We=92re using this in a bash shell script.  I don=92t think 
>> > there=92s a n=
>> ative
>> > shell command to get the IP, so I=92ll use a mixture of host and 
>> > dig as necessary.
>>
>> If your system has it, try "getent" e.g.
>>
>> getent ahosts hostname
>> ___
>> Please visit https://lists.isc.org/mailman/listinfo/bind-users to 
>> unsubscri= be from this list
>>
>> bind-users mailing list
>> bind-users@lists.isc.org
>> https://lists.isc.org/mailman/listinfo/bind-users
> --
> Mark Andrews, ISC
> 1 Seymour St., Dundas Valley, NSW 2117, Australia
> PHONE: +61 2 9871 4742 INTERNET: ma...@isc.org
> ___
> Please visit https://lists.isc.org/mailman/listinfo/bind-users to 
> unsubscribe from this list
>
> bind-users mailing list
> bind-users@lists.isc.org
> https://lists.isc.org/mailman/listinfo/bind-users



--
I don't think the execution is relevant when it was obviously a bad idea in the 
first place.
This is like putting rabid weasels in your pants, and later expressing regret 
at having chosen those particular rabid weasels and that pair of pants.
   ---maf
___
Please visit https://lists.isc.org/mailman/listinfo/bind-users to unsubscribe 
from this list

bind-users mailing list
bind-users@lists.isc.org
https://lists.isc.org/mailman/listinfo/bind-users
___
Please visit https://lists.isc.org/mailman/listinfo/bind-users to unsubscribe 
from this list

bind-users mailing list
bind-users@lists.isc.org
https://lists.isc.org/mailman/listinfo/bind-users


Re: Digging to the final IP

2014-10-21 Thread Dave Knight

On Oct 19, 2014, at 1:26, Frank Bulk  wrote:

> Is there a dig option that will list out the final (IPs) or query result??
> By default, even with +short, it can list intermediate CNAME(s) and not what
> IP(s) that CNAME may have.  
> 
> For example, 
>   root@nagios:/tmp# dig mail.automatedwastesystems.net +short
>   mail3.sandhills.com.
>   root@nagios:/tmp#
> 
> I'd rather know that mail3.sandhills.com is NXDOMAIN.
> 
> Regards,
> 
> Frank


How about… 

$ dig +noall +answer mail.automatedwastesystems.net in a | egrep 'IN\tA\t' | 
cut -f6

which correctly returns nothing in this case, but when there’s a CNAME chain 
ending in addresses it returns them

$ dig +noall +answer dave.knig.ht in a | egrep 'IN\tA\t' | cut -f6
216.235.14.46

and surely you want IPv6 support…

$ dig +noall +answer dave.knig.ht in a dave.knig.ht in  | egrep 
'IN\t(A|)\t' | cut -f6
216.235.14.46
2001:4900:1:393::2

dave


signature.asc
Description: Message signed with OpenPGP using GPGMail
___
Please visit https://lists.isc.org/mailman/listinfo/bind-users to unsubscribe 
from this list

bind-users mailing list
bind-users@lists.isc.org
https://lists.isc.org/mailman/listinfo/bind-users

Re: Digging to the final IP

2014-10-21 Thread Novosielski, Ryan


 *Note: UMDNJ is now Rutgers-Biomedical and Health Sciences*
|| \\UTGERS  |-*O*-
||_// Biomedical | Ryan Novosielski - Senior Technologist
|| \\ and Health | novos...@rutgers.edu- 
973/972.0922 (2x0922)
||  \\  Sciences | OIRT/High Perf & Res Comp - MSB C630, Newark
`'

On Oct 21, 2014, at 16:00, Evan Hunt mailto:e...@isc.org>> wrote:

On Tue, Oct 21, 2014 at 12:07:15PM -0700, Warren Kumari wrote:
dig A $name | awk '$0 ~ /status/ && $0 !~ /status: NOERROR,/ {
   sub(",", "", $6 ); print $6; x=1
  }
  $4 == "A" { print $5; x=1 }
  END { if (!x) print "TIMEOUT" }'


Because, not everyone is as stunningly brilliant as you?

To a non-zero population of this list the above looks like line-noise...

Could be worse, could be perl.  In any case, filtering the existing
output does seem better than adding every imaginable formatting option
to dig.

... I *could* maybe see adding a formatting option to produce an
easier-to-parse output header, though, such as:

   ; OPCODE=QUERY
   ; RCODE=NOERROR
   ; QRFLAG=1
   ; AAFLAG=0
   ; TCFLAG=0
   ; RDFLAG=1
   ; RAFLAG=1
   ; ADFLAG=0
   ; CDFLAG=0
   [... etc ...]

While on some level, I'm with you, "IP only" doesn't seem like a corner case.
___
Please visit https://lists.isc.org/mailman/listinfo/bind-users to unsubscribe 
from this list

bind-users mailing list
bind-users@lists.isc.org
https://lists.isc.org/mailman/listinfo/bind-users

RE: Digging to the final IP

2014-10-21 Thread Frank Bulk
Dave,

Thanks for the input, but what I was looking for was a dig command that
returns the IP(s) or a fail.  It looks like the host command is the right
solution in this case, not dig.

Kind regards,

Frank

-Original Message-
From: Dave Knight [mailto:d...@knig.ht] 
Sent: Tuesday, October 21, 2014 8:21 PM
To: Frank Bulk
Cc: bind-users
Subject: Re: Digging to the final IP

On Oct 19, 2014, at 1:26, Frank Bulk  wrote:

> Is there a dig option that will list out the final (IPs) or query result??
> By default, even with +short, it can list intermediate CNAME(s) and not
what
> IP(s) that CNAME may have.  
> 
> For example, 
>   root@nagios:/tmp# dig mail.automatedwastesystems.net +short
>   mail3.sandhills.com.
>   root@nagios:/tmp#
> 
> I'd rather know that mail3.sandhills.com is NXDOMAIN.
> 
> Regards,
> 
> Frank


How about. 

$ dig +noall +answer mail.automatedwastesystems.net in a | egrep 'IN\tA\t' |
cut -f6

which correctly returns nothing in this case, but when there's a CNAME chain
ending in addresses it returns them

$ dig +noall +answer dave.knig.ht in a | egrep 'IN\tA\t' | cut -f6
216.235.14.46

and surely you want IPv6 support.

$ dig +noall +answer dave.knig.ht in a dave.knig.ht in  | egrep
'IN\t(A|)\t' | cut -f6
216.235.14.46
2001:4900:1:393::2

dave

___
Please visit https://lists.isc.org/mailman/listinfo/bind-users to unsubscribe 
from this list

bind-users mailing list
bind-users@lists.isc.org
https://lists.isc.org/mailman/listinfo/bind-users


Re: Digging to the final IP

2014-10-21 Thread LuKreme

> On 21 Oct 2014, at 19:20 , Dave Knight  wrote:
> 
> $ dig +noall +answer dave.knig.ht in a | egrep 'IN\tA\t' | cut -f6
> 216.235.14.46

Interesting. This works for me:

dig +noall +answer home.kreme.com in a | egrep '\tA' | cut -f5

but on your example, it requires -f6

And yet, the outputs appear to have the same number of fields.

 $ dig +noall +answer www.kreme.com in a 
www.kreme.com.  21139   IN  CNAME   cerebus.kreme.com.
cerebus.kreme.com.  21141   IN  A   23.24.150.141
 $ dig +noall +answer dave.knig.ht in a 
dave.knig.ht.   13916   IN  CNAME   sb.sanxion.org.
sb.sanxion.org. 222 IN  A   216.235.14.46

Very odd.

I use:

 $ dig +short $HOSTNAME | tail -1


-- 
"A synonym is a word you use when you can't spell the word you first
thought of." - Burt Bacharach

___
Please visit https://lists.isc.org/mailman/listinfo/bind-users to unsubscribe 
from this list

bind-users mailing list
bind-users@lists.isc.org
https://lists.isc.org/mailman/listinfo/bind-users


Re: Digging to the final IP

2014-10-21 Thread David Ford
# dig +noall +answer dave.knig.ht a|awk '/IN\tA\t/ {print $NF}'
216.235.14.46




signature.asc
Description: OpenPGP digital signature
___
Please visit https://lists.isc.org/mailman/listinfo/bind-users to unsubscribe 
from this list

bind-users mailing list
bind-users@lists.isc.org
https://lists.isc.org/mailman/listinfo/bind-users

Re: Digging to the final IP

2014-10-21 Thread Jim Young
On 10/22/14 12:08 AM, "LuKreme"  wrote:

>> On 21 Oct 2014, at 19:20 , Dave Knight  wrote:
>> 
>> $ dig +noall +answer dave.knig.ht in a | egrep 'IN\tA\t' | cut -f6
>> 216.235.14.46
>
>Interesting. This works for me:
>
>dig +noall +answer home.kreme.com in a | egrep '\tA' | cut -f5
>
>but on your example, it requires -f6
>
>And yet, the outputs appear to have the same number of fields.
>
> $ dig +noall +answer www.kreme.com in a
>www.kreme.com. 21139   IN  CNAME   cerebus.kreme.com.
>cerebus.kreme.com. 21141   IN  A   23.24.150.141
> $ dig +noall +answer dave.knig.ht in a
>dave.knig.ht.  13916   IN  CNAME   sb.sanxion.org.
>sb.sanxion.org.222 IN  A   216.235.14.46
>
>Very odd.

Subtle formatting difference for human consumption.  There are a variable
number of ASCII TABs inserted to visually align fields.

$ dig +noall +answer www.kreme.com in a | egrep '\tA' | cat -t
cerebus.kreme.com.^I21409^IIN^IA^I23.24.150.141

$ dig +noall +answer dave.knig.ht in a | egrep '\tA' | cat -t
sb.sanxion.org.^I^I299^IIN^IA^I216.235.14.46

There is only one ASCII TAB (represented as ^I with cat -t) between
"cerebus.kreme.com." and "21409." but two ASCII TABs between
"sb.sanxion.org." and "299".  I'm guessing a very short name might
result in three!

This is where output generated for human consumption can be tricky to
parse.

Best regards,

Jim Y.

___
Please visit https://lists.isc.org/mailman/listinfo/bind-users to unsubscribe 
from this list

bind-users mailing list
bind-users@lists.isc.org
https://lists.isc.org/mailman/listinfo/bind-users