Configuring Ubuntu IPV6: How to Enable and Disable IPv6 on Ubuntu

Do you know what IPv6 is? If not, IPv6, the latest Internet Protocol (IP) version since 1998, is a communication protocol directing data across the Internet, providing machines with identity and location. It was designed to replace the IPv4 protocol. 

Furthermore, IPv6's goals include preventing address exhaustion, improving security, and boosting speed. It accomplishes this by assigning each device a globally unique 128-bit address, a significant upgrade from the 32-bit addresses used in IPv4.

In this article, we will demonstrate how to disable IPv6 on Ubuntu 22.04 (Jammy Jellyfish) and explore various key features of IPv6 protocols. We will also provide a guide on configuring Ubuntu IPv6 and how to enable IPv6 on the Ubuntu system.

What Are the Key Features of IPv6?

IPv6 incorporates a range of advanced features that include the following:

  • Smooth Auto-Configuration: This function optimizes the acquisition of network configuration parameters, streamlining the process.
  • Avoid Address Collisions: IPv6 actively works to mitigate conflicts arising from the utilization of private addresses, ensuring a smoother network operation.
  • Improved Multicast Routing and Header Format: The protocol improves the efficiency of routing for multicast communication, contributing to a more streamlined data transmission process. IPv6 employs a more straightforward structure for packet headers, simplifying data packet management.
  • Flow Labeling and Efficient Routing: IPv6 enhances the quality of service through the implementation of flow labeling, ensuring a more refined and responsive network performance. The protocol simplifies and enhances the overall efficiency of the routing process, facilitating faster and more reliable data transfer.
  • Authentication and Diverse Extensions Support: The protocol provides built-in authentication features and support mechanisms, enhancing the security and reliability of communications. IPv6 offers adaptability through flexible options and extensions, accommodating diverse network requirements.
  • Administration (No DHCP): By eliminating the need for DHCP (Dynamic Host Configuration Protocol), IPv6 simplifies network administration, streamlining the management of connected devices.

What Are the Reasons for Choosing to Disable IPv6 on Ubuntu?

IPv6 can occasionally pose challenges with certain applications. Taking into consideration the fact that VPNs operate globally and the use of globally routed IPv6 addresses, coupled with the continued lack of IPv6 support from some ISPs, places this functionality lower on their priority list. This approach allows VPN providers to concentrate on vital aspects for users, particularly security. 

Another compelling reason to disable IPv6 on your system is the desire to mitigate exposure to potential threats. While IPv6 itself is deemed more secure than IPv4, the risks here are different. If you're not actively utilizing IPv6 and its features, having it enabled can leave you susceptible to various attacks, providing hackers with an additional potential exploit. 

Those are all the reasons why many users may need to disable IPv6 on your system. But you can enable IPv6 again on your system, which we will also discuss in this article.

Disable IPv6 on Ubuntu (Ubuntu Disable IPv6)

By default, Ubuntu has IPv6 network connections enabled. However, in many cases, it may be necessary to turn off IPv6 Ubuntu setting. In this section, we'll provide a comprehensive demonstration of how to disable IPv6 on the Ubuntu 22.04 system.

To disable IPv6 on Ubuntu, you need root privileges to run all administrative system commands.

However, before starting, check whether IPv6 is enabled on your Ubuntu system. Use the following command to inspect your IP address:

$ ip a

If IPv6 is enabled, the following result will be displayed in your terminal:

configuring ubuntu ipv6: how to enable and disable ipv6 on ubuntu

Now, you can disable IPv6 on Ubuntu system using the following different methods:

Method 1: Disable IPv6 on Ubuntu Using the “sysctl” Command

Using the following three command inputs, you can disable IPv6 on your system:

You can disable IPv6 on Ubuntu using the “sysctl” command. To turn off IPv6 Ubuntu setting, use the following command inside your terminal:

$ sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1
$ sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1
$ sudo sysctl -w net.ipv6.conf.lo.disable_ipv6=1

Upon executing the above commands, the IPv6 settings on your Ubuntu system will be disabled. However, it's important to note that this is a temporary solution. Upon system reboot, IPv6 will be re-enabled again.

Method 2: Disable IPv6 on Ubuntu by Editing the “/etc/sysctl.conf” File

