Network Manager doesn't automaticly assign dns

Today I f up by trying to fix a problem with a single network and cause problem for my machine in every network.
I’ve deleted /etc/NetworkManager/NetworkManager.conf and ever since then I need to manually assign dns address for every single new network.
What should I do?

Edit: this my current NetworkManager.conf

# Configuration file for NetworkManager.
#
# See "man 5 NetworkManager.conf" for details.
#
# The directories /usr/lib/NetworkManager/conf.d/ and /run/NetworkManager/conf.d/
# can contain additional .conf snippets installed by packages. These files are
# read before NetworkManager.conf and have thus lowest priority.
# The directory /etc/NetworkManager/conf.d/ can contain additional .conf
# snippets. Those snippets are merged last and overwrite the settings from this main
# file.
#
# The files within one conf.d/ directory are read in asciibetical order.
#
# You can prevent loading a file /usr/lib/NetworkManager/conf.d/NAME.conf
# by having a file NAME.conf in either /run/NetworkManager/conf.d/ or /etc/NetworkManager/conf.d/.
# Likewise, snippets from /run can be prevented from loading by placing
# a file with the same name in /etc/NetworkManager/conf.d/.
#
# If two files define the same key, the one that is read afterwards will overwrite
# the previous one.

[main]
#plugins=keyfile,ifcfg-rh
dns=default

[logging]
# When debugging NetworkManager, enabling debug logging is of great help.
#
# Logfiles contain no passwords and little sensitive information. But please
# check before posting the file online. You can also personally hand over the
# logfile to a NM developer to treat it confidential. Meet us on #nm on Libera.Chat.
#
# You can also change the log-level at runtime via
#   $ nmcli general logging level TRACE domains ALL
# However, usually it's cleaner to enable debug logging
# in the configuration and restart NetworkManager so that
# debug logging is enabled from the start.
#
# You will find the logfiles in syslog, for example via
#   $ journalctl -u NetworkManager
#
# Please post full logfiles for bug reports without pre-filtering or truncation.
# Also, for debugging the entire `journalctl` output can be interesting. Don't
# limit unnecessarily with `journalctl -u`. Exceptions are if you are worried
# about private data. Check before posting logfiles!
#
# Note that debug logging of NetworkManager can be quite verbose. Some messages
# might be rate-limited by the logging daemon (see RateLimitIntervalSec, RateLimitBurst
# in man journald.conf). Please disable rate-limiting before collecting debug logs!
#
#level=TRACE
#domains=ALL

My system works flawlessly with the default file and does not need that line you have added.

Have you looked at the logs with the command suggested in that file?

# You will find the logfiles in syslog, for example via
#   $ journalctl -u NetworkManager

Using resolvectl status I noticed that resolvectl set the Gateway as the DNS. And because my router is not a DNS server it fails to return data.
Setting a new dns using nmcli connection modify works. But I want something that will work automaticly.

It all depends on the dhcp server in your network. If the dhcp server says that your gateway is also your DNS server, then that is what gets configured.

It’s only set it to this computer. Every other machine in the network works perfectly.

I’ve found a “workaround” that works.

  1. In /etc/systemd/resolved.conf I’ve uncommented and edited the next two line
DNS=8.8.8.8 2001:4860:4860::8888 # Google IPV4 and IPV6
FallbackDNS=8.8.4.4 2001:4860:4860::8844
  1. In /etc/NetworkManager I’ve added the next two line under [main]
dns=default
rc-manager=resolvconf
  1. Restart NetworkManager and systemd-resolved
sudo systemctl restart systemd-resolved
sudo systemctl restart NetworkManager

And from then on it works perfectly for me.
Yes it does set the DNS to the Google’s DNS but it’s better than nothing.

Glad that it works for you, but it is not normal for Fedora to run in the fallback modus. If all other devices work, I assume they get network parameters from DHCP, and so is Fedora able to do without any manual intervention. If your router is not a DNS server, it should at least provide DNS server addresses in the DHCP answer.

The two additions in the NetworkManager.conf file should be not necessary.

Key is that /etc/resolv.conf is not manually created, but a symlink to

/etc/resolv.conf -> /run/systemd/resolve/stub-resolv.conf

In this configuration, NetworkManager passes the DNS server automatically to systemd-resolved, and everything should work fine.

Of course, if your router is not standard and all devices have to be manually configured, then Fedora should be configured too, but then you can set your
IPV4 method to “Automatic Address only” and specify the DNS servers in the DNS entry box.

It is not usual to refer to Windows in the Linux world, but if you have an automatically configured Windows box on the net, the command prompt command “ipconfig /all” gives a nice overview of the network config obtained by DHCP.