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.
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:
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:
#!/bin/bash # /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).
Need More Ubuntu Training?
Checkout this Ubuntu Fundamentals course from Pluralsight. Pluralsight has great training at a great price. Free 10-day trial.
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!