How to disable IPv6 for all interfaces?

I tried different methods I found on the internet to disable IPv6 completely, but without success. It seems that the tips on the internet are no longer valid for Ubuntu MATE 16.04.

I created the file /etc/sysctl.d/60-disable-ipv6.conf:
net.ipv6.conf.all.disable_ipv6 = 1 net.ipv6.conf.default.disable_ipv6 = 1 net.ipv6.conf.lo.disable_ipv6 = 1

But when I look up e.g. the ethernet interface with sysctl, then it is still set to 0 and only “all”, “lo” and “default” are set to 1. It seems like the “all” / “default” settings are not applied to the existing interfaces. I know I could add the respective interfaces to this file too, but I am looking for a general solution that disables IPv6 completely without having to specify each interface specifically.

Thus I also created the file /etc/modprobe.d/aliases (as it did not exist):
alias net-pf-10 off alias ipv6 off

as well as the file /etc/modprobe.d/blacklist-ipv6.conf:
blacklist ipv6 install ipv6 /bin/false

But neither of them had any effect, as I can still see e.g. an inet6 address for my ethernet interface. Any ideas which is the correct way to disable IPv6 on Ubuntu MATE 16.04?

Can you not do it within grub?

GRUB_CMDLINE_LINUX_DEFAULT=“ipv6.disable=1”

I’d say try it manually on next startup, see if it sticks before writing it into boot.

I guess the big question though, is: why would you want to?

Thanks. That works - seems that IPv6 is very tightly integrated, if that is the only way to completely disable it.

With regards to your question: My whole LAN is currently using static IPv4 addresses and comprises only a few computers. Thus there is no benefit from having IPv6 up and running - on the contrary, I can stick with the current firewall setup as I do not need to set up rules to tame IPv6. And I am a fan of the principle of minimizing the attack surface by disabling / uninstalling any piece of software / service that I do not need.

See also: