Recently I was asked to disable IPv6 on an Ubuntu Linux server. Here are the steps:
- Test if IPv6 is enabled:
cat /proc/sys/net/ipv6/conf/all/disable_ipv6
0 means it’s enabled and 1 – disabled.
- To disable IPv6, add the following lines to /etc/sysctl.conf:
#disable ipv6
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1
- Run the following command:
echo “#disable ipv6” | sudo tee -a /etc/sysctl.conf
echo “net.ipv6.conf.all.disable_ipv6 = 1” | sudo tee -a /etc/sysctl.conf
echo “net.ipv6.conf.default.disable_ipv6 = 1” | sudo tee -a /etc/sysctl.conf
echo “net.ipv6.conf.lo.disable_ipv6 = 1” | sudo tee -a /etc/sysctl.conf
- You will need to reboot the network interfaces (sysctl):
sudo sysctl -p
- Validate:
cat /proc/sys/net/ipv6/conf/all/disable_ipv6
0 means it’s enabled and 1 – disabled.