Disable IPv6 on Linux
This guide explains how to permanently disable IPv6 on a Linux server using a persistent sysctl configuration file. The change takes effect immediately — no reboot required — and will survive future system restarts automatically.
How It Works
The Linux kernel exposes IPv6 behavior through a set of runtime parameters found under /proc/sys/net/ipv6/. By default, IPv6 is enabled on all network interfaces. To disable it, you need to set three specific kernel parameters to 1: one for all currently active interfaces, one for any interfaces created in the future, and one for the loopback interface.
While you can change these parameters on the fly using the sysctl command, those changes are lost on the next reboot. To make them permanent, you write them to a configuration file inside /etc/sysctl.d/. Files in this directory are loaded automatically at boot time. Using a 99- prefix ensures your file is applied last — overriding any distribution defaults that might otherwise re-enable IPv6.
Step 1 — Create a Dedicated sysctl Configuration File
Start by creating a new, dedicated configuration file for disabling IPv6. Keeping this setting in its own file makes it easy to identify, modify, or remove later:
sudo nano /etc/sysctl.d/99-disable-ipv6.conf
Paste the following three lines into the file:
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1
Each line targets a different scope:
all— disables IPv6 on every network interface currently active on the system.default— ensures that any new network interfaces created after boot also have IPv6 disabled.lo— disables IPv6 on the loopback interface (localhost).
Save and close the file. In nano, press Ctrl+O to save and Ctrl+X to exit.
Step 2 — Apply the Changes Immediately (No Reboot Needed)
Reload all sysctl configuration files, including the one you just created, with the following command:
sudo sysctl --system
This reads every .conf file in /etc/sysctl.d/ (and related directories) and applies all settings to the running kernel in real time. IPv6 is disabled immediately — no reboot is required.
Step 3 — Verify That IPv6 Is Disabled
Check whether any network interfaces still have IPv6 addresses assigned:
ip a | grep inet6
If IPv6 has been fully disabled, this command will return no output at all. If you still see a ::1 address listed for the loopback interface, double-check that the net.ipv6.conf.lo.disable_ipv6 = 1 line is present and correctly formatted in your configuration file.
You can also verify the kernel parameter value directly:
cat /proc/sys/net/ipv6/conf/all/disable_ipv6
A return value of 1 confirms IPv6 is disabled. If you see 0, IPv6 is still active and the sysctl configuration was not loaded correctly. In that case, re-run sudo sysctl --system and check your configuration file carefully for typos or formatting errors.
Summary
Disabling IPv6 via sysctl is the most reliable and maintainable method on Linux. By placing your settings in /etc/sysctl.d/99-disable-ipv6.conf, the configuration is modular, easy to manage, and automatically applied on every boot. This approach works across most major Linux distributions, including Ubuntu, Debian, CentOS, and Rocky Linux.
Leave a Reply