Some cloud servers have IPv6 enabled by default, but certain use cases do not require it. Here are two methods to disable it.
1. Permanently modify /proc via /etc/sysctl.conf
# Disable IPv6 on all interfaces system-wide
net.ipv6.conf.all.disable_ipv6 = 1
# Disable IPv6 on a specific interface (e.g., eth0, lo)
net.ipv6.conf.lo.disable_ipv6 = 1
net.ipv6.conf.eth0.disable_ipv6 = 1
After making these changes in /etc/sysctl.conf, run the following command to apply them:
2. Permanently disable IPv6 via kernel boot parameter
Open /etc/default/grub with a text editor and add "ipv6.disable=1" to the GRUB_CMDLINE_LINUX variable.
The "xxxxx" above represents any existing kernel parameters — simply append "ipv6.disable=1" after them.
Finally, don't forget to save the changes to GRUB/GRUB2:
On Debian, Ubuntu, or Linux Mint systems:
On Fedora, CentOS, or RHEL systems:
The changes will take effect after rebooting the server.
1. Permanently modify /proc via /etc/sysctl.conf
# Disable IPv6 on all interfaces system-wide
net.ipv6.conf.all.disable_ipv6 = 1
# Disable IPv6 on a specific interface (e.g., eth0, lo)
net.ipv6.conf.lo.disable_ipv6 = 1
net.ipv6.conf.eth0.disable_ipv6 = 1
After making these changes in /etc/sysctl.conf, run the following command to apply them:
| $ sudo sysctl -p /etc/sysctl.conf |
2. Permanently disable IPv6 via kernel boot parameter
Open /etc/default/grub with a text editor and add "ipv6.disable=1" to the GRUB_CMDLINE_LINUX variable.
| $ sudo vi /etc/default/grub GRUB_CMDLINE_LINUX="xxxxx ipv6.disable=1" |
The "xxxxx" above represents any existing kernel parameters — simply append "ipv6.disable=1" after them.
Finally, don't forget to save the changes to GRUB/GRUB2:
On Debian, Ubuntu, or Linux Mint systems:
| $ sudo update-grub |
On Fedora, CentOS, or RHEL systems:
| $ sudo grub2-mkconfig -o /boot/grub2/grub.cfg |
The changes will take effect after rebooting the server.
