How to Disable IPv6 on Ubuntu (And Why You Probably Shouldn’t)

If you have ever chased a slow DNS lookup, a connection that hangs for a few seconds before falling back, or an application that refuses to bind correctly, you have probably landed on the same advice repeated across forums: disable IPv6. It is a tempting fix because it is fast and it often makes the immediate symptom disappear. But before you reach for the off switch, it is worth understanding what you are actually turning off and whether you should.

This guide covers every reliable method to disable IPv6 on Ubuntu — runtime, permanent, and at the kernel level — along with how to verify the change, how to reverse it, and the caveats that catch people out. Just as importantly, it explains why disabling IPv6 is frequently the *wrong* fix.

Key Takeaways
Disabling IPv6 is usually a workaround, not a solution. Most “IPv6 problems” are misconfigurations you can fix without turning the protocol off.
• There are three main methods: runtime via `sysctl` (temporary), permanent via `/etc/sysctl.d/`, and kernel-level via GRUB (`ipv6.disable=1`, the most thorough).
• The GRUB method disables IPv6 at boot before the network stack initializes — use it only if you genuinely need a fully IPv6-free system.
• Disabling IPv6 can break services that expect `::1` (the IPv6 loopback). Be ready to point those at IPv4 instead.
IPv6 is the future of internet addressing. Disable it only if you have a real, identified reason.

Should you actually disable IPv6?

Before any command, ask the honest question: do you have a real reason, or are you copying a quick fix?

Legitimate reasons to disable IPv6 do exist:

  • An application or service misbehaves over IPv6 — it advertises an IPv6 address it cannot actually reach, or binds to `::1` when your clients only speak IPv4.
  • Your network or upstream provider does not support IPv6, so the stack hands out addresses that route nowhere and slow down connection attempts.
  • You are troubleshooting and need to eliminate IPv6 as a variable to isolate a fault.
  • A compliance or firewall policy mandates a single-stack IPv4 environment.

Those are valid. What is *not* valid is disabling IPv6 because a tutorial said so. IPv4 address exhaustion is real, IPv6 adoption keeps climbing, and a growing number of networks, CDNs, and services now expect or require it. Turn it off system-wide and you may quietly break connectivity to IPv6-only endpoints down the line — and the next engineer to touch the box will have no idea why.

Here is the part most guides skip: the slowness or hang that drives people to disable IPv6 is almost always a symptom of a misconfiguration, not of IPv6 itself. A hostname returns both an A (IPv4) and AAAA (IPv6) record; your client tries the IPv6 address first; if that route is broken, it waits for a timeout before falling back to IPv4 — and *that* is the delay you feel. The correct fix is usually to repair the broken route, fix the DNS record, or adjust the application’s address-family preference — not to amputate the entire protocol. Reach for a system-wide disable only after you have confirmed the root cause cannot be addressed any other way. If you must, the GRUB method is the most complete, but it is also the bluntest instrument in the box.

What are the methods to disable IPv6 on Ubuntu?

There are three approaches, and they differ in scope and persistence. Pick based on whether you want a quick test or a permanent change, and how thoroughly IPv6 must be removed.

Method Persistence Scope Reboot required Best for
`sysctl -w` (runtime) Temporary (lost on reboot) Running kernel only No Quick testing and troubleshooting
`/etc/sysctl.d/` + `sysctl -p` Permanent Network stack via kernel parameters No (applies immediately) Most production cases
GRUB `ipv6.disable=1` Permanent Entire kernel — IPv6 never initializes Yes A fully IPv6-free system

A useful way to think about it: the `sysctl` methods disable the *use* of IPv6 while the module stays loaded, whereas the GRUB method stops IPv6 from existing at all at the kernel level. Start with the least invasive option that solves your problem.

How do you disable IPv6 temporarily with sysctl?

Use this when you want to test whether disabling IPv6 fixes an issue without committing to a permanent change. It applies immediately and reverts on the next reboot — which makes it the safest way to experiment.

“`bash sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1 sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1 sudo sysctl -w net.ipv6.conf.lo.disable_ipv6=1 “`

  • `all` affects every existing and future interface.
  • `default` sets the value for interfaces created after this point.
  • `lo` is the loopback interface — include it only if you specifically need `::1` gone, and be aware it can affect local services (more on that below).

To restore IPv6 before a reboot, set the same values back to `0`:

“`bash sudo sysctl -w net.ipv6.conf.all.disable_ipv6=0 sudo sysctl -w net.ipv6.conf.default.disable_ipv6=0 sudo sysctl -w net.ipv6.conf.lo.disable_ipv6=0 “`

Because nothing is written to disk, a reboot wipes the change entirely. That is exactly what makes runtime `sysctl` the right tool for diagnosis.

How do you disable IPv6 permanently with sysctl?

If the runtime test confirms you want IPv6 off and you want it to survive reboots, write the settings to a configuration file. The cleanest approach is a dedicated file in `/etc/sysctl.d/` rather than editing the main `/etc/sysctl.conf` — it keeps your change isolated and easy to remove later.

Create the file:

“`bash sudo tee /etc/sysctl.d/99-disable-ipv6.conf > /dev/null <<'EOF' net.ipv6.conf.all.disable_ipv6 = 1 net.ipv6.conf.default.disable_ipv6 = 1 net.ipv6.conf.lo.disable_ipv6 = 1 EOF ```

