DNS в Ubuntu
Введение | |
resolv.conf |
Чтобы лучше ориентироваться в сетевом администрировании, а именно в таких понятиях как типы IP адресов, маски, подсети и т.д. советую изучить статью
«Основы компьютерных сетей»
Введение
Настройка DNS важнейший шаг при работе с Ubuntu, который может вызвать
у новичка много вопросов.
В этой статье вы можете найти ответы на некоторые из них.
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 - это мой локальный DNS сервер на основе bind. Вам его указывать нужно только если вы полностью повторили мой урок про
DNS сервер в CentOS.
8.8.8.8; 8.8.4.4; - это публичные DNS сервера Google
1.1.1.1; 1.0.0.1; - это публичные DNS сервера Cloudflare
Порядок перечисления не имеет значения - будет использоваться тот, от которого быстрее отклик.
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