This guide provides step-by-step instructions on how to disable IPv6 in Linux using both temporary and permanent methods, ensuring flexibility for your system’s needs.
Table of Contents:
What is IP (Internet Protocol)?
IP (Internet Protocol) is a core technology that enables communication between devices on a network, including the Internet. It is part of the TCP/IP protocol suite, which serves as the foundation for modern networking. IP’s primary role is to define how data is sent, addressed, routed, and delivered from one device to another over a network.
What is IPv6?
IPv6 (Internet Protocol version 6) is the most recent version of the Internet Protocol (IP), which serves as an identifier for devices on a network and routes traffic across the Internet. IPv6, developed to address the limitations of its predecessor, IPv4, particularly the exhaustion of available IPv4 addresses.
An IPv6 address is eight groups of four hexadecimal digits, separated by colons, written as:
For e.g.- 2001:0db8:85a3:0000:0000:8a2e:0370:7334
Key Features of IPv6
- Larger Address Space: IPv6 uses 128-bit addresses, allowing for approximately 38 decillion unique addresses. In contrast, IPv4 uses 32-bit addresses, which allows for about 4.3 billion unique addresses.
- Improved Routing and Addressing: Hierarchical address allocation improves routing efficiency. IPv6 supports stateless address autoconfiguration (SLAAC), allowing devices to generate their own IP addresses without the need for a DHCP server.
- Built-in Security: IPv6 has IPsec (Internet Protocol Security) as a mandatory component for securing communication between devices.
- Simplified Header Format: IPv6 reduces the size of some header fields and eliminates others (like checksum fields), improving packet processing efficiency.
- No Need for NAT (Network Address Translation): The vast address space eliminates the need for NAT, allowing for end-to-end connectivity and simplified peer-to-peer communication.
- Enhanced Multicasting: Improved support for multicast traffic (sending data to multiple destinations) allows for more efficient use of network resources.
- Support for Mobile IP: IPv6 provides better support for devices that move between networks, such as mobile phones and laptops.
Disabling IPv6 in Linux:
Disabling IPv6 in Linux is essential for specific use cases such as compatibility issues or system configuration requirements. This can be done temporarily or permanently using system commands or by modifying configuration files.
Method 1: Using the sysctl command to Temporarily Disable IPv6
The sysctl
command is a command-line utility used to view and modify kernel parameters at runtime. These parameters are part of the Linux kernel which controls the operating system’s behavior. The sysctl
command allows administrators to make changes dynamically without requiring to reboot the system.
Check if IPv6 is Enabled:
Use the command below to check the current network configuration.
$> ip a
If, there are inet6 addresses in the output, it means IPv6 is on.

Disable IPv6 Temporarily:
Use the commands below to disable IPv6 for all network interfaces:
$> sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1
$> sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1
-w
: Writes (modifies) a kernel parameter.
net.ipv6.conf.all.disable_ipv6=1
: Disables IPv6 for all network interfaces.
net.ipv6.conf.default.disable_ipv6=1
: Disables IPv6 for any new or default network interfaces.
These commands set the kernel parameters to disable IPv6 for all interfaces and the default interface.

Verify IPv6 is Disabled:
Use the command below to check the network configuration:
$> ip a
If, there are no inet6 addresses in the output, it means IPv6 is off.

Method 2: Editing GRUB configuration file to Permanently Disable IPv6
GRUB (Grand Unified Bootloader) is a bootloader in Linux and other operating systems that allows the user to select and load the operating system during system startup. It is responsible for loading the kernel and other system components into memory during startup.
Thus, for a permanent solution, user can disable IPv6 by modifying the GRUB configuration file. This prevents IPv6 from turning on during system boot.
Open the GRUB configuration file using a text editor, here we are using the Nano Editor:
$> sudo nano /etc/default/grub
Modify GRUB Settings:
Add or update the following lines in the file.
GRUB_CMDLINE_LINUX_DEFAULT="ipv6.disable=1 quiet splash"
GRUB_CMDLINE_LINUX="ipv6.disable=1"
Save the file by pressing CTRL+O and exit the editor with CTRL+X.

Apply the changes to the GRUB configuration and Reboot the System:
Use the command below to Apply the changes to the GRUB configuration.
$> sudo update-grub
Use the command below to reboot the system so the changes take effect.
$> sudo reboot

Verify IPv6 is Disabled:
After the reboot, use the command below to check the network configuration.
$> ip a
If, there are no inet6 addresses in the output, it means IPv6 is off.

Enabling IPv6 in Linux:
Method 1: Using the sysctl
command to Temporarily Enable IPv6
Check if IPv6 is Disabled:
Use the command below to check the current network configuration:
$> ip a
If, there are no inet6 addresses in the output, it means IPv6 is off.

Enable IPv6 Temporarily:
Use the commands below to disable IPv6 for all network interfaces:
$> sudo sysctl -w net.ipv6.conf.all.disable_ipv6=0
$> sudo sysctl -w net.ipv6.conf.default.disable_ipv6=0
-w
: Writes (modifies) a kernel parameter.
net.ipv6.conf.all.disable_ipv6=0
: Enables IPv6 for all network interfaces.
net.ipv6.conf.default.disable_ipv6=0
: Enables IPv6 for any new or default network interfaces.
These commands set the kernel parameters to enable IPv6 for all interfaces and the default interface.

Verify IPv6 is Enabled:
Use the command below to check the network configuration.
$> ip a
If inet6 addresses are listed then, IPv6 is successfully enabled.

Method 2: Editing GRUB configuration file to Permanently Enable IPv6
Open the GRUB configuration file using a text editor, here we are using the Nano Editor:
$> sudo nano /etc/default/grub
Modify GRUB Settings:
Add or update the following lines in the file.
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX=""
Save the file by pressing CTRL+O and exit the editor with CTRL+X.

Apply the changes to the GRUB configuration and Reboot the System:
Use the command below to Apply the changes to the GRUB configuration.
$> sudo update-grub
Use the command below to Reboot the System for the changes to take effect.
$> sudo reboot

Verify IPv6 is Enabled:
After the reboot, use the command below to check the network configuration.
$> ip a
If, there are inet6 addresses in the output, it means IPv6 is on.
