Linux: How To Disable The IPv6 Protocol

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.

ADVERTISEMENTS

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:

🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source & DevOps topics via:
CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
17 comments… add one
  • Teodor Jul 22, 2009 @ 6:24

    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

    • Teodor Oct 30, 2013 @ 13:30

      How in the world someone would unsubscribe from your alerts?

      It feels like I made a mistake posting a comment on this forum!

      • 🐧 nixCraft Oct 30, 2013 @ 18:10

        Check the bottom of this page or email. FYI, I just removed you from this FAQ/page.

        HTH

  • Axel Aug 4, 2009 @ 18:35

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

  • Pete Aug 11, 2009 @ 23:29

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

    Pete.

  • Sean Nov 28, 2009 @ 21:45

    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

  • Harri Jan 20, 2010 @ 9:02

    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.

    • Peter Jul 25, 2010 @ 19:18

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

  • the dsc Jan 30, 2010 @ 4:41

    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.

  • Geir Helland Apr 6, 2010 @ 9:30

    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 ..”

  • Heinrich Oct 24, 2010 @ 11:06

    Thanks Geir, very useful

  • Stefan Lasiewski Sep 26, 2011 @ 22:59

    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.

    • Eric Wheeler Jan 20, 2013 @ 0:37

      I like the sysctl or /proc method as it should be most reliable since some kernels may hard-code ipv6 support. If its compiled as a module then the module way will work, but its not quite as reliable.

      On the other hand, the sysctl method may not work if the module is unloaded. If the module is loaded after sysctl is processed, the config parameter may not be respected since without the module the /proc entry it wouldn’t exist yet. So use both methods if you wish to be certain.

      Since most distribution network stacks load IPv6 by default these days, the sysctl is probably the most reliable single-step. Setting the module alias to off will be useless for kernels with ipv6 hard-compiled in.

      -Eric
      Expert Linux server support and Security since 1996

  • Thron Dec 1, 2011 @ 20:01

    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

  • Rajarshi May 19, 2012 @ 6:46

    To disable ipv6 on Debian 6:
    echo net.ipv6.conf.all.disable_ipv6=1 > /etc/sysctl.d/disableipv6.conf
    Reboot.

  • IgnitedMind Apr 5, 2013 @ 10:03

    1. I had already made following entries in ifcfg-eth0 :
    IPv6INIT=NO
    IPV6AUTOCONF=NO
    2. Following entries were made in /etc/modprob.conf” :
    alias net-pf-10 off
    alias ipv6 off
    3. These entries in /etc/sysconfig/network :
    IPV6INIT=NO
    NETWORKING_IPV6=NO
    4. This line is added to /etc/modprobe.d/blaclist :
    blacklist ipv6
    5. Also I did one more in /etc/sysctl.conf :
    6. `net.ipv6.conf.all.autoconf = 0`
    7. `net.ipv6.conf.accept_ra = 0`

    Still I am unable to disable IPV6 on linux, any thought please

  • me Oct 16, 2013 @ 16:25

    Since I have been forced into this land of ozz you people call linux, how about telling us , inplain english, how does one Open your modprob.conf file (Red Hat / CentOS / Fedora and friend) and add following line:
    How do I know if I have one of these “systems”.
    why does everything has to be engineered for a Martian?
    why do I have to be a computer engineer to run this progra,

    If Windows wasn’t working directly for the NSA, I assure you I wouldn’t be here, asking questions that you people will answer with more gobble de gooK?

Leave a Reply

Your email address will not be published. Required fields are marked *

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.