Command line

On a Red Hat-based system:

As root

To Disable IPV6

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

To enable IPv6:

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

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

On a Debian-based machine:

Edit /etc/sysctl.conf file

sudo nano /etc/sysctl.conf

Add the following at the bottom of the file:

net.ipv6.conf.all.disable_ipv6 = 1

net.ipv6.conf.default.disable_ipv6 = 1

net.ipv6.conf.lo.disable_ipv6 = 1

Save and close the file.

Reboot the machine.

To re-enable IPv6, remove the above lines from /etc/sysctl.conf and reboot the machine.