How to disable IPv6 on Linux
Disabling IPv6 temporarily
Run the following command to disable IPv6 temporarily. This will be reset after a reboot.:
disable_ipv6.sh
sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1
sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1
sudo sysctl -w net.ipv6.conf.lo.disable_ipv6=1Re-enable IPv6
To re-enable IPv6, run the following command:
enable_ipv6.sh
sudo sysctl -w net.ipv6.conf.all.disable_ipv6=0
sudo sysctl -w net.ipv6.conf.default.disable_ipv6=0
sudo sysctl -w net.ipv6.conf.lo.disable_ipv6=0Disabling IPv6 permanently
To disable IPv6 permanently, you need to modify the sysctl configuration file. Open the file /etc/sysctl.conf with your preferred text editor (e.g., nano, vim):
edit_sysctl.conf.sh
sudo nano /etc/sysctl.confAdd the following lines at the end of the file:
sysctl.conf
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1Check out similar posts by category:
Linux
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow