How to disable IPv6 on Linux (Old Version Kernels)
Disabling IPv6 on Linux
IPv6 is enabled by default on most Linux distributions. While IPv6adoption has grown, many environments still rely primarily on IPv4, and disabling IPv6 can simplify networking configurations or resolve compatibility issues.
Quick Method: Disable via modprobe
The most straightforward approach is to prevent the IPv6 kernel module from loading:
echo "options ipv6 disable=1" >> /etc/modprobe.d/disable-ipv6.conf
This adds a configuration line telling the kernel not to load the IPv6 module at boot. After reboot, IPv6 will be disabled.
Verify the change took effect:
cat /proc/sys/net/ipv6/conf/all/disable_ipv6
A value of 1 confirms IPv6 is disabled; 0 means it’s enabled.
Disable IPv6 Without Reboot
If you need to disable IPv6 immediately without rebooting:
sysctl -w net.ipv6.conf.all.disable_ipv6=1
sysctl -w net.ipv6.conf.default.disable_ipv6=1
Verify:
ip a
IPv6 addresses (those starting with fe80:: or 2001:) should no longer appear.
To make these settings persistent across reboots, add them to /etc/sysctl.conf or create a file in /etc/sysctl.d/:
echo "net.ipv6.conf.all.disable_ipv6 = 1" | sudo tee -a /etc/sysctl.d/99-disable-ipv6.conf
echo "net.ipv6.conf.default.disable_ipv6 = 1" | sudo tee -a /etc/sysctl.d/99-disable-ipv6.conf
sudo sysctl -p /etc/sysctl.d/99-disable-ipv6.conf
Disable IPv6 for Specific Interfaces
To disable IPv6 on a specific interface instead of system-wide:
sysctl -w net.ipv6.conf.eth0.disable_ipv6=1
Replace eth0 with your interface name. Make it persistent by adding to /etc/sysctl.d/99-disable-ipv6.conf:
net.ipv6.conf.eth0.disable_ipv6 = 1
Using netplan (Ubuntu/Debian with netplan)
On systems using netplan for network configuration, you can disable IPv6 in the YAML config:
network:
version: 2
ethernets:
eth0:
dhcp4: true
dhcp6: false
ipv6: false
Apply the configuration:
sudo netplan apply
Using NetworkManager
With NetworkManager, disable IPv6 via the nmcli command:
nmcli con mod "Connection Name" ipv6.method ignore
nmcli con up "Connection Name"
Or edit the connection file directly at /etc/NetworkManager/conf.d/ if needed.
Verify IPv6 is Disabled
Check both kernel parameters and active connections:
cat /proc/sys/net/ipv6/conf/all/disable_ipv6
ip -6 addr show
ss -tunap | grep '::'
All IPv6 listening sockets and addresses should be absent.
Re-enabling IPv6
To reverse the changes:
sysctl -w net.ipv6.conf.all.disable_ipv6=0
sysctl -w net.ipv6.conf.default.disable_ipv6=0
Or remove the configuration files and reboot:
sudo rm /etc/modprobe.d/disable-ipv6.conf /etc/sysctl.d/99-disable-ipv6.conf
sudo reboot
Important Considerations
Some services and applications expect IPv6 to be available, even if not actively used. Disabling IPv6 globally can cause:
- Increased DNS lookup times if the system tries IPv6 before falling back to IPv4
- Issues with services binding to
::1(IPv6 localhost) - Potential problems with containerized applications or systemd services
Test thoroughly in non-production environments before applying globally.
3 Comments