Wondering how to disable IPv6 on Ubuntu? In this article I'll describe some of the methods and why you should consider this option; I'll also mention how to enable, or re-enable, IPv6 in case you change your mind.
What is IPv6? Why would you want to disable it? Internet Protocol version 6 (IPv6) is the latest version of the Internet Protocol (IP). The Internet Protocol is a communications protocol that provides an identification and location system for computers on a network and routes communications on the Internet. IPv6 was designed in 1998 to replace the IPv4 protocol. IPv6 is designed to improve security and performance while ensuring that addresses are not exhausted; it can assign unique 128-bit addresses to each device worldwide, while IPv4 only uses 32 bits. Although IPv6 aims to replace IPv4, it still has a long way to go; less than 30% of websites on the Internet support IPv6 (here are Google's statistics), and IPv6 sometimes causes problems for some applications. Due to the fact that IPv6 uses globally (uniquely assigned) routing addresses and the fact that there are (still) Internet Service Providers (ISPs) that do not offer IPv6 support, IPv6 is a feature that is low on the priority list of VPN providers that offer global services, so that they can focus on what is most important to VPN users: security. Not wanting to expose yourself to various threats might be another reason why you might want to disable IPv6 on your system. While IPv6 itself is more secure than IPv4, the risks I'm referring to are of a different nature. If you don't actually use IPv6 and its features, then by enabling IPv6 you'll be vulnerable to various attacks, thus providing hackers with another possible tool to exploit. Likewise, it's not enough to just configure basic network rules; you have to pay the same attention to tweaking the IPv6 configuration as you did for IPv4, which can be quite a hassle (to maintain, too). And with IPv6 comes a different set of questions than IPv4 (many of which can already be found online, given the protocol's age), adding another layer of complexity to your system. It has been observed that disabling IPv6 helps improve WiFi speed in Ubuntu in some cases. Disable IPv6 on Ubuntu [Advanced Users] In this section, I will explain how to disable IPv6 protocol on Ubuntu. Please open the terminal (default shortcut: CTRL+ALT+T) and let’s get started! Note: Most of the commands that follow require root privileges (sudo). warn! If you are a regular Linux desktop user and prefer a stable working system, please steer clear of this tutorial, the following sections are for those who know what they are doing and why they are doing it. 1. Disable IPv6 using sysctl First, you can check whether IPv6 is enabled by executing the following command:
If enabled, you should see an IPv6 address (the name of your network card may be different than in the picture) IPv6 Address Ubuntu IPv6 Address Ubuntu In the tutorial "Restart Network in Ubuntu" (LCTT translation note: In fact, this article does not mention the method of using sysctl...), you have already seen the sysctl command, and we will use it here as well. To disable IPv6, you only need to enter three commands:
Check whether the command is effective:
If the command worked, you should notice that the IPv6 entry has disappeared: IPv6 Disabled Ubuntu However, this method can only temporarily disable IPv6, so the next time the system starts, IPv6 will still be enabled. (LCTT translation note: The temporary disabling here means that the changes made this time are valid until the current shutdown, because the relevant parameters are stored in the memory and the values can be changed, but they will be lost after the memory is powered off; in this sense, the two methods described below are temporary, except that the timing of changing the parameter value is early in the system startup, and it is applied every time the system starts. So how to complete this permanent change? The answer is to disable the relevant functions when compiling the kernel, and then you can only recompile the kernel if you regret it (sad).) One way to make the options persistent is to modify the file /etc/sysctl.conf. Here I use vim to edit the file, but you can use any editor you want. Make sure you have administrator privileges (use sudo): Sysctl Configuration Add the following lines (using the same parameters as before) to the file:
Execute the following command to apply the settings:
If IPv6 is still enabled after the reboot and you want to continue with this method, you must create (with root privileges) the file /etc/rc.local and add the following content:
Next, use the chmod command to change the file permissions to make it executable:
This will cause the system (at boot time) to read kernel parameters from the previously edited sysctl configuration file. 2. Disable IPv6 using GRUB Another way is to configure GRUB, which will pass parameters to the kernel when the system boots. To do this, you need to edit the file /etc/default/grub (make sure you have administrator privileges). GRUB Configuration Now you need to modify the two lines starting with GRUB_CMDLINE_LINUX_DEFAULT and GRUB_CMDLINE_LINUX in the file to disable IPv6 at boot time:
(LCTT translation note: This refers to adding the parameter ipv6.disable=1 in the above two lines. The default values of these two lines may be different in different systems.) Save the file and execute the command:
(LCTT translation note: This command is used to update the GRUB configuration file. In systems without the update-grub command, you need to use sudo grub-mkconfig -o /boot/grub/grub.cfg ) The setting will take effect after reboot. Re-enabling IPv6 on Ubuntu To re-enable IPv6, you need to undo all previous changes. However, if you just want to temporarily enable IPv6, you can execute the following command:
Otherwise, if you want to keep it enabled, check whether /etc/sysctl.conf has been modified. You can delete the previously added parts, or change them to the following values (the two methods are equivalent):
Then apply the settings (optional):
(LCTT translation note: The optional meaning here may be that if IPv6 was temporarily enabled before, there is no need to reload the configuration file) You should now see the IPv6 address again: IPv6 Reenabled in Ubuntu Alternatively, you can also delete the previously created file /etc/rc.local (optional):
If you modified the file /etc/default/grub, go back and delete the parameters you added:
Then update the GRUB configuration file:
end In this article, I've covered how to disable IPv6 on Linux and briefly covered what IPv6 is and why you might want to disable it. |
<<: Zhang Ping, academician of the Chinese Academy of Engineering: 6G faces dimensional disaster
>>: What to do if the Wi-Fi signal at home is not good? Here are 4 tips
While some of the larger telecom companies, such ...
Ftpit is a foreign hosting company founded in 201...
Recently, the three major operators released thei...
In 2002, digital communication redefined the tele...
In the vast information system of the Internet, D...
When we start learning network programming, we fi...
Justhost has been expanding since October, with n...
Exploring new paths for industrial development [[...
I received an email from Virtono two days ago. Th...
[51CTO.com original article] On May 18-19, 2018, ...
Another favorable policy for 5G has emerged. Rece...
The IP address and MAC address can be compared to...
We know that the CN2 GIA line is one of the relat...
Gartner, the world's leading information tech...
Globally, more than 1 billion people, or 15% of t...