137

I am using Ubuntu 14.04. And I have done the following to disable ipv6.

I have open /etc/sysctl.conf using gedit and paste the following lines at the end of sysctl.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 check it using following command,

$ cat /proc/sys/net/ipv6/conf/all/disable_ipv6

I am getting result as '0'( i.e still Enabled). Please help me to disable ipv6, so that I can use hadoop.

I followed instructions from this link.

Stefano Palazzo
  • 85,787
  • 45
  • 210
  • 227
A J
  • 11,277
  • 16
  • 43
  • 59

3 Answers3

229

To disable ipv6, you have to open /etc/sysctl.conf using any text editor and insert the following lines at the end:

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

If ipv6 is still not disabled, then the problem is that sysctl.conf is still not activated.

To solve this, open a terminal(Ctrl+Alt+T) and type the command,

sudo sysctl -p

You will see this in the terminal:

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

After that, if you run:

$ cat /proc/sys/net/ipv6/conf/all/disable_ipv6

It will report:

1

If you see 1, ipv6 has been successfully disabled.

Ross Rogers
  • 145
  • 7
A J
  • 11,277
  • 16
  • 43
  • 59
  • 1
    will value 1 hold after reboot? –  Oct 03 '14 at 01:32
  • 1
    @Georjia yes... after this ipv6 will disable permanently.... untill you enable it... – A J Oct 06 '14 at 03:53
  • 7
    even with `cat /proc/sys/net/ipv6/conf/all/disable_ipv6` reporting disabled (1), ubuntu x64 14.04 still manages to somehow autoconfig an a v6 ip on the main interface (ipv6 is set to auto in the network manager by default) – stackblow Jun 30 '15 at 16:12
  • 1
    if ipv6 is disabled in kernel this dont work beacuse cant find /proc/sys/net/ipv6/ . There must be another way too. – obayhan Sep 17 '15 at 13:58
  • I did get the same issue too. For a while the ipv6 was disabled, but I started getting boot messages about it again. – r1k0 Oct 08 '15 at 20:05
  • 1
    I tried this (getting the `1`), and the advice from Mostafa below - yet `ipv6` still appears in my `dmesg` and slows down my boot - what can I do? `[ 19.434645] IPv6: ADDRCONF(NETDEV_UP): eno1: link is not ready` – FooBar Apr 15 '17 at 11:21
  • if ipv6 is still respawning Mostafa Ahangarha Answer is worth trying - I am using that an many machines to completely disable ipv6 system wide without any problems so far – Mr.Gosh Sep 14 '17 at 09:43
  • 1
    I tend to avoid directly editing the config file if there is a `someapp.conf.d` directory available. On my system there is `/etc/sysctl.d/` with many config files for various settings. I created a new one called `30-noipv6.conf` and put the settings from above in and then loaded it with `sudo sysctl -p /etc/sysctl.d/30-noipv6.conf`. – dragon788 Apr 19 '18 at 22:03
18

You might want to disable it right from the boot. For this purpose, open /etc/default/grub with your favorite text editor with root access (maybe sudo vi /etc/default/grub.

In this file, find this line:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"

and change it to:

GRUB_CMDLINE_LINUX_DEFAULT="ipv6.disable=1 quiet splash"

Save the file and update grub by running:

sudo update-grub

=============================
Mint 19 and Ubuntu 18.04:

on Mint 19 it would be "xed admin:///etc/default/grub" and maybe on Ubuntu 18.04 "gedit admin:///etc/default/grub" to get a GUI editor for doing the edits to the file. The rest of the steps will be the same.

Mostafa Ahangarha
  • 4,358
  • 7
  • 35
  • 51
  • 1
    Why and when do we want to disable using GRUB instead of setting the sysctl? – txs Sep 08 '20 at 16:46
  • There has been cases in which I failed to disable ipv6 using sysctl. I think last time it happened few month ago while I was configuring my Raspberry Pi. – Mostafa Ahangarha Sep 09 '20 at 05:17
-2

In addition to Ross Rogers answer above you should add:

sudo nano /etc/init/scip.conf

# description "Start sysctl at boot"

description "sysctl"

start on runlevel [2345]
stop on runlevel [016]

console log

respawn
respawn limit unlimited

exec /sbin/sysctl -p
scopa
  • 207
  • 1
  • 4
  • 7
  • 2
    Why? What does it do? – GuiGS Sep 01 '16 at 18:01
  • It looks like it runs sysctl -p when booting to runlevel 2,3,4, and 5. However there's this question http://askubuntu.com/questions/654291/i-cant-get-any-information-or-help-about-an-init-process-called-scip-which-ha that implies this scip.conf thing doesn't really work. – Jistanidiot Nov 01 '16 at 11:51
  • sysctl runs on its own at boot, so this is wrong.. – Alex R Feb 02 '17 at 14:29