sodcalculator

10 Tech How-To

Disable IPv6 Temporarily on Linux and Restore It Safely

Guide 10-39412 · Updated · Step by step

Temporarily disabling IPv6 can help diagnose a network or application problem on Linux, but it may interrupt services that rely on IPv6. The steps below show how to turn it off for the current session, verify the change, and restore the original settings without making a permanent system-wide change.

What You’ll Need

  • A local terminal session and an account with sudo privileges (or root access).
  • The name of the network interface you want to change, such as eth0, ens33, or wlan0.
  • If connected remotely, preferably a way to access the machine locally or through a separate management connection. Changing network settings can disconnect SSH.

Step-by-Step

  1. Check how IPv6 is currently configured. In a terminal, run ip -6 address show to see IPv6 addresses and interfaces. Run ip link show to identify interface names. Also inspect the kernel setting with sysctl net.ipv6.conf.all.disable_ipv6 and sysctl net.ipv6.conf.default.disable_ipv6. A value of 0 means enabled; 1 means disabled. Record the values so you can restore them accurately.
  2. Decide whether you need to disable IPv6 everywhere or on one interface. To limit the change, use the interface-specific setting in step 4. For a temporary system-wide test, use step 3. Disabling IPv6 can affect local services, VPNs, containers, name resolution, and connections that prefer IPv6. Do not do this casually on a remote system.
  3. Temporarily disable IPv6 system-wide, if appropriate. Run these commands, replacing no values: sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1, then sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1. The first applies to existing interfaces; the second sets the default for interfaces created afterward. These changes are normally temporary and do not survive a reboot. Existing applications may need to reconnect before they reflect the change.
  4. Or disable IPv6 on just one interface. Replace IFACE with the exact name found earlier, for example wlan0: sudo sysctl -w net.ipv6.conf.IFACE.disable_ipv6=1. The shell treats the text literally, so enter the actual interface name rather than typing IFACE. This narrower test is usually preferable when diagnosing one connection.
  5. Verify the result. Check the relevant setting with sysctl net.ipv6.conf.all.disable_ipv6 or sysctl net.ipv6.conf.IFACE.disable_ipv6. Then run ip -6 address show dev IFACE for an interface-specific check, or ip -6 address show for all interfaces. The setting should read 1; IPv6 addresses may disappear or become unusable. A loopback address or special kernel entries can still appear, so do not rely on one displayed line alone.
  6. Test only the task you are investigating. Retry the affected application or connection and note the result. If the test does not help, restore IPv6 rather than leaving it disabled. Do not alter firewall rules or resolver configuration as part of this procedure; those are separate settings.
  7. Restore the recorded values. If the original system-wide values were both 0, run sudo sysctl -w net.ipv6.conf.all.disable_ipv6=0 and sudo sysctl -w net.ipv6.conf.default.disable_ipv6=0. For an interface-only change, run sudo sysctl -w net.ipv6.conf.IFACE.disable_ipv6=0, using the actual interface name. If your recorded values differed, restore those exact values instead of assuming both were enabled.
  8. Confirm service is back. Recheck the sysctl value and ip -6 address show. Network configuration managers may take a short time to renew addresses; if needed, reconnect that network through your normal desktop or server network manager. Avoid restarting networking remotely unless you have a recovery route.

Common Mistakes

  • Assuming a sysctl change is permanent. The -w commands change the running system, not the usual persistent configuration. Conversely, do not add settings to a sysctl configuration file if you only intend a temporary test.
  • Changing only one setting without understanding the scope. all affects existing interfaces, while default supplies a default for interfaces created later. An interface-specific setting targets one interface. A system may have additional per-interface settings.
  • Using the wrong interface name. Names vary between systems. Copy the name from ip link show; do not assume every wireless interface is called wlan0.
  • Working over the connection you are changing. Disabling IPv6 can drop an SSH session if it uses IPv6, and changing network state can disrupt remote access even when the session uses IPv4.
  • Confusing disabled IPv6 with a firewall block. The commands above change the kernel IPv6 setting. They do not remove firewall rules, fix DNS, or guarantee that every application immediately changes its behavior.

Tips

  • Prefer an interface-only change for a narrow diagnosis. It reduces the chance of affecting unrelated network services.
  • Copy the original values into your notes before changing anything. Restore the original state, not an assumed default.
  • Use a second terminal to keep a recovery path available, especially on a server. If you are remote, arrange console access first.
  • Keep the change brief and verify the exact problem while IPv6 is off. Re-enable it as soon as the test is complete.
  • If the command reports that a setting does not exist, check the spelling and whether IPv6 is enabled or supported by that kernel; do not create persistent files to work around it.

Troubleshooting

Permission denied: rerun the command with sudo, or use a root shell if that is how your system is administered. If you do not have administrative access, ask the system administrator rather than trying to bypass permissions.

The value returns to 0 or the interface still has IPv6: a network manager or system service may reconfigure interfaces, or you may have changed a different scope than the one being checked. Inspect sysctl net.ipv6.conf.all.disable_ipv6, sysctl net.ipv6.conf.default.disable_ipv6, and the interface-specific value. Recheck after reconnecting, and consult the distribution’s network-management configuration before making any persistent adjustment.

You lost your remote connection: use a local console, out-of-band management, or an authorized recovery route to set the original values back to 0 (or to the values you recorded). If the change was only made with sysctl -w, rebooting may also clear it unless other configuration reapplies the setting. Do not count on reboot if the setting is configured persistently.

IPv6 is restored but an application still fails: reconnect the application or network, then check DNS and firewall configuration separately. The temporary toggle may not have been the cause, and changing unrelated settings can make diagnosis harder.

Frequently Asked Questions

Will disabling IPv6 with sysctl survive a reboot?
Usually not when using sysctl -w; it changes the running kernel state. Configuration files or boot settings can reapply a disabled state, so check them if it remains off after reboot.

Can I disable IPv6 for just Wi-Fi?
Yes. Use net.ipv6.conf.IFACE.disable_ipv6 with the Wi-Fi interface’s actual name, then restore that same setting afterward.

Does this turn off IPv4 too?
No. These settings target IPv6. However, a connection or service that depends on IPv6 may stop working.

Is disabling IPv6 a good permanent fix?
Generally, treat it as a diagnostic step. If IPv6 is causing a persistent issue, identify the underlying network, firewall, or application configuration rather than leaving it disabled without a clear need.

Why do I still see an IPv6 entry after disabling it?
Some displayed entries, such as loopback or kernel-related information, may remain. Check the relevant sysctl value and whether the interface can actually use IPv6; do not judge solely by one line of output.

Related

General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.

More in this bed

The whole Tech How-To bed →