Linux: How To Disable The IPv6 Protocol

by Vivek Gite on September 12, 2006 · 11 comments

Sometime you just need to disable IPv6 protocol. In some case, you do not need it at all or it may increase browsing speed and security.

Linux has Internet Protocol Version 6 (IPv6) enabled by default, almost all distros enable it.

RHEL v4 / CentOS v4

Open your modprob.conf file (Red Hat / CentOS / Fedora and friend) and add following line:
# vi /etc/modprobe.conf

Add following line:
alias net-pf-10 off
Save and close the file. Reboot the system.
See RedHat / Centos v5.x Disable IPv6 Networking for more info.

Debian / Ubuntu Linux

If you are using Debian/Ubuntu linux (thanks to beranger), open file /etc/modprobe.d/aliases
# vi /etc/modprobe.d/aliases
Find the line:
alias net-pf-10 ipv6

Replace with:
alias net-pf-10 off
alias ipv6 off

Save and close the file. Finally, reboot the system. IPv6 support should now be disabled and it did improve my DNS performance. Also you can install DNS proxy - to improve DNS performance and squid caching server.

See Also:

Featured Articles:

Share this with other sys admins!
Facebook it - Tweet it - Print it -

We're here to help you make the most of sysadmin work. So, subscribe!

{ 11 comments… read them below or add one }

1 Teodor July 22, 2009

In Debian you should just blacklist the module like this:

HOSTu:~# vi /etc/modprobe.d/blacklist
[..]
## disable IPv6 module (to avoid DNS query delays)
blacklist ipv6

Sometimes this works on RHEL5 too, but not always (XEN virtualization).

Cheers

Reply

2 Axel August 4, 2009

in Debian Sid it’s /etc/modprobe.d/blacklist.conf
Regards, Axel

Reply

3 Pete August 11, 2009

In Fedora, you can edit /etc/sysconfig/network and add the following:
NETWORKING_IPV6=no
IPV6INIT=no

Pete.

Reply

4 Sean November 28, 2009

DISABLE IPV6 IN UBUNTU 9.10
gksu gedit /etc/default/grub

CHANGE THIS LINE:
GRUB_CMDLINE_LINUX_DEFAULT=”quiet splash”

TO
GRUB_CMDLINE_LINUX_DEFAULT=”ipv6.disable=1 quiet splash”

THEN UPDATE GRUB:
sudo update-grub

TO TEST WITH TERMINAL:
ip a | grep inet6

Reply

5 Harri January 20, 2010

Even modifying /etc/modprobe.d/aliases.conf or blacklisting ipv6 might not be sufficient. Some packages load other kernel modules that depend upon ipv6, and then it is back.

There is only one reliable way: Build a kernel without ipv6 support.

Reply

6 Peter July 25, 2010

@Harri
This is correct. I had this problem on Ubuntu I disabled ipv6 on system, however some commandline utilities were still using ipv6.

Reply

7 the dsc January 30, 2010

You do not need to reboot the system, “sudo /etc/init.d/networking restart” should suffice (or su if sudoers is not configured to permit that).

It may be interesting to have a tiny script or maybe two huge aliases to toggle ipv6, so whenever you stumble with something that requires it (debian multimedia repositories, for example), you may reactivate it.

I hope the whole ipv6-and-speed get solved soon, if too many people use such circumventions, then we’ll face some trouble when everything becomes ipv6.

Reply

8 Geir Helland April 6, 2010

Add these lines to “/etc/sysctl.conf” and run “sysctl -p /etc/sysctl.conf”

#disable ipv6
net.ipv6.conf.all.disable_ipv6=1

Alternatively, just run this command to disable ipv6 temporarily:

echo 1 > /proc/sys/net/ipv6/conf/all/disable_ipv6

Aktivate again with “echo 0 ..”

Reply

9 Heinrich October 24, 2010

Thanks Geir, very useful

Reply

10 Stefan Lasiewski September 26, 2011

I see many solutions in this thread. What are the advantages/disadvantages of doing this via /etc/modprobe.d/* [1], vs. /etc/sysctl.conf vs. /etc/sysconfig/network vs. /etc/default/grub ?

Which way is the “best” way?

[1] Also see http://tldp.org/HOWTO/html_single/Linux+IPv6-HOWTO/#AEN734 , which agrees with Vivek’s solution.

Reply

11 Thron December 1, 2011

I add the following line to /etc/sysctl.conf
net.ipv6.conf.all.disable_ipv6 = 1
or do it for the specific nic
net.ipv6.conf.eth0.disable_ipv6 = 1

Then service network restart

Reply

Leave a Comment

You can use these HTML tags and attributes for your code and commands: <strong> <em> <ol> <li> <u> <ul> <blockquote> <pre> <a href="" title="">
What is 15 + 8 ?
Please leave these two fields as-is:
Are you a human being? Solve the simple math so we know that you are a human and not a bot.



Previous post:

Next post: