BIND 9.16.0 has just been released, and it’s full of lovely new features including one for devopsy types:

$ dig +dnssec +yaml jpmens.net SOA
-
  type: MESSAGE
  message:
    type: RECURSIVE_RESPONSE
    query_time: !!timestamp 2020-02-20T17:06:06.091Z
    response_time: !!timestamp 2020-02-20T17:06:06.091Z
    message_size: 257b
    socket_family: INET
    socket_protocol: UDP
    response_address: 127.0.0.1
    response_port: 53
    query_address: 0.0.0.0
    query_port: 61944
    response_message_data:
      opcode: QUERY
      status: NOERROR
      id: 61207
      flags: qr rd ra ad
      QUESTION: 1
      ANSWER: 2
      AUTHORITY: 0
      ADDITIONAL: 1
      OPT_PSEUDOSECTION:
        EDNS:
          version: 0
          flags: do
          udp: 4096
      QUESTION_SECTION:
        - jpmens.net. IN SOA
      ANSWER_SECTION:
        - jpmens.net. 3445 IN SOA u.six53.net. noc.six53.net. 7562 86400 7200 3600000 3600
        - jpmens.net. 3445 IN RRSIG SOA 8 2 3600 20200305000000 20200220000000 17145 jpmens.net. Fvi1sUEvEBQjrp1KzioO5kdn7PUM+WlHuVxQDBolyPRRiGCPXdHTBtDz 6CV+l0lXmyK10IHo5OukBXyNu0QBLSCB+bIHP4GJ+yslWFuWzvzxHigM LLiRvbCPUMjGIjMKweJa/o6W3o1Vc2EzZoKdbibZy5gAqqfwkrkVtuGu u7s=

There we go! dig, mdig, and delv can now all take a +yaml option to print output in a detailed YAML format.

And we can quickly produce JSON by piping the output to something like this:

python -c 'import yaml,json,sys; print(json.dumps(yaml.safe_load(sys.stdin.read()), indent=4, default=str))'
bind, dig, and yaml :: 20 Feb 2020 :: e-mail