Difference between revisions of "DNS"

From Ever changing code
Jump to navigation Jump to search
Line 48: Line 48:
Example entries in <code>/etc/hosts</code>
Example entries in <code>/etc/hosts</code>
<source lang=bash>
<source lang=bash>
10.108.250.187                 echo-1.service.k8s.acme.cloud # via app-service LoadBalancer
10.10.11.11                 echo-1.service.k8s.acme.cloud # via app-service LoadBalancer
10.98.212.164  k8s.acme.cloud echo-1.ingress.k8s.acme.cloud # via ingress-service (k8s entry point)
10.10.22.22  k8s.acme.cloud echo-1.ingress.k8s.acme.cloud # via ingress-service (k8s entry point)
</source>
</source>


can be verified using <code>getent</code> utility, to get entries from Name Service Switch libraries
can be verified using <code>getent</code> utility, to get entries from Name Service Switch libraries
<source lang=bash>
<source lang=bash>
$ getent hosts 10.108.250.187
$ getent hosts 10.10.11.11
10.108.250.187  echo-1.service.k8s.acme.cloud
10.10.11.11 echo-1.service.k8s.acme.cloud
$ getent hosts echo-1.ingress.k8s.acme.cloud
$ getent hosts echo-1.ingress.k8s.acme.cloud
10.98.212.164  k8s.acme.cloud echo-1.ingress.k8s.acme.cloud
10.10.22.22 k8s.acme.cloud echo-1.ingress.k8s.acme.cloud
</source>
</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 14:46, 11 June 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

References