zdns icon indicating copy to clipboard operation
zdns copied to clipboard

Fix all ns mode

Open vishalmohanty opened this issue 2 years ago • 4 comments

This diff does the following.

  • Updates the all-nameservers mode to lookup only via IPv4 nameserver addresses.
  • Adds a TODO to add lookup via IPv6 NS once that is figured out.

Test:

» echo "google.com" | ./zdns A --retries=10 --all-nameservers  | python -m json.tool
{
    "data": {
        "results": [
            {
                "nameserver": "ns4.google.com",
                "result": {
                    "answers": [
                        {
                            "answer": "142.251.32.46",
                            "class": "IN",
                            "name": "google.com",
                            "ttl": 300,
                            "type": "A"
                        }
                    ],
                    "protocol": "udp",
                    "resolver": "216.239.38.10:53"
                },
                "status": "NOERROR"
            },
            {
                "nameserver": "ns3.google.com",
                "result": {
                    "answers": [
                        {
                            "answer": "142.251.32.46",
                            "class": "IN",
                            "name": "google.com",
                            "ttl": 300,
                            "type": "A"
                        }
                    ],
                    "protocol": "udp",
                    "resolver": "216.239.36.10:53"
                },
                "status": "NOERROR"
            },
            {
                "nameserver": "ns1.google.com",
                "result": {
                    "answers": [
                        {
                            "answer": "142.251.32.46",
                            "class": "IN",
                            "name": "google.com",
                            "ttl": 300,
                            "type": "A"
                        }
                    ],
                    "protocol": "udp",
                    "resolver": "216.239.32.10:53"
                },
                "status": "NOERROR"
            },
            {
                "nameserver": "ns2.google.com",
                "result": {
                    "answers": [
                        {
                            "answer": "142.251.32.46",
                            "class": "IN",
                            "name": "google.com",
                            "ttl": 300,
                            "type": "A"
                        }
                    ],
                    "protocol": "udp",
                    "resolver": "216.239.34.10:53"
                },
                "status": "NOERROR"
            }
        ]
    },
    "name": "google.com",
    "status": "NOERROR",
    "timestamp": "2022-04-28T11:38:48-07:00"
}

vishalmohanty avatar Apr 28 '22 18:04 vishalmohanty

do you know why when running your example, but with the iterative flag, some results still are missing the protocol/resolver?

echo "google.com" | sudo ./zdns A --retries=10 --all-nameservers --iterative | jq

{
  "data": {
    "results": [
      {
        "nameserver": "ns2.google.com",
        "result": {
          "answers": [
            {
              "answer": "142.251.46.238",
              "class": "IN",
              "name": "google.com",
              "ttl": 300,
              "type": "A"
            }
          ],
          "protocol": "udp",
          "resolver": "216.239.36.10:53"
        },
        "status": "NOERROR"
      },
      {
        "nameserver": "ns1.google.com",
        "result": {
          "answers": [
            {
              "answer": "142.251.46.238",
              "class": "IN",
              "name": "google.com",
              "ttl": 300,
              "type": "A"
            }
          ],
          "protocol": "",
          "resolver": ""
        },
        "status": "NOERROR"
      },
      {
        "nameserver": "ns3.google.com",
        "result": {
          "answers": [
            {
              "answer": "142.251.46.238",
              "class": "IN",
              "name": "google.com",
              "ttl": 300,
              "type": "A"
            }
          ],
          "protocol": "",
          "resolver": ""
        },
        "status": "NOERROR"
      },
      {
        "nameserver": "ns4.google.com",
        "result": {
          "answers": [
            {
              "answer": "142.251.46.238",
              "class": "IN",
              "name": "google.com",
              "ttl": 300,
              "type": "A"
            }
          ],
          "protocol": "",
          "resolver": ""
        },
        "status": "NOERROR"
      }
    ]
  },
  "name": "google.com",
  "status": "NOERROR",
  "timestamp": "2022-04-28T19:33:24Z"
}

LizIzhikevich avatar Apr 28 '22 19:04 LizIzhikevich

@LizIzhikevich that is because in the --iterative mode, the response is getting cached and hence the requests after the first all get back the cached response (with missing resolver). I need some help in running the --iterative mode without using the cache. --cache-size=0 still returns cached response.

vishalmohanty avatar Apr 28 '22 19:04 vishalmohanty

ok. im happy to approve this PR on my end---since it does solve the root problem--- but sounds like you might need to open a new issue that addresses cache=0 not working haha.

LizIzhikevich avatar Apr 28 '22 19:04 LizIzhikevich

I want to take a pass on this before we merge. I'm not sure this is the right place for the code.

zakird avatar Apr 28 '22 20:04 zakird