Execute the following command to reflect the changes.
sysctl -p

To re-enable IPv6, remove the above lines from /etc/sysctl.conf and reboot the machine.
Method 2:
1. To disable IPv6 in a running system, enter the following commands one by one:
sysctl -w net.ipv6.conf.all.disable_ipv6=1
sysctl -w net.ipv6.conf.default.disable_ipv6=1

OR
echo 1 > /proc/sys/net/ipv6/conf/all/disable_ipv6
echo 1 > /proc/sys/net/ipv6/conf/default/disable_ipv6

2. To enable IPv6 on a running system, enter the following commands one by one:
sysctl -w net.ipv6.conf.all.disable_ipv6=0
sysctl -w net.ipv6.conf.default.disable_ipv6=0

OR
echo 0 > /proc/sys/net/ipv6/conf/all/disable_ipv6
echo 0 > /proc/sys/net/ipv6/conf/default/disable_ipv6
