This question already has an answer here:

I'm trying to disable IPv6 on all of the adapters on an Ubuntu 17.10 machine. I used to be able to do so (prior Ubuntu versions) by editing /etc/sysctl.d/99-sysctl.conf to add disable parameters as follows:

echo "net.ipv6.conf.all.disable_ipv6 = 1" >> /etc/sysctl.d/99-sysctl.conf
echo "net.ipv6.conf.default.disable_ipv6 = 1" >> /etc/sysctl.d/99-sysctl.conf
echo "net.ipv6.conf.lo.disable_ipv6 = 1" >> /etc/sysctl.d/99-sysctl.conf

then reloading the parameters with:

sysctl -p

With Ubuntu 17.10, this works for the current session (i.e., ifconfig or ip address will show only IPv4 addresses), but IPv6 addresses come back after a reboot. (FWIW, I also have dhcp6: no set for each adapter in the netplan 01-netcfg.yaml file, so the IPv6 address associated with each adapter is a default one.)

How do I disable IPv6 permanently on an Ubuntu 17.10 (netplan) machine?


Since this was marked as an "exact duplicate" of https://askubuntu.com/a/337736/283721, I'll defend my question by noting that

  1. That answer, which I had seen, appears to be a last resort ("If your PC doesn't load /etc/sysctl.conf at boot time"). I think Ubuntu 17.10 does load /etc/sysctl.d/99-sysctl.conf at startup (though I'll do some research to confirm this if no one who knows responds to this), and

  2. There has to be a more elegant (or "correct") way to disable IPv6 within Ubuntu. I can think of lots of kludgy ways to disable IPv6 (cron script run at boot, this grub fix, etc.), but I'm worried about portability across, for example, kernel updates (will my grub edits persist across updates, or will I need to make the same edits each time?).

Since this problem appears to have started only with the move to netplan instead of /etc/network/interfaces, I'm hoping someone familiar with netplan network configuration will weigh in.

Sorry if I sound defensive, but I try very hard to do my homework first and not to post duplicate questions.

marked as duplicate by Charles Green, Fabby, David Foerster, Eric Carvalho, waltinator Dec 24 '17 at 1:34

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • This answer will probably do exactly what you want https://askubuntu.com/a/337736/283721 – Charles Green Dec 22 '17 at 19:33
  • 2
    "will my grub edits persist across updates, or will I need to make the same edits each time?)" yes, it will. Voting to leave closed. If there's a more elegant answer, it should be posted to the other question. – muru Dec 25 '17 at 4:55
  • Thanks. I can confirm that it solved my problem. And I guess editing /etc/default/grub isn't much messier than editing sysctl.conf files... – DScott Dec 26 '17 at 15:28