keepcalculator

06 Numbers and Powers

Disable IPv6 in CentOS: Steps & Risks

Card No. 06·28064 · Updated · Standard formula, shown below

To disable IPv6 in CentOS, you typically edit the kernel boot parameters or the network configuration files, depending on your CentOS version. This guide covers the exact steps for CentOS 7, 8, and 9, plus the risks and why you might (or might not) want to do it.

Why People Disable IPv6

IPv6 is the modern replacement for IPv4, but it’s not always welcome. Common reasons to disable it include:

  • Legacy applications or scripts that hardcode IPv4 addresses and break when IPv6 is tried first.
  • Network environments where IPv6 isn’t routed correctly, causing connection timeouts (e.g., a host waiting for an IPv6 response that never comes).
  • Simplified troubleshooting: one protocol means fewer variables.
  • Security policies that restrict IPv6 traffic, even though IPv6 itself isn’t inherently less secure.

However, modern CentOS (8 and later) is designed to run with IPv6 enabled. Disabling it is a workaround, not a fix, and can cause subtle problems with SSH, NFS, or Docker if those services expect IPv6.

How IPv6 Is Enabled in CentOS

IPv6 is part of the Linux kernel and is loaded as a module (ipv6) unless explicitly disabled. On CentOS 7, the network service reads /etc/sysctl.conf and /etc/sysctl.d/ to set runtime kernel parameters. On CentOS 8/9, NetworkManager also respects these sysctl settings but manages connections through nmcli or the GNOME GUI.

The kernel parameter that controls IPv6 is net.ipv6.conf.all.disable_ipv6. Setting it to 1 turns off IPv6 on all interfaces. You can also set it per-interface (e.g., net.ipv6.conf.eth0.disable_ipv6=1).

There are two ways to apply this: temporarily (until reboot) with sysctl -w, or permanently by writing to a sysctl file. The permanent method is what most admins want.

Method 1: Disable via sysctl (All CentOS Versions)

This is the cleanest, most portable method. It works on CentOS 7, 8, and 9.

  1. Open a terminal and become root: sudo -i
  2. Create a new sysctl config file: vi /etc/sysctl.d/99-disable-ipv6.conf
  3. Add these lines:
    net.ipv6.conf.all.disable_ipv6 = 1
    net.ipv6.conf.default.disable_ipv6 = 1
  4. Apply it immediately: sysctl -p /etc/sysctl.d/99-disable-ipv6.conf
  5. Verify: ip -6 addr should show no addresses, and cat /proc/sys/net/ipv6/conf/all/disable_ipv6 should output 1.

Note: The default line ensures new interfaces (e.g., a USB NIC plugged in later) also get IPv6 disabled. Without it, a new interface might still have IPv6.

To re-enable, change the 1 to 0 and reload, or remove the file and reboot.

Method 2: Disable via GRUB (CentOS 7/8)

This method adds a kernel boot parameter, which completely prevents the IPv6 module from loading. It’s more aggressive and can break things like NFS or Docker that rely on IPv6 loopback (::1). Use only if the sysctl method doesn’t work (rare).

  1. Edit /etc/default/grub.
  2. Find the line GRUB_CMDLINE_LINUX and add ipv6.disable=1 inside the quotes. For example:
    GRUB_CMDLINE_LINUX="... rhgb quiet ipv6.disable=1"
  3. Regenerate the GRUB config:
    • CentOS 7 (BIOS): grub2-mkconfig -o /boot/grub2/grub.cfg
    • CentOS 7 (UEFI): grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg
    • CentOS 8/9: grub2-mkconfig -o /boot/grub2/grub.cfg (path may vary on UEFI systems)
  4. Reboot: reboot

After boot, lsmod | grep ipv6 should return nothing, and /proc/sys/net/ipv6 won’t exist.

Method 3: Disable per Interface (CentOS 8/9 with NetworkManager)

If you only want to disable IPv6 on a specific interface (e.g., eth0) but keep it on others, use NetworkManager’s connection profile.

  1. List connections: nmcli connection show
  2. Set IPv6 to ignore: nmcli connection modify "System eth0" ipv6.method ignore
  3. Reactivate: nmcli connection up "System eth0"

