First, check whether IPv6 protocol support is enabled or disabled (0 – on, 1 – off):
cat /proc/sys/net/ipv6/conf/all/disable_ipv6
cat /proc/sys/net/ipv6/conf/eth1/disable_ipv6
To temporarily disable, run the following commands:
sudo sysctl net.ipv6.conf.all.disable_ipv6=1
sudo sysctl net.ipv6.conf.default.disable_ipv6=1
Here is an example of disabling IPv6 on a specific interface:
sudo sysctl net.ipv6.conf.lo.disable_ipv6=1
sudo sysctl net.ipv6.conf.eth0.disable_ipv6=1
To keep IPv6 disabled after a server restart, open the /etc/sysctl.conf configuration file in a text editor and enter:
net.ipv6.conf.all.disable_ipv6=1
net.ipv6.conf.default.disable_ipv6=1
Apply the changes:
sudo sysctl -p
Let’s see if there are ipv6 addresses on the network interfaces:
ifconfig | grep inet6
ip addr show | grep net6
See also my article:
Lowering the priority of IPv6