Skip to content

How to Disable IPv6 on CentOS

Introduction

IPv6 is the next-generation internet protocol that provides a larger address space compared to IPv4. However, there may be situations where you need to disable IPv6 on your CentOS server. Disabling IPv6 can help resolve compatibility issues or improve network performance. This guide provides two methods to disable IPv6 on CentOS: using sysctl and using the kernel boot option. By following these steps, you can effectively disable IPv6 on your CentOS system.

Method 1: Disable IPv6 Using sysctl

  1. Open the sysctl configuration file /etc/sysctl.d/90-ipv6.conf using the following command:

    Bash Session
    vi /etc/sysctl.d/90-ipv6.conf
    
  2. Add the following lines to the file and save it:

    Text Only
    net.ipv6.conf.all.disable_ipv6 = 1
    net.ipv6.conf.default.disable_ipv6 = 1
    
  3. Apply the changes by running the following command:

    Bash Session
    sysctl --load /etc/sysctl.d/90-ipv6.conf
    
  4. To verify that IPv6 is disabled, use the following command:

    Bash Session
    ip a | grep inet6
    

    If the command does not return any output, it means that IPv6 has been disabled on all your network interfaces.

Note

If you are using CentOS 8 with Network Manager, some network interfaces may still use IPv6 after a system reboot. To completely stop using IPv6, proceed to Method 2.

Method 2: Disable IPv6 Using the Kernel Boot Option

  1. Open the default GRUB configuration file /etc/default/grub using the following command:

    Bash Session
    vi /etc/default/grub
    
  2. Locate the line that begins with GRUB_CMDLINE_LINUX and append ipv6.disable=1 to the existing parameters. The line should look like this:

    VimL
    GRUB_CMDLINE_LINUX="$GRUB_CMDLINE_LINUX ipv6.disable=1"
    
  3. Save and exit the configuration file.

  4. Update the GRUB configuration files by running the following commands:

    Bash Session
    grub2-mkconfig -o /boot/grub2/grub.cfg
    grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg
    
  5. Reboot your CentOS machine for the changes to take effect:

    Bash Session
    reboot
    
  6. After the reboot, use the following command to verify whether IPv6 is disabled:

    Bash Session
    ip a | grep inet6
    

    If no IPv6 addresses are displayed, it indicates that IPv6 has been successfully disabled.

Conclusion

Disabling IPv6 on CentOS can be necessary in certain scenarios. By following the methods outlined in this guide, you can effectively disable IPv6 on your CentOS system. Choose the method that best suits your requirements and verify the success of the disabling process. Disabling IPv6 can help resolve compatibility issues and improve network performance if IPv6 is not required in your environment.


Last update: June 17, 2023 21:48:54
Created: June 17, 2023 21:48:54

Comments