This tells NetworkManager not to configure IPv6 on that connection, but the kernel still has IPv6 enabled (so loopback works). This is the safest per-interface method.

Common Problems and Misconceptions

  • “Disabling IPv6 speeds up my network.â€� Usually false. IPv6 doesn’t slow down IPv4 traffic. If you have timeouts, the real cause is often a broken IPv6 route or DNS, not IPv6 itself.
  • “I can just uninstall the IPv6 module.â€� Not possible. IPv6 is compiled into the kernel, not a loadable module on CentOS 8/9. You can only disable it via sysctl or boot param.
  • “After sysctl, IPv6 is gone.â€� Not entirely. The loopback interface (lo) still has ::1 unless you also set net.ipv6.conf.lo.disable_ipv6=1. Some services (like SSH) may still bind to :: and listen on IPv6.
  • “I disabled IPv6 but my system still shows an IPv6 address.â€� Check if you set both all and default. Also, NetworkManager may override sysctl on some interfaces; use the nmcli method instead.
  • “Docker breaks after disabling IPv6.â€� Docker’s default bridge network uses IPv4, but some containers or custom networks may expect IPv6. Disabling IPv6 globally can cause Docker to fail to start on some versions.

When You Should NOT Disable IPv6

If your server is publicly accessible and your ISP or hosting provider supports IPv6, leave it enabled. Reasons:

  • IPv6 is required for future connectivity; IPv4 address space is exhausted.
  • Many modern services (e.g., mail servers, CDNs) use IPv6 for better performance.
  • Disabling it can break SSH if you connect via IPv6, or break NFS mounts that use IPv6 addresses.
  • It’s a system-wide change that can have unintended side effects on monitoring tools, backups, or firewall rules.

Instead of disabling, fix the underlying issue: configure proper IPv6 DNS, or set net.ipv6.conf.all.disable_ipv6=0 and instead set net.ipv6.conf.all.autoconf=0 to stop auto-configuration if that’s the problem.

Verifying and Reverting

To check if IPv6 is active:

  • ip -6 addr — shows IPv6 addresses (or empty if disabled).
  • cat /proc/sys/net/ipv6/conf/all/disable_ipv6 — 1 means disabled, 0 means enabled.
  • ping6 ::1 — succeeds if IPv6 loopback works.

To revert the sysctl method, delete the file /etc/sysctl.d/99-disable-ipv6.conf and run sysctl -p or reboot. For the GRUB method, remove ipv6.disable=1 from /etc/default/grub, regenerate GRUB, and reboot.

Frequently Asked Questions

Will disabling IPv6 break my internet connection?

No, if your ISP only provides IPv4. But if your ISP uses IPv6-only (rare), you’ll lose connectivity. Most home and business connections have IPv4, so it’s safe. Test by pinging an IPv4 address after disabling.

Is it safe to disable IPv6 on a CentOS 8 server?

It’s safe for basic web serving or SSH, but it can break services that specifically use IPv6, like some Docker networks or IPv6-only monitoring. Always test in a staging environment first.

What’s the difference between sysctl and GRUB methods?

Sysctl disables IPv6 at runtime (and after reboot if persisted) but the kernel module still loads. GRUB method prevents the module from loading entirely, which is more thorough but can cause more side effects (like breaking IPv6 loopback).

How do I disable IPv6 on a specific interface only?

Use nmcli connection modify "Connection Name" ipv6.method ignore on CentOS 8/9, or add net.ipv6.conf.eth0.disable_ipv6=1 to sysctl on CentOS 7.

Why does my system still have an IPv6 address after disabling?

You likely didn’t set both all and default in sysctl, or NetworkManager re-enabled it. Check with sysctl net.ipv6.conf.all.disable_ipv6 and use the nmcli method if needed.

Can I enable IPv6 later without reinstalling?

Yes, simply reverse the steps: remove the sysctl file or GRUB parameter, reload, and reboot. No reinstall needed.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →