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: 102 Average: 4.1]

6 Responses to “How to Disable IPv6 on Ubuntu 16.04 and Ubuntu 17.04

  • Psalm56Eleven
    4 months ago

    Thank you!

  • Roman Yarovoy
    4 months ago

    That’s working well, thanks!

  • StygianAgenda
    4 months ago

    Many thanks!

    I’d just recently setup ‘Graylog’ as sort of a light SIEM solution for my lab network, and wanted to eliminate all internal IPv6 chatter. This cleared it right up.

    Also, it worked across Ubuntu 14.04 and Debian 8 (Jessie) and Debian 9 (stretch), aside from Ubuntu 16.04.3.

  • UFOHUNTERORGUK
    4 months ago

    Thanks !

  • seweryn adam
    4 months ago

    For those who didn’t work suggest use also those command modyfiyng it, according to your interface name, repleace enp0s25 with your interface name:
    # sudo ip addr flush enp0s25
    # sudo systemctl restart networking.service

  • Anders J
    3 months ago

    No real need to disable IPv6, really.
    If you don’t have a IPv6 router in the LAN, your computer will not use IPv6.
    If you do have a IPv6 router in the LAN, and it doesn’t work, then fix the problem, not the symptom. Fix the router. And by the way, IPv6 are faster then IPv4.

Leave a Comment

  • Comments with links are moderated by admin before published.
  • Your email address will not be published.
  • Use <pre> ... </pre> HTML tag to quote the output from your terminal/console.
  • * Some of my previous answers are lost after I uninstalled Disqus comment system from my website. I try to recover those answers whenever I can.