How to Disable IPv6 on Ubuntu

This tutorial is going to show you how to disable IPv6 on Ubuntu. 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: 106 Average: 4.5]

11 Responses to “How to Disable IPv6 on Ubuntu

  • Psalm56Eleven
    3 years ago

    Thank you!

  • StygianAgenda
    3 years 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.

  • Roman Yarovoy
    3 years ago

    That’s working well, thanks!

    3 years ago

    Thanks !

  • seweryn adam
    3 years 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 years 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.

    • “Fix the router” assumes that you have control over the router, of course, and even if you can, it only fixes the problem for *one* network. It’s much better to fix the problem once and for all by definitely turning off IPv6. Then you know you are protected no matter which network you are connecting to.

  • There is a better way. The method described above seems to not work in 18.04 any more, and even when it does work, it leaves some traces of IPv6 support that can cause problems. The better way is to modify the kernel boot command line.

    Open /etc/default/grub and edit the line that starts with GRUB_CMDLINE_LINUX_DEFAULT. Add the entry “ipv6.disable=1” to the arguments that are already there. Then run sudo update-grub, and reboot.

    Presto – no more worrying that connecting to a sketchy airport WiFi might expose you with a public IP address.

  • Test guy
    2 years ago

    Works for me in 19.04.

  • Thanks for the tut, works fine just outofthebox 🙂

  • Yohans Bastian
    7 months ago

    Thanks for the guide. All worked except on my Ubuntu 18.04 LTS the command “sudo sysctl -p” didn’t reload the variables. Instead I used the following command to update the IPV6 related variables:
    service procps reload

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.
  • Please use the community ( for questions unrelated to this article.
  • I don't have time to answer every question. Making a donation would incentivize me to spend more time answering questions.

The maximum upload file size: 2 MB. You can upload: image.