DNS in Ubuntu

To better navigate network administration, namely such concepts as types of IP addresses, masks, subnets, etc. I advise you to study the article

«Basics of computer networks»

Introduction

Setting up DNS is a crucial step when working with Ubuntu, and it can raise many questions for a beginner.

In this article you can find answers to some of them.

resolv.conf

cat /etc/resolv.conf

# This file is managed by man:systemd-resolved(8). Do not edit. # # This is a dynamic resolv.conf file for connecting local clients to the # internal DNS stub resolver of systemd-resolved. This file lists all # configured search domains. # # Run "systemd-resolve --status" to see details about the uplink DNS servers # currently in use. # # Third party programs must not access this file directly, but only through the # symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a different way, # replace this symlink by a static file or a different symlink. # # See man:systemd-resolved.service(8) for details about the supported modes of # operation for /etc/resolv.conf. nameserver 127.0.0.53 options edns0 search home

sudo apt install resolvconf

Reading package lists... Done Building dependency tree Reading state information... Done The following NEW packages will be installed: resolvconf 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded. Need to get 48.0 kB of archives. After this operation, 187 kB of additional disk space will be used. Get:1 http://fi.archive.ubuntu.com/ubuntu bionic-updates/universe amd64 resolvconf all 1.79ubuntu10.18.04.3 [48.0 kB] Fetched 48.0 kB in 1s (53.3 kB/s) Preconfiguring packages ... /tmp/resolvconf.config.Dpl2pL: 13: /tmp/resolvconf.config.Dpl2pL: ifquery: not found /tmp/resolvconf.config.Dpl2pL: 13: /tmp/resolvconf.config.Dpl2pL: ifquery: not found Selecting previously unselected package resolvconf. (Reading database ... 67344 files and directories currently installed.) Preparing to unpack .../resolvconf_1.79ubuntu10.18.04.3_all.deb ... Unpacking resolvconf (1.79ubuntu10.18.04.3) ... Setting up resolvconf (1.79ubuntu10.18.04.3) ... /var/lib/dpkg/info/resolvconf.config: 13: /var/lib/dpkg/info/resolvconf.config: ifquery: not found /var/lib/dpkg/info/resolvconf.config: 13: /var/lib/dpkg/info/resolvconf.config: ifquery: not found Created symlink /etc/systemd/system/sysinit.target.wants/resolvconf.service → / lib/systemd/system/resolvconf.service. Created symlink /etc/systemd/system/systemd-resolved.service.wants/resolvconf-p ull-resolved.path → /lib/systemd/system/resolvconf-pull-resolved.path. resolvconf-pull-resolved.service is a disabled or a static unit, not starting i t. resolvconf-pull-resolved.service is a disabled or a static unit, not starting i t. Processing triggers for systemd (237-3ubuntu10.51) ... Processing triggers for man-db (2.8.3-2ubuntu0.1) ... Processing triggers for ureadahead (0.100.0-21) ... Processing triggers for resolvconf (1.79ubuntu10.18.04.3) ...

sudo systemctl status resolvconf.service

● resolvconf.service - Nameserver information manager Loaded: loaded (/lib/systemd/system/resolvconf.service; enabled; vendor pres Active: inactive (dead) Docs: man:resolvconf(8)

sudo systemctl start resolvconf.service sudo systemctl enable resolvconf.service

Synchronizing state of resolvconf.service with SysV service script with /lib/systemd/systemd-sysv-install. Executing: /lib/systemd/systemd-sysv-install enable resolvconf

sudo systemctl status resolvconf.service

● resolvconf.service - Nameserver information manager Loaded: loaded (/lib/systemd/system/resolvconf.service; enabled; vendor pres Active: active (exited) since Mon 2021-09-13 18:45:15 UTC; 16s ago Docs: man:resolvconf(8) Main PID: 11851 (code=exited, status=0/SUCCESS) Tasks: 0 (limit: 4915) CGroup: /system.slice/resolvconf.service Sep 13 18:45:15 ubuntu-openstack systemd[1]: Starting Nameserver information ma Sep 13 18:45:15 ubuntu-openstack systemd[1]: Started Nameserver information man

sudo vi /etc/resolvconf/resolv.conf.d/head

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8) # DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN # 127.0.0.53 is the systemd-resolved stub resolver. # run "systemd-resolve --status" to see details about the actual nameservers. nameserver 192.168.56.149 nameserver 1.1.1.1 nameserver 1.0.0.1 nameserver 8.8.8.8 nameserver 8.8.4.4

192.168.56.149 is my local DNS server based on bind. You only need to specify it if you have fully repeated my lesson about DNS server in CentOS.

8.8.8.8; 8.8.4.4; are public Google DNS servers

1.1.1.1; 1.0.0.1; are public Cloudflare DNS servers

The order of listing does not matter - the one that responds faster will be used.

sudo systemctl restart resolvconf.service
cat /etc/resolv.conf

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8) # DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN # 127.0.0.53 is the systemd-resolved stub resolver. # run "systemd-resolve --status" to see details about the actual nameservers. nameserver 192.168.56.149 nameserver 1.1.1.1 nameserver 1.0.0.1 nameserver 8.8.8.8 nameserver 8.8.4.4 nameserver 127.0.0.53 search home options edns0

Article author: Andrei Olegovich