Disabling IPv6 on Linux

This won’t work on Arch Linux, see Deprecation of /etc/sysctl.conf.

On Arch Linux, use /etc/sysctl.d/99-disable-ipv6.conf instead of /etc/sysctl.conf.

Sudo method:

echo "net.ipv6.conf.all.disable_ipv6=1" | sudo tee -a /etc/sysctl.conf
sudo sysctl -p

Root method:

echo "net.ipv6.conf.all.disable_ipv6=1" >> /etc/sysctl.conf
sysctl -p

Remember to replace IPv6=yes with IPv6=no in /etc/default/ufw.

After that, sudo ufw disable && sudo ufw enable or reboot.

Disable temporarily for single interface

sudo sysctl net.ipv6.conf.ens3.disable_ipv6=1