title: DNSRR iteration
body: <p>If I send a DNSQR for www.google.com using sr1 I get several DNSRR(s) in reply, such as (done using <code>ans[DNSRR].show()</code>): </p>
  
  <pre><code>###[ DNS Resource Record ]###
     rrname= 'www.google.com.'
     type= A
     rclass= IN
     ttl= 294
     rdlen= 4
     rdata= '173.194.35.176'
  ###[ DNS Resource Record ]###
     rrname= 'www.google.com.'
     type= A
     rclass= IN
     ttl= 294
     rdlen= 4
     rdata= '173.194.35.178'
  ###[ DNS Resource Record ]###
     ....
  </code></pre>
  
  <p>Is there a neat way to iterate over those DNSRR(s)? As is I use regex and the following code:</p>
  
  <pre><code>def get_ip_addr(s):
      pattern = r'[0-9]+(?:\.[0-9]+){3}'
      match = re.search(pattern, s)
      if match:
          return match.group()
      return None    
  
  def resolve_host(host, nserver):
      print "resolving host: " + host + " (using nserver: " + nserver + ")"
      dns_pkt = IP(dst=nserver)/UDP()/DNS(rd=1, qd=DNSQR(qname=host))
      ans = sr1(dns_pkt)
      if ans:
          print "IP(s) for %s:" % (host)
          dnsrr_strings = repr(ans[DNSRR]).split("|")
          for dnsrr in dnsrr_strings :
              ip_addr = get_ip_addr(dnsrr)
              if ip_addr:
                  print " %s"  % ip_addr
      else:
          sys.stderr.write("unable to lookup " + host)
  </code></pre>