Difference between revisions of "DNS"
Line 61: | Line 61: | ||
= flush dns = | = flush dns = | ||
<source lang=bash> | |||
sudo systemd-resolve --flush-caches # Flush Ubuntu DNS Cache | sudo systemd-resolve --flush-caches # Flush Ubuntu DNS Cache | ||
sudo systemd-resolve --statistics | sudo systemd-resolve --statistics | ||
sudo systemctl restart nscd # Other distros, eg arch Linux | sudo systemctl restart nscd # Other distros, eg arch Linux | ||
</source> | |||
= References = | = References = | ||
*[https://en.wikipedia.org/wiki/List_of_DNS_record_types List of DNS record types] Wikipedia | *[https://en.wikipedia.org/wiki/List_of_DNS_record_types List of DNS record types] Wikipedia |
Revision as of 19:49, 3 July 2020
This is a source of general information about Domain Name System aka DNS.
The DNS server stores different types of resource records used to resolve names, records like:
- A - Address record - returns a 32-bit IPv4 address, most commonly used to map hostnames to an IP address of the host
- NS - Name server record - an authoritative name server, delegates a DNS zone to use the given authoritative name servers
- CNAME - Canonical name record - the canonical name (or Fully Qualified Domain Name) for an alias; Alias of one name to another: the DNS lookup will continue by retrying the lookup with the new name. Used when multiple services have the single network address, but each service has its own entry in DNS
- MX - mail exchange record; maps a domain name to a list of mail exchange servers (MTA) for that domain
- SOA - Start of [a zone of] authority record - Specifies authoritative information about a DNS zone, including the primary name server, the email of the domain administrator, the domain serial number, and several timers relating to refreshing the zone.
- PTR - Pointer record - pointer to a canonical name. Unlike a CNAME, DNS processing stops and just the name is returned. The most common use is for implementing reverse DNS lookups
The ipconfig /displaydns
command displays all of the cached DNS entries on a Windows computer system.
/etc/hosts
dig
(domain information groper) and nslookup
(query Internet name servers interactively) are tools that query name servers. Unless a specific name server is specified as a commandline argument they will query the name server(s) found in /etc/resolv.conf
. They simply don't look at alternative sources of host information such as the /etc/hosts
file or other sources specified in /etc/nsswitch.conf
.
To force all dns queries through dnsmasq on your host, the /etc/resolv.conf
there should point to dnsmasq, i.e. it should look like:
#/etc/resolv.conf on sun nameserver 127.0.0.1
Hosts file is part of Name Service Switch. Configured at
$ cat /etc/nsswitch.conf # /etc/nsswitch.conf # # Example configuration of GNU Name Service Switch functionality. # If you have the `glibc-doc-reference' and `info' packages installed, try: # `info libc "Name Service Switch"' for information about this file. passwd: compat systemd group: compat systemd shadow: compat gshadow: files hosts: files mdns4_minimal [NOTFOUND=return] dns myhostname networks: files protocols: db files services: db files ethers: db files rpc: db files
Example entries in /etc/hosts
10.10.11.11 echo-1.service.k8s.acme.cloud # via app-service LoadBalancer 10.10.22.22 k8s.acme.cloud echo-1.ingress.k8s.acme.cloud # via ingress-service (k8s entry point)
can be verified using getent
utility, to get entries from Name Service Switch libraries
$ getent hosts 10.10.11.11 10.10.11.11 echo-1.service.k8s.acme.cloud $ getent hosts echo-1.ingress.k8s.acme.cloud 10.10.22.22 k8s.acme.cloud echo-1.ingress.k8s.acme.cloud
flush dns
sudo systemd-resolve --flush-caches # Flush Ubuntu DNS Cache sudo systemd-resolve --statistics sudo systemctl restart nscd # Other distros, eg arch Linux
References
- List of DNS record types Wikipedia