Question

Disable "/etc/systemd/resolved.conf.d/DigitalOcean.conf"

On every boot/reboot of an Ubuntu Linux (21.10 at the moment) droplet, DigitalOcean restores this file:

/etc/systemd/resolved.conf.d/DigitalOcean.conf

I can comment-out the lines inside and they will be uncommented on reboot. I can delete the file and it will re-appear on reboot. The file causes problems (https://github.com/systemd/systemd/issues/20119) and there must be some way to disable it.

Aside from writing my own script that auto-deletes the file on boot, how can I disable that file from every appearing in the first place?


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hello there,

Have you tried to make the file immutable using chattr?

chattr [operator] [flags] [filename]

  1. chattr +i /path/to/file

A file is set with ‘i‘ attribute, cannot be modified (immutable). Means no renaming, no symbolic link creation, no execution, no writable

To remove the attribute:

  1. chattr -i /path/to/file

To check the attributes of a file:

  1. lsattr /path/to/file

Hope that this helps!

I was referred to the resolved documentation. I used the suggestion to replace the file with a symbolic link to /dev/null. That worked for me.

If you wish to override the values in the DigitalOcean.conf file that is written, you can do so by creating a file that is sorted alphabetically after DigitalOcean.conf (i.e. myresolved.conf as m comes after d so that file’s values are used rather than the values within DigitalOcean.conf)

========================

In addition to the “main” configuration file, drop-in configuration snippets are read from /usr/lib/systemd/.conf.d/, /usr/local/lib/systemd/.conf.d/, and /etc/systemd/*.conf.d/. Those drop-ins have higher precedence and override the main configuration file. Files in the *.conf.d/ configuration subdirectories are sorted by their filename in lexicographic order, regardless of in which of the subdirectories they reside. When multiple files specify the same option, for options which accept just a single value, the entry in the file sorted last takes precedence, and for options which accept a list of values, entries are collected as they occur in the sorted files.

Alternatively, To disable a configuration file supplied by the vendor, the recommended way is to place a symlink to /dev/null in the configuration directory in /etc/, with the same filename as the vendor configuration file.

The above is taken from the following article: https://www.freedesktop.org/software/systemd/man/resolved.conf.html