Linux: Disable IPv6 on Linux-based operating systems

Debian / Ubuntu (Linux Mint etc.) / all debian-based Operating Systems
sudo nano /etc/sysctl.conf

Add this lines (to re-enable IPv6 simply remove them)

net.ipv6.conf.all.disable_ipv6=1
net.ipv6.conf.default.disable_ipv6=1
net.ipv6.conf.lo.disable_ipv6=1

#since 18.04 you also need to disable IPv6 per Interface by adding:
net.ipv6.conf.<ifname>.disable_ipv6=1

e.g.:
net.ipv6.conf.wlo1.disable_ipv6=1
net.ipv6.conf.enp4s0.disable_ipv6=1

Reload your configuration or reboot

sudo sysctl -p
CentOS / RedHat
sysctl -w net.ipv6.conf.all.disable_ipv6=1
sysctl -w net.ipv6.conf.default.disable_ipv6=1

To re-enable IPv6 run the following commands

sysctl -w net.ipv6.conf.all.disable_ipv6=0
sysctl -w net.ipv6.conf.default.disable_ipv6=0