As time moves forward the servers that support IPv6 grow. Currently, estimates put global adoption somewhere around 30% to 50%. That said like anything else it can be misconfigured, not supported, etc. on different networks.
In this post, we will cover how to disable ipv6 on your Ubuntu machine, for those who have run into a situation where you’re considering disabling IPv6.
Before we get into how to disable ipv6 on Ubuntu, let’s look at what IPv6 is, how to check if your system has an ipv6 address, and why you may want/need to disable it.
What Is IPv6?
To access the internet you either use IPv6 or IPv4. These are the very protocols that allow devices to connect across such great distances. So what is the difference between these two protocols?
IPv6 builds on lessons learned from IPv4, the biggest of these being not enough globally unique addresses, NAT, and more options for address configuration compared to IPv4.
Does My Ubuntu System Have An IPv6 Address
This one-liner command checks your default network interface for IPv6 addresses excluding loop-back addresses.
ip -6 addr show $(ip route show default | awk '/default/ {print $5}') | grep -oP '(?<=inet6\s)(?!fe80)[\da-f:]+'
If you received output from this command it means the system has one or more IPv6 addresses on the primary interface, although this does not guarantee full IPv6 connectivity.
Why Would You Want To Disable IPv6?
Some reasons you may want to disable ipv6 are listed below.
- If the network you connected to doesn’t support ipv6.
- If the network is misconfigured and has a broken ipv6 implication.
- Ipv6 isn’t needed for the server’s specific use case.
Disable IPv6 On Which Level
There are a few different levels at which the IPv6 protocol can be disabled, this includes:
- Application level
- Applications Like your package manager or web browser
- Network Manager Level
- This means it can be selectively applied to specific networks
- Kernel Level
- Although this is the most restrictive this method will force disable ipv6 across the whole system
Application Level
Don’t want to disable ipv6 everywhere, how about configuring individual applications? The two most common applications I have seen affected by this are Package managers and web browsers.
Apt Package Manager
For the apt package manager, you can disable IPv6 by forcing it to use IPv4 instead using the following command:
echo 'Acquire::ForceIPv4 "true";' >> /etc/apt/apt.conf.d/force-ipv4
Web Browsers
With chromium/chrome-based browsers the way this is typically configured is by going to the browser_name://flags for chrome this would be chrome://flags and Vivaldi would be vivaldi://flags.
With Firefox, you go about:config to make those changes.
Note: for full directions please look up software-specific documentation
Network Manager Level
Typically, you will run into this more with systems that are automatically configured like desktops rather than servers.
For Ubuntu Desktop
- Open settings by either using a shortcut in the status bar or tapping the meta key and start typing settings.
- For a wired connection look for Network or a wireless connection look for Wi-Fi.
- From there see the network you’re currently connected to, and click the gear next to that network.
- You will see an IPv6 tab in the window that opens, click on it.
- There you will see Disable under IPv6 Method.
- Select it click apply and reconnect to the network to finish applying the change.
For Ubuntu Server
For Ubuntu Server as long as you aren’t specifying IPv6 specifically, it shouldn’t be configured. This means all you need to do to disable IPv6 on a Ubuntu server is remove any IPv6-specific configuration from the network configuration files.
Kernel Level
The most universal way to disable ipv6 from the command line is though the sysctl configuration file as this sets kernel parameters directly. (Be aware this requires root privileges)
The following lines create the needed configuration.
sudo echo "net.ipv6.conf.all.disable_ipv6 = 1" >> /etc/sysctl.conf
sudo echo "net.ipv6.conf.default.disable_ipv6 = 1" >> /etc/sysctl.conf
sudo echo "net.ipv6.conf.lo.disable_ipv6 = 1" >> /etc/sysctl.conf
The following command reloads the sysctl configuration file and applies the parameters without a reboot.
sudo sysctl -p
How Do I Confirm IPv6 Is Disabled?
If you would like to check after to confirm IPv6 is disabled here are a few ways to do so.
You can use the IP command to see if there are any v6 addresses.
ip -6 addr show
Another way is to cat this path, 0 means it is disabled.
cat /proc/sys/net/ipv6/conf/all/disable_ipv6
Conclusion
Although IPv6 is growing in popularity has a few concepts that are different from its predecessor. In this post, we have discussed what is, how to check if your system has an address, and what you might want to disable it on your Ubuntu Linux system. Starting at the application level, to the network manager, and ending at disabling it via the kernel.
Embracing a lifelong passion for technology since childhood, CJ delved into the intricate workings of systems, captivated by the desire to understand the unknown. This innate curiosity led to his discovery of Linux, a revelation that resonated deeply. With more than 7 years of on the job experience, he’s honed his technical skills as a Geek and Senior Linux Systems Administrator.
Leave a Reply