To disable IPv6 connections permanently, modify the “/etc/sysctl.conf” file. Open this configuration file using any available text editor. In this instance, we are using the nano editor for the modification.

$ sudo nano /etc/sysctl.conf

configuring ubuntu ipv6: how to enable and disable ipv6 on ubuntu

Now, make changes to this file. To disable IPv6 on this system, paste the below lines in this file. Save the changes and exit from it.

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

If you have a specific network interface that is enabled on your Ubuntu system, paste the below-mentioned line, such as “enp0s3,” in it. You can change it based on your requirements.

net.ipv6.conf.enp0s3.disable_ipv6 = 1

To verify the change settings, type the following command:

$ sudo sysctl -p

Now, when you check it again, you will see no IPv6 entry in your output as follows:

$ ip a

configuring ubuntu ipv6: how to enable and disable ipv6 on ubuntu

If IPv6 remains enabled on your Ubuntu system after a reboot, you can address this by creating and configuring the “/etc/rc.local” file. Ensure that you perform these steps with root privileges. Copy and paste the following script into the file:

#!/bin/bash
# /etc/rc.local
/etc/sysctl.d
/etc/init.d/procps restart
exit 0

After that, use the “chmod” command with sudo to make the file executable:

$ sudo chmod 755 /etc/rc.local

This command allows the system to manually read kernel parameters from the “sysctl” configuration file during the boot process. However, keep in mind that these actions occur at boot time.

Method 3: Disable IPv6 on Ubuntu Using GRUB

You can also disable IPV6 on Ubuntu using the GRUB. This is an alternative approach that involves configuring GRUB to pass kernel parameters during boot. To implement this, edit the “/etc/default/grub" file. Ensure you have administrative privileges before proceeding.

To disable IPv6 during boot, adjust the GRUB configuration by modifying the values for:

GRUB_CMDLINE_LINUX_DEFAULT and GRUB_CMDLINE_LINUX:
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash ipv6.disable=1"
GRUB_CMDLINE_LINUX="ipv6.disable=1"

Save the changes, and then execute the following command to update GRUB:


$ sudo update-grub


These settings will now be effective each time the system reboots.

How to Enable IPv6 on Ubuntu? (Configuring Ubuntu IPv6)

Below, you can find the guide to Configuring Ubuntu IPv6 on your system:

Edit the Configuration File “/etc/systemctl.config”

First, log in to your Ubuntu system with sudo or root privileges and launch the terminal window on your desktop. To configure Ubuntu IPv6, you will have to change a few details in the “sysctl.conf” file. So, open the “/etc/sysctl.conf” file in any source code or file editor.

$ sudo nano /etc/sysctl.conf

Now, add the following lines at the end of the above-mentioned configuration file:

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

Press “Ctrl+O” to save changes and exit from this file using “Ctrl+X.”

Enable IPv6 Using the “sysctl” Command

To re-enable IPv6, you will have to undo the changes you made by running the “sysctl” command. To enable IPv6 until reboot, enter the following commands:

$ sudo sysctl -w net.ipv6.conf.all.disable_ipv6=0
$ sudo sysctl -w net.ipv6.conf.default.disable_ipv6=0
$ sudo sysctl -w net.ipv6.conf.lo.disable_ipv6=0

Reload Services

Reload the setting again using the following command:

$ sudo sysctl -p

Again, run the “ip a” command to verify whether IPv6 is enabled on your Ubuntu system or not.

Enable IPv6 Using GRUB

If you made changes to the kernel parameters in the “/etc/default/grub file,” remove the added options:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX=""

After making the above-mentioned changes, execute the following command:

$ sudo update-grub

This ensures that the modifications are applied, and the system is updated accordingly.

Conclusion

In this article, we have provided a concise guide on disabling IPv6 on the Ubuntu 22.04 system, emphasizing the versatility of the presented commands applicable across Ubuntu versions. 

While IPv6 addresses the challenge of address space, it also brings various advantages, such as preventing private address collisions, enhancing multicast routing, improving quality of service, and offering built-in authentication. Thus, understanding how to enable and disable IPv6 on Ubuntu is crucial. 

Ubuntu, known for its user-friendly interface, is highlighted as a preferred Linux distribution. Additionally, the article mentions the availability of an Ubuntu VPS featuring robust hardware optimized for maximizing Ubuntu's functionality. If you found this information helpful, your feedback is appreciated.