Most Linux distributions ship with IPv6 enabled by default. That works fine until it does not. Legacy applications that choke on IPv6 addresses, VPN tunnels that only handle IPv4, or troubleshooting scenarios where you need a clean IPv4-only stack that don’t handle dual-stack networking, troubleshooting DNS resolution issues, or hardening a server that only needs IPv4 connectivity. This guide covers every method to disable IPv6 on Ubuntu 24.04/22.04 and Rocky Linux 10/AlmaLinux 10, from temporary runtime changes to permanent kernel-level configuration.
Each method has trade-offs. Runtime sysctl changes are instant but lost on reboot. Persistent sysctl files survive reboots but can be overridden by NetworkManager. GRUB kernel parameters are the most bulletproof approach since IPv6 never loads in the first place. Pick the method that fits your use case.
Prerequisites
You need root or sudo access on your Linux system. These instructions are tested on:
- Ubuntu 24.04 LTS and Ubuntu 22.04 LTS
- Rocky Linux 10 and AlmaLinux 10
The commands work on other distributions in the same families (Debian 13/12, RHEL 10, Fedora 42) with no changes.
Check Current IPv6 Status
Before making changes, confirm whether IPv6 is currently active on your system. Run this command to check the kernel parameter:
cat /proc/sys/net/ipv6/conf/all/disable_ipv6
A value of 0 means IPv6 is enabled. A value of 1 means it is disabled.
You can also check for active IPv6 addresses on your interfaces:
ip -6 addr show
If you see inet6 addresses listed (other than ::1 on loopback), IPv6 is active and in use.
Method 1: Disable IPv6 Temporarily with sysctl (Runtime Only)
This method disables IPv6 immediately without a reboot, but the change is lost when the system restarts. It is useful for quick testing or troubleshooting.
Disable IPv6 on all network interfaces:
sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1
sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1
The kernel applies the change instantly. Verify it took effect:
cat /proc/sys/net/ipv6/conf/all/disable_ipv6
The output should show 1, confirming IPv6 is now disabled.
You can also confirm no IPv6 addresses remain on your interfaces:
ip -6 addr show
This should return empty output or only show the loopback address. Remember, this change reverts after a reboot. For a persistent solution, use Method 2 or Method 3.
Method 2: Disable IPv6 Permanently via sysctl Configuration
Creating a sysctl configuration file makes the IPv6 disable setting persist across reboots. This is the most common approach for servers that need IPv4 only.
Create a new sysctl configuration file:
sudo vi /etc/sysctl.d/70-disable-ipv6.conf
Add the following lines:
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1
Save the file and apply the settings without rebooting:
sudo sysctl --system
You should see your settings being applied in the output. Verify the change:
sysctl net.ipv6.conf.all.disable_ipv6
The output should confirm the value is set to 1:
net.ipv6.conf.all.disable_ipv6 = 1
Important note for NetworkManager systems
On systems running NetworkManager (default on Rocky Linux 10, AlmaLinux 10, and Ubuntu desktop), NetworkManager can re-enable IPv6 on managed interfaces even after setting the sysctl parameter. To prevent this, also disable IPv6 in NetworkManager for each connection.
List your active connections:
nmcli connection show --active
Then disable IPv6 on the connection (replace ens18 with your actual connection name):
sudo nmcli connection modify ens18 ipv6.method disabled
sudo nmcli connection up ens18
This ensures NetworkManager won’t override your sysctl settings.
Method 3: Disable IPv6 via GRUB Kernel Parameter
The most reliable way to disable IPv6 is at the kernel level through GRUB boot parameters. This prevents the IPv6 kernel module from loading entirely, which means no process or service can re-enable it at runtime.
Ubuntu 24.04/22.04
Edit the GRUB configuration file:
sudo vi /etc/default/grub
Find the line starting with GRUB_CMDLINE_LINUX and add the IPv6 disable parameter. If the line already has values, append to them:
GRUB_CMDLINE_LINUX="ipv6.disable=1"
If you have existing parameters, keep them and add ipv6.disable=1 at the end, separated by a space.
Regenerate the GRUB configuration:
sudo update-grub
Reboot the system for the change to take effect:
sudo reboot
Rocky Linux 10 / AlmaLinux 10
On RHEL-family distributions, edit the GRUB defaults:
sudo vi /etc/default/grub
Add ipv6.disable=1 to the GRUB_CMDLINE_LINUX line:
GRUB_CMDLINE_LINUX="crashkernel=auto ipv6.disable=1"
Keep any existing parameters and append the IPv6 disable flag. Then regenerate the GRUB configuration. The command differs depending on your boot mode.
For BIOS-based systems:
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
For UEFI-based systems:
sudo grub2-mkconfig -o /boot/efi/EFI/rocky/grub.cfg
On AlmaLinux 10, replace rocky with almalinux in the UEFI path. Then reboot:
sudo reboot
After the reboot, verify the kernel parameter was applied:
cat /proc/cmdline
You should see ipv6.disable=1 in the output. This confirms IPv6 is disabled at the kernel level.
Method 4: Disable IPv6 on a Specific Network Interface
Sometimes you only need to disable IPv6 on one interface while keeping it active on others. This is common on multi-homed servers where the internal interface should be IPv4-only but the external interface needs IPv6.
Using sysctl for a single interface
To disable IPv6 on a specific interface at runtime (replace ens18 with your interface name):
sudo sysctl -w net.ipv6.conf.ens18.disable_ipv6=1
To make this persistent, create a sysctl configuration file:
sudo vi /etc/sysctl.d/70-disable-ipv6-ens18.conf
Add the following line (adjust the interface name as needed):
net.ipv6.conf.ens18.disable_ipv6 = 1
Apply the configuration:
sudo sysctl --system
Verify IPv6 is disabled only on that interface:
ip -6 addr show dev ens18
This should return no IPv6 addresses for ens18, while other interfaces retain their IPv6 configuration.
Using NetworkManager for a single interface
On systems with NetworkManager, you can disable IPv6 per connection profile:
sudo nmcli connection modify ens18 ipv6.method disabled
sudo nmcli connection up ens18
Confirm the change by checking the connection details:
nmcli connection show ens18 | grep ipv6.method
The output should show ipv6.method: disabled.
How to Re-enable IPv6
If you need to restore IPv6 after disabling it, reverse the steps from whichever method you used.
Re-enable after sysctl (runtime)
Set the disable parameter back to 0:
sudo sysctl -w net.ipv6.conf.all.disable_ipv6=0
sudo sysctl -w net.ipv6.conf.default.disable_ipv6=0
IPv6 addresses will reappear on your interfaces within seconds.
Re-enable after persistent sysctl file
Remove the configuration file you created:
sudo rm /etc/sysctl.d/70-disable-ipv6.conf
sudo sysctl --system
If you also disabled IPv6 in NetworkManager, re-enable it:
sudo nmcli connection modify ens18 ipv6.method auto
sudo nmcli connection up ens18
The interface will obtain an IPv6 address through SLAAC or DHCPv6, depending on your network configuration.
Re-enable after GRUB kernel parameter
Edit /etc/default/grub and remove ipv6.disable=1 from the GRUB_CMDLINE_LINUX line. Then regenerate the GRUB configuration.
On Ubuntu:
sudo update-grub
On Rocky Linux / AlmaLinux (BIOS):
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
Reboot for the change to take effect. After reboot, IPv6 will be fully functional again.
Verify IPv6 is Disabled
Regardless of which method you used, run these checks to confirm IPv6 is properly disabled.
Check the kernel parameter value:
sysctl net.ipv6.conf.all.disable_ipv6
A value of 1 confirms IPv6 is disabled system-wide.
Confirm no IPv6 addresses are assigned to any interface:
ip -6 addr show
This should return empty output when IPv6 is fully disabled.
If you used the GRUB method, verify the kernel boot parameter:
cat /proc/cmdline | grep ipv6
You should see ipv6.disable=1 in the kernel command line.
Test that IPv6 connectivity is actually gone by attempting a connection to an IPv6-only endpoint:
ping -6 -c 2 ::1
With IPv6 disabled, this command will fail with “connect: Network is unreachable” or a similar error.
Things to Watch Out For
Disabling IPv6 can have side effects that catch people off guard. Keep these in mind:
- SSH may slow down – If your SSH config or DNS returns AAAA records, SSH will try IPv6 first and wait for it to time out. Add
AddressFamily inetto/etc/ssh/sshd_configto force IPv4-only connections. - DNS resolution issues – Some resolvers query for AAAA records even when IPv6 is disabled. If you see slow DNS lookups, configure your resolver to prefer IPv4.
- Package managers – APT and DNF may try IPv6 mirrors if the mirror list includes AAAA records. This usually falls back to IPv4 automatically but adds latency.
- Docker and containers – Docker uses IPv6 internally for some bridge networking features. Disabling IPv6 on the host can affect container networking. Test thoroughly before applying to production container hosts.
- Localhost connections – Some applications bind to
::1(IPv6 localhost) by default. With IPv6 disabled, those applications need to be configured to bind to127.0.0.1instead. - NetworkManager overrides – On RHEL-family systems, NetworkManager can re-enable IPv6 on managed interfaces. Always disable IPv6 in both sysctl and NetworkManager to avoid conflicts.
Frequently Asked Questions
Is it safe to disable IPv6 on a production server?
Yes, as long as your applications and services don’t depend on IPv6 connectivity. Most server workloads still run on IPv4. Check that your application configs don’t bind to IPv6 addresses before disabling it.
Which method is best for servers?
The GRUB kernel parameter method (Method 3) is the most reliable for production servers. It prevents the IPv6 stack from loading entirely, so no service or process can re-enable it. The sysctl file method (Method 2) is a close second and doesn’t require a reboot to apply.
Will disabling IPv6 break my system?
Modern Linux distributions work fine without IPv6. The main risks are applications that bind exclusively to IPv6 addresses and SSH slowdowns if DNS returns AAAA records. Both are easy to fix with minor configuration changes.
Can I disable IPv6 on one interface and keep it on another?
Yes, Method 4 covers exactly this. Use the per-interface sysctl parameter or NetworkManager’s per-connection setting to selectively disable IPv6 on specific interfaces.