If you’re wondering how to disable ipv6 linux, you are not alone. Many users turn off IPv6 to fix network issues or improve performance. Removing Gear VR service from your phone stops it from running in the background, and disabling IPv6 on Linux works similarly—it stops unnecessary network traffic. This guide covers everything from temporary commands to permanent kernel changes.
IPv6 is the newer version of the Internet Protocol, but it can cause problems with certain apps or routers. Disabling it is a common troubleshooting step. You can do this in several ways, depending on your Linux distribution and needs.
Why Disable IPv6 On Linux?
Before we get into the steps, let’s understand why you might want to disable IPv6. Some VPNs don’t work well with IPv6 enabled. Older network hardware may have bugs with IPv6. Some enterprise networks only support IPv4.
Disabling IPv6 can also speed up DNS lookups. If your ISP doesn’t support IPv6 properly, your system might waste time trying to connect. Turning it off forces your system to use IPv4 only, which is often more stable.
But remember, IPv6 is not evil. It’s actually essential for the future of the internet. Only disable it if you have a specific reason.
How To Disable Ipv6 Linux
Now let’s get to the main part. There are multiple methods to disable IPv6 on Linux. We’ll cover the most common ones, from simple to permanent.
Method 1: Temporary Disable Via Sysctl
This method disables IPv6 until you reboot. It’s great for testing if IPv6 is causing your issue.
- Open a terminal.
- Type the following command to disable IPv6 for all interfaces:
sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1 - Then disable it for the default interface:
sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1 - To verify, run:
cat /proc/sys/net/ipv6/conf/all/disable_ipv6 - If it shows
1, IPv6 is disabled.
This change is immediate but not permanent. After a reboot, IPv6 will be enabled again. Use this for quick tests.
Method 2: Permanent Disable Via Sysctl Configuration
To make the change survive reboots, you need to edit the sysctl configuration file.
- Open the file
/etc/sysctl.confwith a text editor:
sudo nano /etc/sysctl.conf - Add these lines at the end of the file:
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1 - Optionally, disable it for a specific interface like eth0:
net.ipv6.conf.eth0.disable_ipv6 = 1 - Save the file and exit.
- Apply the changes:
sudo sysctl -p
This method works on most Linux distributions, including Ubuntu, Debian, Fedora, and CentOS. The changes will persist across reboots.
Method 3: Disable IPv6 Via Grub Boot Loader
Another permanent method is to pass a kernel parameter at boot. This completely disables the IPv6 module.
- Open the GRUB configuration file:
sudo nano /etc/default/grub - Find the line that starts with
GRUB_CMDLINE_LINUX_DEFAULT. - Add
ipv6.disable=1inside the quotes. For example:
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash ipv6.disable=1" - Save and exit.
- Update GRUB:
On Ubuntu/Debian:sudo update-grub
On Fedora/CentOS:sudo grub2-mkconfig -o /boot/grub2/grub.cfg - Reboot your system.
This method is more aggresive because it stops the IPv6 kernel module from loading at all. It’s very effective but harder to reverse.
Method 4: Disable IPv6 Via Network Manager
If you use NetworkManager (common on desktop Linux), you can disable IPv6 per connection.
- Open NetworkManager settings. You can use the GUI or command line.
- For GUI: Go to Settings > Network > select your connection (Wi-Fi or wired) > click the gear icon.
- Go to the IPv6 tab.
- Change the method to “Disabled” or “Ignore”.
- Apply and reconnect.
For command line, use nmcli:
- List connections:
nmcli connection show - Disable IPv6 for a connection:
nmcli connection modify "YourConnectionName" ipv6.method disabled - Restart the connection:
nmcli connection down "YourConnectionName" && nmcli connection up "YourConnectionName"
This method only affects the specific network connection. Other interfaces may still use IPv6.
Method 5: Disable IPv6 For Specific Services
Sometimes you only want to disable IPv6 for certain services like SSH or Apache. You can configure each service individually.
For SSH, edit /etc/ssh/sshd_config and set:
AddressFamily inet
Then restart SSH: sudo systemctl restart sshd
For Apache, edit the config file and add:
Listen 0.0.0.0:80
Instead of Listen 80 which listens on both IPv4 and IPv6.
This approach is more precise. You keep IPv6 enabled for the system but restrict it for specific apps.
How To Verify IPv6 Is Disabled
After applying any method, you should verify that IPv6 is actually off. Here are some commands:
ip aorifconfig– Check if you see any inet6 addresses. If none, IPv6 is disabled.cat /proc/sys/net/ipv6/conf/all/disable_ipv6– Should show1.ping6 google.com– Should fail with “Network is unreachable” or similar.ss -tuln– Check if services are listening on IPv6 addresses.
If you still see IPv6 addresses, the method may not have worked. Double-check the steps or try a different method.
Potential Issues When Disabling IPv6
Disabling IPv6 can cause problems. Some applications rely on IPv6 for features like link-local addressing. SSH X11 forwarding may break. Some Docker containers need IPv6.
Also, if you disable IPv6 via GRUB, you might have trouble with certain network tools. The kernel module is completely gone, so you can’t enable it without a reboot.
Another issue: some systemd services might fail if they expect IPv6. You may see errors in logs, but they are usually harmless.
If you experience problems, re-enable IPv6 using the reverse steps. For sysctl, set the values to 0. For GRUB, remove the parameter and update GRUB again.
How To Re-Enable IPv6
To undo the changes, follow these steps:
- For temporary sysctl:
sudo sysctl -w net.ipv6.conf.all.disable_ipv6=0 - For permanent sysctl: edit
/etc/sysctl.confand remove or comment the lines, then runsudo sysctl -p. - For GRUB: remove
ipv6.disable=1from/etc/default/grub, update GRUB, and reboot. - For NetworkManager: change the IPv6 method back to “Automatic” or “DHCP”.
After re-enabling, verify with the same commands. IPv6 should be working again.
Disabling IPv6 On Specific Linux Distributions
Ubuntu And Debian
Both methods 2 and 3 work well. Ubuntu also has a GUI option via NetworkManager. For server editions, use sysctl or GRUB.
Fedora And CentOS
Fedora uses NetworkManager by default. The nmcli method is easiest. For CentOS, sysctl is common. GRUB method also works.
Arch Linux
Arch users often prefer the GRUB method. But sysctl is also fine. Arch’s /etc/sysctl.d/ directory allows custom config files.
OpenSUSE
OpenSUSE uses YaST for network configuration. You can disable IPv6 there. Alternatively, use sysctl or GRUB.
Disabling IPv6 For Specific Interfaces
You might want to disable IPv6 only on one network interface, like eth0, but keep it on others. Use this sysctl command:
sudo sysctl -w net.ipv6.conf.eth0.disable_ipv6=1
To make it permanent, add to /etc/sysctl.conf:
net.ipv6.conf.eth0.disable_ipv6 = 1
Replace eth0 with your interface name. Find it with ip link show.
Using Firewall To Block IPv6
Another way to effectively disable IPv6 is to block it with a firewall. This doesn’t actually turn it off, but it stops traffic.
With iptables:
sudo ip6tables -P INPUT DROP
sudo ip6tables -P OUTPUT DROP
sudo ip6tables -P FORWARD DROP
With firewalld (Fedora/CentOS):
sudo firewall-cmd --zone=public --remove-service=dhcpv6-client
sudo firewall-cmd --runtime-to-permanent
This method is less intrusive and easier to reverse. But it doesn’t free up kernel resources like true disabling does.
Common Mistakes When Disabling IPv6
- Forgetting to apply changes with
sysctl -pafter editing the config file. - Not updating GRUB after editing
/etc/default/grub. - Disabling IPv6 on a system that relies on it for internal networking (like some Kubernetes clusters).
- Using the wrong interface name in sysctl commands.
- Not restarting network services after making changes.
When You Should NOT Disable IPv6
If your network fully supports IPv6, leave it enabled. Many modern websites and services use IPv6. Disabling it can slow down connections because your system has to fall back to IPv4.
Also, if you use Docker or containers, they often require IPv6 for internal networking. Disabling it may break container communication.
Windows Subsystem for Linux (WSL) also uses IPv6 for some features. Disabling it there can cause issues.
Frequently Asked Questions
How do I disable IPv6 on Linux permanently?
Edit /etc/sysctl.conf and add net.ipv6.conf.all.disable_ipv6 = 1 and net.ipv6.conf.default.disable_ipv6 = 1. Then run sudo sysctl -p. This survives reboots.
Can I disable IPv6 without rebooting?
Yes, use the sysctl command: sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1. This takes effect immediately but resets after reboot.
Does disabling IPv6 improve performance?
In some cases, yes. If your ISP has broken IPv6, disabling it can reduce connection timeouts. But on a well-configured network, it may not help.
How do I disable IPv6 on Ubuntu 22.04?
Use the sysctl method or GRUB method. Ubuntu 22.04 uses systemd, so both work. NetworkManager GUI also works for desktop users.
What is the command to check if IPv6 is disabled?
Run cat /proc/sys/net/ipv6/conf/all/disable_ipv6. If it returns 1, IPv6 is disabled. Also check with ip a for no inet6 addresses.
Final Thoughts
Disabling IPv6 on Linux is straightforward once you know the methods. Start with the temporary sysctl method to test if it solves your problem. Then make it permanent if needed.
Remember that IPv6 is not inherently bad. Only disable it if you have a clear reason. And always have a plan to re-enable it if things go wrong.
We’ve covered multiple ways: sysctl, GRUB, NetworkManager, firewall, and per-service. Choose the one that fits your setup. Most users find the sysctl method to be the best balance of simplicity and effectiveness.
If you encounter any issues, check the logs with dmesg | grep -i ipv6 or journalctl -xe. These can help diagnose problems.
Now you know how to disable ipv6 linux like a pro. Go ahead and apply the method that works for you. Your network will thank you.