Disable IPv6 on Linux with sysctl -w net.ipv6.conf.all.disable_ipv6=1 (runtime) plus a line in /etc/sysctl.d/ (persistence). The harder cases (where IPv6 is still in use by some processes or by the loopback) need ipv6.disable=1 on the GRUB kernel command line. The team that has IPv4-only on a server and IPv6 breaking something uses the sysctl path; the team that has a clean IPv4-only box uses the GRUB path.
Table of contents
- When to disable IPv6
- The sysctl method (the right first try)
- The GRUB method (the harder cases)
- Checking what is using IPv6
- Rolling back
- How this fits the rest of the stack
- FAQ
When to disable IPv6
Most servers should leave IPv6 on. The right time to disable:
-
The server is on an IPv4-only network and IPv6 link-local addresses are causing noise in logs.
-
A specific service is binding to IPv6 and breaking an IPv4-only config (common with some old daemons).
-
Compliance or policy requires IPv4-only.
The team that disables IPv6 to “fix a problem” without understanding the cause usually creates more problems - some services use IPv6 for inter-process communication even on IPv4-only servers.
The sysctl method (the right first try)
Runtime:
sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1
sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1
Persistence:
echo "net.ipv6.conf.all.disable_ipv6 = 1" | sudo tee /etc/sysctl.d/90-disable-ipv6.conf
echo "net.ipv6.conf.default.disable_ipv6 = 1" | sudo tee -a /etc/sysctl.d/90-disable-ipv6.conf
sudo sysctl --system
Verify: ip -6 addr should show no IPv6 addresses (other than the loopback if it’s still bound).
The GRUB method (the harder cases)
For when sysctl alone is not enough (some services still bind to IPv6):
sudo nano /etc/default/grub
Add ipv6.disable=1 to GRUB_CMDLINE_LINUX:
GRUB_CMDLINE_LINUX="ipv6.disable=1"
Update GRUB and reboot:
sudo update-grub
sudo reboot
After this, the kernel itself does not initialize IPv6 at all. The ipv6.disable=1 parameter disables the IPv6 stack at boot, before any userspace process can bind to it.
The team that uses this for a clean IPv4-only box has the cleanest result. The team that does not reboot to test (or uses a VM without GRUB) misses whether it actually worked.
Checking what is using IPv6
Before disabling, see what is bound to IPv6:
ss -tulnp | grep -i ipv6
netstat -tulnp | grep -i ipv6
The team that sees sshd, nginx, or other services listening on :: (IPv6 all-interfaces) is the team that knows what will need to be restarted after the disable.
The team that wants the most verbose output: lsof -i6 (if lsof is installed).
Rolling back
If the sysctl path was used, remove the conf file and re-run sysctl:
sudo rm /etc/sysctl.d/90-disable-ipv6.conf
sudo sysctl --system
If the GRUB path was used, remove ipv6.disable=1 from /etc/default/grub, run update-grub, and reboot.
The team that needs IPv6 back fast does the sysctl rollback (no reboot). The team that used GRUB has to reboot.
FAQ
Is it safe to disable IPv6?
Yes, if you understand the consequences. Some services use IPv6 for loopback (apt, postfix on some distros). The team that disables IPv6 and then sees apt break on localhost is hitting the loopback case - the fix is to keep IPv6 on the loopback (net.ipv6.conf.lo.disable_ipv6=0) while disabling it on physical interfaces.
Will disabling IPv6 break my server’s connectivity?
If the server only has IPv4 connectivity (no IPv6 addresses assigned, no IPv6 routes), no. If the server has an IPv6 address and the disable breaks the IPv6 stack, then yes - any IPv6-only traffic to/from the server will fail. The team that uses ip -6 addr to check before disabling is doing it right.
What is the difference between sysctl and GRUB methods?
sysctl disables IPv6 at runtime (and persists via the conf file). The kernel module is loaded but disabled. GRUB’s ipv6.disable=1 disables IPv6 at the kernel level before the module loads - cleaner, but requires a reboot.
Can I disable IPv6 per interface?
Yes. sysctl -w net.ipv6.conf.eth0.disable_ipv6=1 disables IPv6 on eth0 only. The team that wants IPv6 on the loopback but not on external interfaces uses this pattern.
Is IPv4 actually faster than IPv6?
Not in any inherent sense - the protocols have similar overhead. IPv6 has theoretical advantages (no NAT, simpler header). Real-world speed depends on the path, the ISP, and the application’s behavior. The team that benchmarks finds that on most paths, IPv4 and IPv6 are within 5-10% of each other.
How this fits the rest of the stack
For a sense of what the full project costs before it commits, the RunxBuild hosting calculator shows the line items together. The API, the database, the storage, the worker, the bandwidth - each one is a separate number, and the team’s mental model for the platform is the sum of those numbers.
Useful related references: