How to Disable IPv6 on Ubuntu 16.04 and Ubuntu 17.04

This tutorial is going to show you how to disable IPv6 on Ubuntu 16.04 and Ubuntu 17.04. Why do you want to disable IPv6? Although IPv6 is the future, but right now many systems and applications still rely on IPv4 and may not work well with IPv6.

For example, if a repository supports IPv6, then APT package manager will connect to that repository via IPv6 regardless of whether or not your ISP supports IPv6, as shown in the screenshot below.

disable ipv6 ubuntu

Disable IPv6 in APT

Sometimes, you need to disable IPv6 in the APT package manage only and other program can continue use IPv6 if needed. To disable IPv6 in APT, run the following command to create a configuration file for APT.

sudo nano /etc/apt/apt.conf.d/99force-ipv4

Copy and paste the following line into the file.

Acquire::ForceIPv4 "true";

Save and close the file. From now on, APT will use IPv4 only.

Disable IPv6 on Ubuntu Altogether

If you want to completely disable IPv6 on your Ubuntu Linux system, then you need to make some changes to Linux kernel parameter.

Edit the 99-sysctl.conf file.

sudo nano /etc/sysctl.d/99-sysctl.conf

Copy and paste the following 3 lines at the bottom of the file.

net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1

Save and close the file. Then execute the following command to load the above changes.

sudo sysctl -p

Now run the following command. You should see 1, which means IPv6 has been successfully disabled.

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

disable ipv6 on ubuntu 16.04

Parameters defined in 99-sysctl.conf file is preserved across reboot, so IPv6 won’t be enabled next time you boot up Ubuntu unless you manually re-enable it.

To re-enable IPv6 on Ubuntu, simply remove those 3 lines in 99-sysctl.conf file and run sudo sysctl -p command to load the changes.

That’s it! I hope this tutorial helped you disable IPv6 on Ubuntu desktop and server.

Rate this tutorial
[Total: 5 Average: 3.2]