2

How does one disable IPv6 completely (for all interfaces, resp. for the whole machine?

Keep in mind, I don't want any kind of GUI solution.


OS in question:

  • Linux Mint 18.x Cinnamon 64-bit

  • GNU/Linux Debian 9.x Cinnamon 64-bit

6

One needs to edit the following file:

/etc/sysctl.conf

to add the following lines, preferably to the end of the file:

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

Once done, you may either reboot the machine, or type the following:

sudo sysctl --load=/etc/sysctl.conf

For other OSes it might be worth noting, if it does not read that file at boot time, there's an alternative approach.

One needs to edit the following file:

/etc/default/grub

to add the following appendix:

ipv6.disable=1

to the following variable:

GRUB_CMDLINE_LINUX_DEFAULT

so it might look like for instance in my case like this:

GRUB_CMDLINE_LINUX_DEFAULT="ipv6.disable=1 quiet splash"

Once edited, you need to call:

sudo update-grub

and reboot the machine.


But as pointed out by Rui F Ribeiro, you should do both methods, because:

  1. If you in the future upgrade allow update of your grub file, you have the safety in form of sysctl settings.

  2. With only the sysctl method, the ipv6 module is still loaded.

  • 1
    I prefer to do both methods, mainly because with only the sysctl method the ipv6 module is loaded. – Rui F Ribeiro Nov 3 '17 at 14:00
  • 2
    @RuiFRibeiro I edited the answer to contain our rationale on doing both methods. – LinuxSecurityFreak Nov 3 '17 at 14:09
  • 1
    Disabling the entire IPv6 while helping in some situations, also creates other problems that must be corrected, namely postfix, xinetd, and other couple of daemons are expecting nowadays to have IPv6 in the Debian default configuration and wont go up anymore until you fix the config. – Rui F Ribeiro Nov 3 '17 at 23:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.