How to Disable IPv6 on Debian 12

Internet Protocol version 6 known as the IPv6 which is the advanced and improved version of the IPv4. This advanced protocol enhances the security and functionality of the internet protocol. The internet connections use the IPv6 protocol but sometimes, the connections are incompatible with the IPv6. In such cases, it is required to disable the IPv6 on the computer. 

This blog explores different ways to disable the IPv6 on Debian 12 using the terminal. 

What are the Features of IPv6?

The IPv6 is the advanced form of the IPv4 and it addresses the issue of limitation of the number of connected devices with the IPv4 protocol. IPv6 allows many devices to establish a connection to the internet. 

The important features of IPv6 are:

  • It addresses the 128-bit long addresses
  • They are displayed in the hexadecimal notation
  • It supports the autoconfiguration of the computer
  • It also supports multicasting communication
  • The security features include end-to-end encryption

What are the Methods to Disable the IPv6 on Debian 12?

Two methods can be used to disable the IPv6 on Debian 12:

  1. Using the sysctl configuration
  2. Blacklisting the IPv6 Kernel Module

Method 1: Disable the IPv6 on Debian 12 Using the sysctl Configuration

The first method of disabling the IPv6 on Debian 12 is by making the changes in the systctl configuration by the below-mentioned steps. 

Step 1: Display the Current Status of IPv6

To find out the current status of the IPv6, run the command:

$ sudo sysctl net.ipv6.conf.all.disable_ipv6

The “0” displaying the IPv6 is enabled. 

Step 2: Open the sysctl Configuration File

Open the sysctl configuration file with the help of the text editor, in our case, the nano text editor is being used to open the file:

$ sudo nano /etc/sysctl.conf

Step 3: Edit the sysctl Configuration File

Scroll down the file and copy-paste the below-mentioned lines at the end of the file to disable the IPv6 permanently:

# Disabling the IPv6
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1

Save the changes with the CTRL+S and exit the nano text editor. 

Step 4: Apply the Changes

Now apply the changes made in the sysctl configuration file with the execution of the command:

$ sudo sysctl -p

Step 5: Verify the IPv6 Status

To verify that the IPv6 has been successfully disable, again display the status:

$ sudo sysctl net.ipv6.conf.all.disable_ipv6

The “1” is showing that the IPv6 has been disabled successfully.  To enable the IPv6 on Debian 12 again, open the sysctl configuration file and remove the added line from it. 

Method 2: Disable the IPv6 on Debian 12 by Blacklisting its Kernel Module

Another method of disabling the IPv6 on Debian 12 is by blacklisting the IPv6 Kernel Module following the below-mentioned steps.

Step 1: Open the Blacklist Configuration File

First, open the Blacklisting configuration file using the nano text editor:

$ sudo nano /etc/modprobe.d/blacklist-ipv6.conf

Step 2: Edit the Blacklist Configuration File

Blacklist the IPv6 Kernel module so it will not load and this can be done by adding the below-mentioned line in the blacklisting file:

blacklist ipv6

Close the file by saving the changes with the shortcut of CTRL+S

Step 3: Apply the Changes

Now apply the changes made in the blacklisting configuration file by running the command:

$ sudo update-initramfs -u

Step 4: Restart the Computer

After making the changes, reboot the computer:

$ sudo reboot

Step 5: Verify the Changes

To verify the changes in the blacklist configuration file, run the command:

$ lsmod | grep ipv6

The output displays that the IPv6 Kernel module has successfully disabled. If the users want to enable the IPv6 on Debian 12, then run the command:

$ sudo rm /etc/modprobe.d/blacklist-ipv6.conf

Also, update the kernels:

$ sudo update-initramfs -u

How to Disable the IPv6 on Debian 12 Temporary?

Temporarily disable the IPv6 on Debian 12, and run the below-mentioned commands:

$ 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

This will disable the IPv6 on Debian 12 for the current sessions which means on restarting the computer, the IPv6 protocol will be enabled. 

These are the methods to disable the IPv6 on Debian 12.

Conclusion

To disable the IPv6 on Debian 12, either open the sysctl configuration file or blacklist the IPv6 kernel module. Both methods are explained in this blog. Also disabling the IPv6 temporarily on Debian 12 has been presented.