If you need to disable IPv6 on Ubuntu Server, or you searched specifically for ubuntu disable ipv6, the cleanest way is to decide first whether you want a temporary runtime change or a persistent change that survives reboots. For most VPS users, the right order is simple: verify whether IPv6 is actually enabled, disable it temporarily with sysctl if you are testing, and then make it persistent only if you are sure the server and network do not need IPv6.
That order matters because turning IPv6 off can absolutely fix a real problem — for example, broken upstream routing, applications that bind badly on dual-stack hosts, or internal compliance rules that require IPv4-only operation. But it can also create new problems if your provider, DNS, firewall policy, or package mirrors expect IPv6 to be available.
This guide shows the safe step-by-step path, the commands you actually need, and how to roll the change back if you change your mind.
Quick answer
There are two common ways to disable IPv6 on Ubuntu:
-
Temporary / runtime only: use
sysctland change the kernel values immediately. -
Persistent across reboots: add the kernel parameter
ipv6.disable=1, rebuild GRUB, and reboot.
For a VPS, I usually recommend this sequence:
- Check whether IPv6 is currently active.
- Test the runtime
sysctlchange first. - If that solves the issue and nothing breaks, make it persistent.
- Verify after reboot.
That gives you the smallest blast radius before you commit the change permanently.
Before you disable IPv6, make sure you really need to
Disabling IPv6 is not a generic performance tweak. It is an operational choice.
Good reasons to do it include:
- your provider or upstream network has broken IPv6 routing
- an application prefers AAAA resolution but fails when the remote path is unhealthy
- your environment is standardized on IPv4 only
- a hardening or compliance baseline explicitly calls for IPv6 to be disabled
Bad reasons include:
- "I heard it makes Ubuntu faster"
- "I am not using it today so I should turn it off"
- "I want fewer protocols running" without first checking whether any service depends on dual-stack networking
In practice, a modern Linux VPS is usually happy with IPv6 enabled. Only disable it when you have a specific networking, application, or policy reason.
Step 1: check the current IPv6 status
Start by checking the current kernel state:
sysctl net.ipv6.conf.all.disable_ipv6
sysctl net.ipv6.conf.default.disable_ipv6
If both values return 0, IPv6 is enabled. In our Ubuntu 24.04 verification environment, both values were 0 by default:
-
net.ipv6.conf.all.disable_ipv6 = 0 -
net.ipv6.conf.default.disable_ipv6 = 0
If you want an additional quick visual check, you can also inspect whether the server currently has IPv6 addresses assigned:
ip -6 addr show
That does not disable anything — it just shows the current state so you know what you are changing.
Step 2: disable IPv6 temporarily with sysctl
If you want to test the effect without making a reboot-time change yet, set the runtime values directly:
sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1
sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1
What these do:
-
all.disable_ipv6=1tells the kernel to disable IPv6 globally -
default.disable_ipv6=1makes newly created interfaces inherit the disabled state
This is the safest first move on a VPS because it is immediate and easy to reverse. If the server loses connectivity in an unexpected way, you can usually reverse the values just as quickly.
How to verify the runtime change
Run the same status commands again:
sysctl net.ipv6.conf.all.disable_ipv6
sysctl net.ipv6.conf.default.disable_ipv6
You want both values to come back as 1.
If you also ran ip -6 addr show before the change, compare the before/after output after restarting the affected service or interface. On a headless VPS, the sysctl values are usually the cleaner verification point.
Step 3: make the change persistent across reboots
If the runtime change solves the problem and you want Ubuntu to keep IPv6 disabled after a reboot, the most reliable server-side method is to set the kernel parameter ipv6.disable=1 and rebuild the boot configuration.
The change looks like this conceptually:
- find the
GRUB_CMDLINE_LINUXline in your GRUB configuration - append
ipv6.disable=1 - rebuild GRUB
- reboot the server
The command you run after editing the kernel command line is:
sudo update-grub
Then reboot:
sudo reboot
Why I prefer the kernel-parameter route for VPS tutorials: it is explicit, it is applied early in the boot process, and it is easier to reason about when you come back to the server six months later.
Step 4: verify IPv6 is disabled after reboot
Once the server is back up, check the same runtime values again:
sysctl net.ipv6.conf.all.disable_ipv6
sysctl net.ipv6.conf.default.disable_ipv6
If the persistent configuration is working, they should still return 1.
You can also do a quick address check:
ip -6 addr show
On a VPS that is fully running IPv4-only after the reboot, you should no longer see normal active IPv6 interface addressing for the workloads you disabled.