Configuring Ubuntu IPV6: How to Enable and Disable IPv6 on Ubuntu
What is IPv6? Introduced in 1998, it’s the latest version of the Internet Protocol (IP), a communication protocol for routing data across the internet. IPv6 provides machines with unique identities and locations and is designed as the successor to IPv4.
The goals of IPv6 are to prevent address exhaustion, enhance security, and improve network speed. It achieves these aims by assigning each internet-connected device a globally unique 128-bit address, a significant leap from IPv4’s 32-bit addresses.
This article explains how to disable IPv6 on Ubuntu 22.04 (Jammy Jellyfish), outlines the key features of IPv6, and provides a comprehensive guide on configuring and enabling IPv6 on Ubuntu systems.
What Are the Key Features of IPv6?
IPv6 offers a range of advanced features:
- Simplified Auto-Configuration: Simplifies obtaining network configuration parameters.
- Address Collision Prevention: Reduces conflicts from using private addresses.
- Improved Multicast Routing and Header Format: Improves multicast communication efficiency and simplifies data packet management with a streamlined header structure.
- Flow Labeling and Efficient Routing: Enhanced Quality of Service (QoS) through flow labeling and simplified routing for faster, more reliable data transfer.
- Authentication and Diverse Extensions Support: Built-in authentication and support mechanisms enhance communication security and reliability. Flexible options and extensions allow adaptation to diverse network needs.
- Simplified Administration (No DHCP): Eliminates the need for DHCP (Dynamic Host Configuration Protocol), simplifying network administration.
Why Disable IPv6 on Ubuntu?
IPv6 can sometimes present compatibility issues with certain applications. Given the global operation of VPNs and the use of globally routed IPv6 addresses, combined with some ISPs’ lack of full IPv6 support, VPN providers may prioritize other features, particularly security.
Disabling IPv6 can also reduce your vulnerability to potential security exploits. Even though IPv6 is inherently more secure than IPv4, having it enabled without active use can create an attack surface, offering hackers a potential entry point.
This guide also covers how to re-enable IPv6 if needed.
Disable IPv6 on Ubuntu (Ubuntu Disable IPv6)
Ubuntu enables IPv6 network connections by default. This section demonstrates how to disable it on Ubuntu 22.04.
You’ll need root privileges to execute the commands.
First, verify whether IPv6 is currently enabled:
$ ip a
If IPv6 is enabled, you’ll see an IPv6 address assigned to your network interface:
Here are different methods to disable IPv6 on Ubuntu:
Method 1: Disable IPv6 Using the “sysctl” Command
These three commands will temporarily disable IPv6:
Execute the following commands in 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
These commands disable IPv6 until the system is rebooted. After a reboot, IPv6 will be automatically re-enabled.
Method 2: Permanently Disable IPv6 by Editing the “/etc/sysctl.conf” File
To disable IPv6 permanently, edit the “/etc/sysctl.conf” file using a text editor (e.g., nano):
$ sudo nano /etc/sysctl.conf
Add the following lines to the end of the file to disable IPv6. Save and exit the file.
net.ipv6.conf.all.disable_ipv6=1
net.ipv6.conf.default.disable_ipv6=1
net.ipv6.conf.lo.disable_ipv6=1
If you want to disable IPv6 on a specific network interface (e.g., “enp0s3”), add the following line, adjusting the interface name as needed:
net.ipv6.conf.enp0s3.disable_ipv6 = 1
Apply the changes with:
$ sudo sysctl -p
Verify that IPv6 is disabled by running:
$ ip a
You should no longer see IPv6 addresses assigned to your interfaces: