How to enable or disable IPv6
Topic: Networking basics
Summary
Enable or disable IPv6 on Linux via sysctl (net.ipv6.conf.all.disable_ipv6 and per-interface), netplan, or NetworkManager. Use this when you need to turn off IPv6 for compatibility or security, or to turn it back on after it was disabled. Test with ping6 and ip -6 addr.
Intent: How-to
Quick answer
- Disable globally: sysctl -w net.ipv6.conf.all.disable_ipv6=1; make persistent in /etc/sysctl.d/ (e.g. net.ipv6.conf.all.disable_ipv6 = 1). Reboot or apply with sysctl -p.
- Enable: set disable_ipv6=0 or remove the override; ensure netplan or NM has IPv6 addresses or method auto if you use DHCPv6; ip -6 addr to verify.
- Per-interface: net.ipv6.conf.IFACE.disable_ipv6; disable on one interface only if you want IPv6 on others; some apps may still prefer IPv4 if IPv6 is broken, so test both.
Prerequisites
Steps
-
Disable IPv6 globally (temporary)
sysctl -w net.ipv6.conf.all.disable_ipv6=1; IPv6 addresses disappear from interfaces; no reboot needed but lost on reboot.
-
Disable IPv6 persistently
Create /etc/sysctl.d/99-disable-ipv6.conf with line net.ipv6.conf.all.disable_ipv6 = 1; run sysctl -p /etc/sysctl.d/99-disable-ipv6.conf; or reboot.
-
Enable IPv6 again
Set net.ipv6.conf.all.disable_ipv6=0 or remove the sysctl override file; run sysctl -p; configure IPv6 in netplan (addresses and optionally gateway) or NM (ipv6.method auto or manual); ip -6 addr to confirm.
-
Verify
ip -6 addr (or ip addr | grep inet6); ping6 -c 2 hostname-or-ipv6; if disabled, no inet6 addresses and ping6 fails; if enabled, addresses present and ping6 works when route exists.
Summary
Enable or disable IPv6 globally (or per interface) with sysctl; make it persistent in /etc/sysctl.d/. When enabling, configure addresses and routes in netplan or NetworkManager. Use this when you need to turn IPv6 off for compatibility or turn it on for dual-stack.
Prerequisites
Steps
Step 1: Disable IPv6 globally (temporary)
sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1
IPv6 addresses are removed from interfaces. Change is lost on reboot.
Step 2: Disable IPv6 persistently
Create /etc/sysctl.d/99-disable-ipv6.conf:
net.ipv6.conf.all.disable_ipv6 = 1
Run sudo sysctl -p /etc/sysctl.d/99-disable-ipv6.conf or reboot.
Step 3: Enable IPv6 again
Set net.ipv6.conf.all.disable_ipv6 = 0 or remove the override file; run sysctl -p. In netplan or NM, add IPv6 addresses or set ipv6.method: auto (or manual). Then ip -6 addr should show addresses.
Step 4: Verify
ip -6 addr
ping6 -c 2 2001:4860:4860::8888
If disabled, no inet6 addresses; if enabled, addresses and ping6 work when routing allows.
Verification
- With IPv6 disabled: no inet6 addresses; ping6 fails. With IPv6 enabled: addresses present and ping6 works when the path supports IPv6.
Troubleshooting
IPv6 still present after disable — Ensure net.ipv6.conf.all.disable_ipv6=1 is applied (sysctl -a | grep disable_ipv6); reboot to clear any stale state.
IPv6 not working when enabled — Check addresses and default route (ip -6 route); firewall may block IPv6; some networks do not route IPv6.