nslookupLook up DNS names quickly
nslookup resolves a name to its addresses (or an IP to its name) and shows which DNS server answered. It's simpler than dig, exists on Linux, macOS and Windows, and is often the only DNS tool inside a minimal container image.
nslookup [-type=TYPE] NAME [SERVER]You want the IPs of a host and, from an IP in a log, the host name, with the least typing.
nslookupName server lookup. Without a name it starts an interactive prompt (>).
The Linux nslookup comes from BIND (the same package as dig) and, like dig, builds DNS queries itself rather than going through getaddrinfo, so /etc/hosts is not consulted. It reads /etc/resolv.conf for the default server and the search list, and applies the search domains to short names: with options ndots:5, as in Kubernetes pods, a name with fewer than five dots is first tried with each search suffix appended (orders becomes orders.shop.svc.cluster.local). For a plain lookup it sends an A and an AAAA query over UDP port 53 and prints the server it used, then the answers. 'Non-authoritative answer' simply means the reply came from a resolver's cache rather than from the zone's own name server. An IP address as argument becomes a PTR query for the in-addr.arpa name. Busybox images ship a smaller nslookup with slightly different output.
-type=TRecord type: a, aaaa, mx, ns, txt, soa, cname, ptr, srv, anyNAME SERVERSecond argument: ask that DNS server instead of the default-debugPrint every question, answer, TTL and section-timeout=NSeconds to wait for a reply-retry=NNumber of retries before giving up-port=NQuery a DNS server on a non-standard port(interactive) server XSwitch the server used for the following queries(interactive) set type=XChange the record type for the following queriesUsing nslookup to check an entry you added to /etc/hostsnslookup queries DNS servers directly and ignores /etc/hosts, so it disagrees with what applications see.
getent hosts myhostReading 'Non-authoritative answer' as an errorIt only means the answer came from a resolver's cache instead of the zone's own server. That's the normal case.
Look for NXDOMAIN, SERVFAIL or timeouts instead.Calling a service in another namespace by its short name from a podThe search list starts with the pod's own namespace, so 'payments' becomes payments.shop.svc.cluster.local and fails.
Use payments.billing (or the full payments.billing.svc.cluster.local).Try these on a Linux machine of your own. Each task has a hint and a solution.
Run nslookup on example.com in this offline sandbox and read the error. Is it NXDOMAIN or something else?
Show the DNS servers and search domains this machine is configured with.
Write the nslookup command that asks 10.0.0.2 for the NS records of devops-lab.io.
nslookupLook up DNS names quickly
nslookup resolves a name to its addresses (or an IP to its name) and shows which DNS server answered. It's simpler than dig, exists on Linux, macOS and Windows, and is often the only DNS tool inside a minimal container image.
nslookup [-type=TYPE] NAME [SERVER]You want the IPs of a host and, from an IP in a log, the host name, with the least typing.
nslookupName server lookup. Without a name it starts an interactive prompt (>).
The Linux nslookup comes from BIND (the same package as dig) and, like dig, builds DNS queries itself rather than going through getaddrinfo, so /etc/hosts is not consulted. It reads /etc/resolv.conf for the default server and the search list, and applies the search domains to short names: with options ndots:5, as in Kubernetes pods, a name with fewer than five dots is first tried with each search suffix appended (orders becomes orders.shop.svc.cluster.local). For a plain lookup it sends an A and an AAAA query over UDP port 53 and prints the server it used, then the answers. 'Non-authoritative answer' simply means the reply came from a resolver's cache rather than from the zone's own name server. An IP address as argument becomes a PTR query for the in-addr.arpa name. Busybox images ship a smaller nslookup with slightly different output.
-type=TRecord type: a, aaaa, mx, ns, txt, soa, cname, ptr, srv, anyNAME SERVERSecond argument: ask that DNS server instead of the default-debugPrint every question, answer, TTL and section-timeout=NSeconds to wait for a reply-retry=NNumber of retries before giving up-port=NQuery a DNS server on a non-standard port(interactive) server XSwitch the server used for the following queries(interactive) set type=XChange the record type for the following queriesUsing nslookup to check an entry you added to /etc/hostsnslookup queries DNS servers directly and ignores /etc/hosts, so it disagrees with what applications see.
getent hosts myhostReading 'Non-authoritative answer' as an errorIt only means the answer came from a resolver's cache instead of the zone's own server. That's the normal case.
Look for NXDOMAIN, SERVFAIL or timeouts instead.Calling a service in another namespace by its short name from a podThe search list starts with the pod's own namespace, so 'payments' becomes payments.shop.svc.cluster.local and fails.
Use payments.billing (or the full payments.billing.svc.cluster.local).Try these on a Linux machine of your own. Each task has a hint and a solution.
Run nslookup on example.com in this offline sandbox and read the error. Is it NXDOMAIN or something else?
Show the DNS servers and search domains this machine is configured with.
Write the nslookup command that asks 10.0.0.2 for the NS records of devops-lab.io.