Disable IPv6 on Ubuntu 18.04

Disable IPv6 on Ubuntu 18.04

(Last Updated On: July 25, 2019)

In this post we will walk through how to disable IPv6 on Ubuntu 18.04.  IPv6 can cause problems with different applications like DNS resolution.


Normally you would never want to disable IPv6 on your system.  There are many great reasons to keep it.  Disabling IPv6 will only hide the real issue at hand.  That being said if you still want to disable it then please follow along.

Video Walkthrough

How to tell if you have IPv6 enabled

IPv6 is enabled by default on Ubuntu but to verify simply run an ‘ip a’ like below:

As you can see there are lines for each interface that begin with inet6.  This shows that IPv6 is enabled.

How to disable IPv6 on Ubuntu 18.04?

IPv6 can be disabled easily on Ubuntu 18.04 by following these simple steps:

1. Edit   /etc/sysctl.d/99-sysctl.conf

#  vim /etc/sysctl.d/99-sysctl.conf

2. Add the following lines to the end of the file

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

3. Save and exit

[ESC] then :wq [ENTER]

4. Reload the values

# sysctl -p

5. Validate that IPv6 is disabled

# ip a

You should see that there is no longer any inet6 lines:

disable ipv6 on ubuntu 18.04

Surviving a Reboot

It turns that after these settings are configured, after a reboot they would disappear and IPv6 would be enabled again.

After some research there appears to be a bug in Ubuntu that prevents the sysctl settings from being loaded after a reboot.

The workaround for this is to create a new file /etc/rc.local and add these contents:

# /etc/rc.local

# Load kernel variables from /etc/sysctl.d
/etc/init.d/procps restart

exit 0

Save and exit.

Next we need to make it executable.

chmod 755 /etc/rc.local

I verified that this workaround works for Kubuntu 18.04 as well.

IPv6 will still be disabled on a reboot because we made changes to the sysctl.conf file. ( And the workaround from above).

Click here for more great Ubuntu articles on AdminTome Blog.

Need More Ubuntu Training?

Checkout this Ubuntu Fundamentals course from Pluralsight.  Pluralsight has great training at a great price.  Free 10-day trial.

Start your Free Trial today!


I hope you have enjoyed this article, if so please leave a comment below.  For more articles, please signup for the AdminTome Blog below.  Also please feel free to share the article to your friends using the buttons to the left.  Thanks again for reading this post.

If you enjoyed this post, please consider donating to AdminTome Blog below. Thanks again for reading!

6 thoughts on “Disable IPv6 on Ubuntu 18.04”

  1. no need to alter the sysctl.conf

    sudo vi /etc/default/grub

    sudo update-grub
    sudo reboot

    thats it, good bye ipv6 and hello ip4

  2. “Normally you would never want to disable IPv6 on your system”

    Crap. On an internal network with less than, oh, say, 4 billion devices, there’s no good reason to use IP6. It adds waaaaaay too much complexity and is totally unnecessary, plus if you’re running services that are listening on both 4 and 6, you’re opening up to extra attacks (possibly). It should be disabled by default. Outside of ISPs and world-wide corporate infrastructures, there’s no need for IP6 at all.

  3. Really Phil?

    What’s it like to be living in the past, and/or with your head in the stand pretending that IPv4 exhaustion isn’t a thing.

  4. Phil is spot on. On a local private network (sitting behind an IPv4 firewall using NAT), there is no such thing as IPv4 exhaustion. Adding IPv6 to such a network exposes it to routes that can bypass the firewall in ways that are still being understood. It is a very real security risk. He didn’t say there was no use for IPv6, or that IPv6 isn’t needed on the Internet. He said there are real valid reasons for disabling it on internal networks, and he is right.

Leave a Comment

you're currently offline