Disable IPv6 in Ubuntu Linux

Recently I was asked to disable IPv6 on an Ubuntu Linux server. Here are the steps:

  1. Test if IPv6 is enabled:

cat /proc/sys/net/ipv6/conf/all/disable_ipv6

0 means it’s enabled and 1 – disabled.

  1. 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

  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

  1. You will need to reboot the network interfaces (sysctl):

sudo sysctl -p

  1. Validate:

cat /proc/sys/net/ipv6/conf/all/disable_ipv6

0 means it’s enabled and 1 – disabled.

Leave a Reply