Method 1
Edit file /etc/sysctl.conf,
vi /etc/sysctl.conf
Add the following lines:
net.ipv6.conf.all.disable_ipv6 = 1 net.ipv6.conf.default.disable_ipv6 = 1
If you want to disable IPV6 for particular network card, for example enp0s3, add the following entry.
net.ipv6.conf.enp0s3.disable_ipv6 = 1
Save and exit the file.
Execute the following command to reflect the changes.
sysctl -p
Method 2:
To IPv6 disable in the running system, enter the following commands one by one:
echo 1 > /proc/sys/net/ipv6/conf/all/disable_ipv6 echo 1 > /proc/sys/net/ipv6/conf/default/disable_ipv6
or,
sysctl -w net.ipv6.conf.all.disable_ipv6=1 sysctl -w net.ipv6.conf.default.disable_ipv6=1
That’s it. Now IPv6 has been disabled.