Then apply it without rebooting:

“`bash sudo sysctl –system “`

Or, if you wrote the values into `/etc/sysctl.conf` directly:

“`bash sudo sysctl -p “`

The `99-` prefix ensures the file loads late, so it overrides earlier defaults. To undo this method, simply delete the file and reload:

“`bash sudo rm /etc/sysctl.d/99-disable-ipv6.conf sudo sysctl –system “`

This approach is permanent but reversible, and it leaves the IPv6 kernel module loaded — which matters if some local tooling still expects the module to be present even while addressing is disabled.

How do you disable IPv6 at the kernel level with GRUB?

This is the most thorough method. Passing `ipv6.disable=1` as a kernel boot parameter stops the IPv6 stack from initializing *before* the network ever comes up. The module effectively does not exist for the running system.

Edit the GRUB configuration:

“`bash sudo nano /etc/default/grub “`

Find the line beginning with `GRUB_CMDLINE_LINUX_DEFAULT` and add `ipv6.disable=1` inside the quotes:

“`bash GRUB_CMDLINE_LINUX_DEFAULT=”quiet splash ipv6.disable=1″ “`

Save, then regenerate the GRUB configuration and reboot:

“`bash sudo update-grub sudo reboot “`

After the reboot, IPv6 is gone at the kernel level — no `disable_ipv6` sysctl toggles, no `::1`, nothing. To reverse it, remove `ipv6.disable=1` from the same line, run `sudo update-grub` again, and reboot.

Use this method only when a partial disable is not enough — for example, when a security baseline requires the kernel to present no IPv6 capability at all. For everyday troubleshooting, it is overkill.

How do you verify IPv6 is disabled?

Always confirm the change rather than assuming it worked. Two quick checks cover it.

Check that no interface has an IPv6 address (look for the absence of any `inet6` lines):

“`bash ip a | grep inet6 “`

No output means no IPv6 addresses are assigned. You can also inspect a specific interface:

“`bash ip a show eth0 “`

Read the sysctl value directly — `1` means disabled:

“`bash cat /proc/sys/net/ipv6/conf/all/disable_ipv6 “`

If you used the GRUB method, confirm the kernel ignored IPv6 entirely:

“`bash cat /proc/cmdline “`

You should see `ipv6.disable=1` in the boot command line, and `ip a` should show no `inet6` entries anywhere — not even loopback.

What can break, and how do you re-enable IPv6?

Disabling IPv6 is rarely free of side effects. The most common surprise is that some services bind to or expect the IPv6 loopback `::1` — local databases, mail components, or applications whose default configuration lists `::1` before `127.0.0.1`. When IPv6 disappears, those services may fail to start or refuse local connections.

The fix is usually a one-line change: point the affected service at the IPv4 loopback `127.0.0.1` instead of `::1` (or `localhost`, which may resolve to either). Check the service’s listen/bind directive in its configuration and `/etc/hosts`, where `localhost` is often mapped to both addresses.

To re-enable IPv6, reverse whichever method you used:

  • Runtime sysctl: set the values back to `0`, or simply reboot.
  • `/etc/sysctl.d/` file: delete the file and run `sudo sysctl –system`.
  • GRUB: remove `ipv6.disable=1`, run `sudo update-grub`, and reboot.

Re-enabling is always available, which is one more reason to start with the reversible methods before committing to a kernel-level change.


Running your own server and want full control over IPv6? On a or , you get full root access and a properly configured dual-stack network with both IPv4 and IPv6. That means you decide how the network stack behaves — enable, disable, or fine-tune IPv6 to match exactly what your applications need, without fighting a provider’s restrictions. With reliable networking and 24/7 support, you can experiment with confidence, knowing a clean baseline and a responsive team are behind you. It is the difference between working around your environment and owning it.


Frequently asked questions

Does disabling IPv6 improve performance? Rarely in a meaningful way. If you see a speed-up, it is almost always because a *broken* IPv6 route was causing fallback timeouts. Fixing the underlying route or DNS record gives you the same speed without losing the protocol. Disabling IPv6 on a correctly configured network offers no real performance benefit.

Should I include the `lo` (loopback) interface when disabling IPv6? Only if you specifically need `::1` removed. Disabling IPv6 on loopback is the most likely cause of local services failing to start, since many default to binding `::1`. If you do not need it gone, leave `lo` alone and disable IPv6 on `all` and `default` only.

What is the difference between the sysctl and GRUB methods? The `sysctl` methods disable the *use* of IPv6 while the kernel module remains loaded, so IPv6 can be turned back on without a reboot. The GRUB `ipv6.disable=1` parameter prevents the IPv6 stack from initializing at all during boot — more thorough, but it requires a reboot to apply or reverse.

Will disabling IPv6 break my internet connection? On a normal IPv4-capable network, no — IPv4 keeps working. The risk is connectivity to IPv6-only endpoints, which will become unreachable. As more services move toward IPv6, a system-wide disable can cause subtle, hard-to-diagnose failures later.

Is it better to disable IPv6 or just fix the configuration? Fix the configuration whenever you can. IPv6 is the direction the internet is heading, and most issues blamed on it are really misconfigurations in DNS, routing, or an application’s address preference. Reserve a full disable for cases where you have a confirmed, specific reason.

About the Author

Leave a Reply