How to prevent NetworkManager from enabling IPv6?

I have a networking-related question.

On Fedora I’m trying to configure network settings so that:

  1. Nameservers are always 1.1.1.1 and 1.0.0.1
  2. IPv6 is always disabled.

To achieve #1, I added the following to /etc/NetworkManager/NetworkManager.conf:

[main]
dns=none

Then I create /etc/resolv.conf with the following contents:

nameserver 1.1.1.1
nameserver 1.0.0.1
options edns0

So far so good, everything is working as expected.

To achieve #2, I added the following to /etc/sysctl.conf:

net.ipv6.conf.all.disable_ipv6=1
net.ipv6.conf.default.disable_ipv6=1
net.ipv6.conf.lo.disable_ipv6=1
net.ipv6.conf.enp0s31f6.disable_ipv6=1
net.ipv6.conf.wlp0s20f3.disable_ipv6=1

Then I add the ipv6.method=disabled to /etc/NetworkManager/NetworkManager.conf so it looks like this:

[main]
dns=none

[ipv6]
method=disabled

Then check that IPv6 is disabled:

❯ ip addr | grep inet6

Which returns nothing as expected.

But now when I connect to a wifi network, IPv6 is being enabled automatically by NetworkManager:

❯ ip addr | grep inet6
    inet6 <redacted>/128 scope global dynamic noprefixroute
    inet6 <redacted>/64 scope global dynamic noprefixroute
    inet6 <redacted>/64 scope link noprefixroute

I want to prevent NetworkManager from enabling IPv6 so that IPv6 always remains disabled. Any suggestions?

Edit to add: I know it is possible to use the Gnome GUI to disable IPv6 on existing connections, but what I’m looking for is a way to disable IPv6 for all existing connections and future connections so that NetworkManager does not re-enable it for new connections.

I found a solution to my question which I’ll leave here in case it helps anyone in the future:

sudo grubby --update-kernel ALL --args ipv6.disable=1

Then I rebooted, and now IPv6 remains disabled even when connecting to new networks.

I’m not sure whether using the grubby command by itself in the first place would be sufficient without having to use the above methods I listed for editing NetworkManager.conf

Although it is a connection by connection solution, (and assuming you are using workstation with gnome DE) one very simple solution is to open the gnome settings panel and make those changes in the network configs there. Notice the same options are available for both wifi and wired networks.