Differences between revisions 1 and 11 (spanning 10 versions)
Revision 1 as of 2020-11-09 23:27:03
Size: 641
Comment:
Revision 11 as of 2023-04-04 15:36:57
Size: 2605
Comment:
Deletions are marked like this. Additions are marked like this.
Line 2: Line 2:

'''Domain Name Resolution''' ('''DNS''') on Linux is done in a very similar way to [[BSD/DNS|DNS on BSD]]. It is worth reiterating that [[Bind|DNS was invented for BSD]].
Line 9: Line 11:
== resolv.conf ==

Linux uses the configuration file `/etc/resolv.conf` to lookup names. The file is read sequentially (note: up to 3 nameservers) for each lookup. As such, changes are effective immediately.

A number of tools exist for debugging DNS on Linux:
 * `drill`
 * `dig` (from the `bind` project, sometimes bundled with `dnsutils`)
== Name resolution ==
Line 19: Line 15:
=== Programs that will overwrite resolv.conf === === Name Service Switch ===
Line 21: Line 17:
`dchpcd` will try to call `resolvconf`, or else overwrite `/etc/resolv.conf`. This latter behavior can be disabled by editing `/etc/dhcpcd.conf`: The '''Name Service Switch''' ('''NSS''') file (`/etc/nsswitch.conf`) defines the order of operations for various services, among them being name resolution.

A minimal configuration looks like...
Line 24: Line 22:
nohook resolv.conf hosts: files dns
Line 26: Line 24:

This configuration will require a fully configured hosts file, as seen below.

Consider instead this configuration, which makes use of libraries and services from the `systemd` project. This will enable some omissions from the hosts file.

{{{
hosts: files mymachines myhostname dns
}}}

See [[Linux/nsswitch.conf|here]] for more details on configuring `/etc/nsswitch`.



=== Hosts ===

The '''hosts''' file (`/etc/hosts`) is a list of addresses and names, especially for local hosts and machines. A basic hosts file looks like:

{{{
127.0.0.1 localhost
}}}

See [[Linux/hosts|here]] for more details on configuring `/etc/hosts`.



=== Resolver ===

The '''resolver''' configuration file (`/etc/resolv.conf`) is a list of nameservers to query for name resolution. The file is read sequentially for up to 3 nameservers for each lookup. As such, changes are effective immediately.

If the resolver file is being configured directly, then it should look like:

{{{
nameserver 8.8.8.8
}}}

See [[Linux/resolv.conf|here]] for more details on configuring `/etc/resolv.conf`.

Services that manipulate the resolver file include:

 * [[Linux/SystemdResolved|systemd-resolved]] and it's userland utility `resolvectl(1)`
 * [[Linux/SystemdResolved#ResolveConf|systemd-resolveconf]]
 * [[OpenResolv|openresolve]]
 * [[Dhcpcd|dhcpcd]]
 * [[NetworkManager]]



=== Utilities ===

 * `drill(1)`, used as `drill NAME @SERVER TYPE`
 * `dig(1)` (see [[Bind]]) used as `dig @SERVER NAME TYPE`

----



== Multicast name resolution ==

'''Multicast domain name resolution''' ('''mDNS''') is an expansion of the DNS protocol. An mDNS broadcaster makes use of port 5353 and resolves names in the `.local` domain.

Note that there is also partial/coincidental support for '''link-local multicast name resolution''' ('''LLMNR''') in many of the Linux implementations of mDNS. LLMNR is a similar but deliberately incompatible protocol (using port 5355) and also with a limited scope for features.



----
CategoryRicottone CategoryRicottone

DNS on Linux

Domain Name Resolution (DNS) on Linux is done in a very similar way to DNS on BSD. It is worth reiterating that DNS was invented for BSD.


Name resolution

Name Service Switch

The Name Service Switch (NSS) file (/etc/nsswitch.conf) defines the order of operations for various services, among them being name resolution.

A minimal configuration looks like...

hosts: files dns

This configuration will require a fully configured hosts file, as seen below.

Consider instead this configuration, which makes use of libraries and services from the systemd project. This will enable some omissions from the hosts file.

hosts: files mymachines myhostname dns

See here for more details on configuring /etc/nsswitch.

Hosts

The hosts file (/etc/hosts) is a list of addresses and names, especially for local hosts and machines. A basic hosts file looks like:

127.0.0.1 localhost

See here for more details on configuring /etc/hosts.

Resolver

The resolver configuration file (/etc/resolv.conf) is a list of nameservers to query for name resolution. The file is read sequentially for up to 3 nameservers for each lookup. As such, changes are effective immediately.

If the resolver file is being configured directly, then it should look like:

nameserver 8.8.8.8

See here for more details on configuring /etc/resolv.conf.

Services that manipulate the resolver file include:

Utilities

  • drill(1), used as drill NAME @SERVER TYPE

  • dig(1) (see Bind) used as dig @SERVER NAME TYPE


Multicast name resolution

Multicast domain name resolution (mDNS) is an expansion of the DNS protocol. An mDNS broadcaster makes use of port 5353 and resolves names in the .local domain.

Note that there is also partial/coincidental support for link-local multicast name resolution (LLMNR) in many of the Linux implementations of mDNS. LLMNR is a similar but deliberately incompatible protocol (using port 5355) and also with a limited scope for features.


CategoryRicottone CategoryRicottone

Linux/DNS (last edited 2023-06-22 20:45:42 by DominicRicottone)