Open In App

How to Disable IPv6 in linux?

Improve
Improve
Like Article
Like
Save
Share
Report

In this article, we will discuss how to disable IPv6 in Linux. We can achieve this using sysctl.

What is IPv6?

IPv6 stands for internet protocol version 6, which is the latest version of the internet protocol.

What is the Internet protocol?

Internet Protocol (IP) is the protocol or set of rules by which data is sent from one computer to another on the internet. The Internet Protocol gives every computer, every machine, or computer on the internet a unique address called an IP address. The IP address is used to uniquely identify each device on a network. The IPv4 is the previous version of the Internet protocol.

The IPv4 is of size 32 bits, whereas the IPv6 is of size 128 bits. As the number of devices in the world is increasing rapidly, there is a chance that all the possible IPv4 addresses might get exhausted. so the ipv6 was introduced. 

Disabling IPv6 in Linux

For disabling the IPv6 we can use the sysctl command. The sysctl command is used to view and view the kernel settings, It is used to modify the kernel parameters at runtime. The IPv6 is disabled by modifying Kernel parameters with sysctl.

Approach

1. Firstly check if the IPv6 is enabled or not by following the command.

 ip a

The inet6 means IPV6 ( IPv6 is enabled)

2.  Now use the following two commands to disable the IPv6

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

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

 

 

3. Again check if the IPv6 is disabled or not using ip a command

inet6 is not  available (IPv6 is disabled)

Enabling the IPv6

1. To re-enable the IPv6, the process is the same as above except that instead of 1 keep it as 0.

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

 

 

2. Check if IPv6 is enabled or not by using the IP command.

IPv6 Enabled

Disable IPv6 using GRUB

1. Open the terminal and open the grub file in nano editor using the following command

 sudo nano /etc/default/grub

 

2. Change the above-highlighted lines as shown below

GRUB_CMDLINE_LINUX_DEFAULT=”ipv6.disable=1 quiet splash”

GRUB_CMDLINE_LINUX=”ipv6.disable=1″

 

3. Save the changes using CTRL O, Exit using CTRL X.

4. Update the grub using the following command.

sudo update-grub

5. Check if the IPv6 is disabled using the IP a command.

 

Enabling IPv6

To re-enable the ipv6 just undo the modifications made in the file

GRUB_CMDLINE_LINUX_DEFAULT=”quiet splash”

GRUB_CMDLINE_LINUX=””

Save the file and use the command upgrade-grub 


Last Updated : 02 Jun, 2022
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads