23

I upgraded a 16.04 Ubuntu server to 22.04. Migration to 18.04 and 20.04 worked well. However, the upgrade to 22.04 broke my DNS config.

I found a lot of tutorials to configure the whole network using netplan, but I don't feel very comfortable with them (I'm afraid that I will break everything). I have a lot of network interfaces on the server but nothing in /etc/netplan.

I wonder if I have to create a netplan file with all the network interfaces or just the broken one.

Here is the result of nmcli device show command:

GENERAL.DEVICE:                         docker0
GENERAL.TYPE:                           bridge
GENERAL.HWADDR:                         02:42:99:76:F4:CE
GENERAL.MTU:                            1500
GENERAL.STATE:                          10 (non-géré)
GENERAL.CONNECTION:                     --
GENERAL.CON-PATH:                       --
IP4.ADDRESS[1]:                         172.17.0.1/16
IP4.GATEWAY:                            --
IP4.ROUTE[1]:                           dst = 172.17.0.0/16, nh = 0.0.0.0, mt = 0
IP6.GATEWAY:                            --

GENERAL.DEVICE:                         docker_gwbridge
GENERAL.TYPE:                           bridge
GENERAL.HWADDR:                         02:42:FA:EB:F8:75
GENERAL.MTU:                            1500
GENERAL.STATE:                          10 (non-géré)
GENERAL.CONNECTION:                     --
GENERAL.CON-PATH:                       --
IP4.ADDRESS[1]:                         172.18.0.1/16
IP4.GATEWAY:                            --
IP4.ROUTE[1]:                           dst = 172.18.0.0/16, nh = 0.0.0.0, mt = 0
IP6.ADDRESS[1]:                         fe80::42:faff:feeb:f875/64
IP6.GATEWAY:                            --
IP6.ROUTE[1]:                           dst = fe80::/64, nh = ::, mt = 256

GENERAL.DEVICE:                         enp2s0f0
GENERAL.TYPE:                           ethernet
GENERAL.HWADDR:                         D8:D3:85:B9:34:20
GENERAL.MTU:                            1500
GENERAL.STATE:                          10 (non-géré)
GENERAL.CONNECTION:                     --
GENERAL.CON-PATH:                       --
WIRED-PROPERTIES.CARRIER:               marche
IP4.ADDRESS[1]:                         10.231.226.41/23
IP4.GATEWAY:                            10.231.227.254
IP4.ROUTE[1]:                           dst = 0.0.0.0/0, nh = 10.231.227.254, mt = 0
IP4.ROUTE[2]:                           dst = 10.231.226.0/23, nh = 0.0.0.0, mt = 0
IP6.ADDRESS[1]:                         fe80::dad3:85ff:feb9:3420/64
IP6.GATEWAY:                            --
IP6.ROUTE[1]:                           dst = fe80::/64, nh = ::, mt = 256

GENERAL.DEVICE:                         enp2s0f1
GENERAL.TYPE:                           ethernet
GENERAL.HWADDR:                         D8:D3:85:B9:34:22
GENERAL.MTU:                            1500
GENERAL.STATE:                          10 (non-géré)
GENERAL.CONNECTION:                     --
GENERAL.CON-PATH:                       --
WIRED-PROPERTIES.CARRIER:               arrêt
IP4.GATEWAY:                            --
IP6.GATEWAY:                            --

GENERAL.DEVICE:                         vethdcb1995
GENERAL.TYPE:                           ethernet
GENERAL.HWADDR:                         C2:05:F6:52:3F:61
GENERAL.MTU:                            1500
GENERAL.STATE:                          10 (non-géré)
GENERAL.CONNECTION:                     --
GENERAL.CON-PATH:                       --
WIRED-PROPERTIES.CARRIER:               marche
IP4.GATEWAY:                            --
IP6.ADDRESS[1]:                         fe80::c005:f6ff:fe52:3f61/64
IP6.GATEWAY:                            --
IP6.ROUTE[1]:                           dst = fe80::/64, nh = ::, mt = 256

GENERAL.DEVICE:                         lo
GENERAL.TYPE:                           loopback
GENERAL.HWADDR:                         00:00:00:00:00:00
GENERAL.MTU:                            65536
GENERAL.STATE:                          10 (non-géré)
GENERAL.CONNECTION:                     --
GENERAL.CON-PATH:                       --
IP4.ADDRESS[1]:                         127.0.0.1/8
IP4.GATEWAY:                            --
IP6.ADDRESS[1]:                         ::1/128
IP6.GATEWAY:                            --
IP6.ROUTE[1]:                           dst = ::1/128, nh = ::, mt = 256

The problem is that the enp2s0f0 device has no DNS defined.

My questions are:

  1. How to add my DNS records safely? Maybe there's a clean solution easier than netplan. Clean excludes hacking files generated by generated by resolvconf like /etc/resolvconf/resolv.conf.d/head.
  2. If I have to create all interfaces in the file, is there a way to create a netplan file from the current settings to reduce the risk of errors?

PS: I do not know if it is important, but systemd-resolve is not installed on the machine and /etc/resolv.conf.d contains the following reference to it:

# 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 127.0.0.53
search DOMAINS
2
  • 1
    Read man systemd-resolved systemd-dnsmasq dnsmasq and the man pages in their "See also" sections. dnsmasq is your local DNS server, and knows about /etc/hosts. Please see https://netplan.io and https://netplan.io/examples.
    – waltinator
    Commented May 5, 2022 at 15:51
  • @waltinator: Of course, before asking, I have read the documentation. The obvious conclusion is I'm not clever enough to set a DNS on that server ;-) Commented May 6, 2022 at 9:49

2 Answers 2

47

I finally found the solution here: https://serverok.in/systemd-resolved

In case the link die in the future: Create a file:

sudo mkdir /etc/systemd/resolved.conf.d/
sudo nano /etc/systemd/resolved.conf.d/dns_servers.conf

Add my dns in this file:

[Resolve]
DNS=8.8.8.8 1.1.1.1

Then restart systemd-resolved

sudo systemctl restart systemd-resolved

It works even after reboot :-)

PS : No idea why my DNS configuration was lost during the upgrade from 20.04 to 22.04.

1
2

I tried to apply the fix of Jean-Marc, but while it worked in the session, I actually lost the whole network configuration (including the IP) after the reboot. I had to create a YAML file with the whole configuration in /etc/netplan such as explained there : https://tecadmin.net/how-to-configure-static-ip-address-on-ubuntu-22-04/ Content of my 01-netcfg.yaml file:

network:
  ethernets:
    ensXX:
      addresses:
      - XXX.XXX.XXX.XX/XX
      routes:
      - to: default
        via: YOUR_GATEWAY
      nameservers:
        addresses:
        - YOUR_MAIN_DNS_IP
        - OTHER_DNS_IPS
        search:
        - MACHINE_DOMAIN_NAME

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .