How To Disable IPv6 In Ubuntu

Having issue with IPv6 and wants to disable it then you are at the right place.  In this blog post, we will show you the multiple ways to disable IPv6 in Ubuntu and it’s derivatives.

How To Disable IPv6 In Ubuntu

We will show you the three methods to disable IPv6 in Ubuntu based operating system.

1. How to disable IPv6 using the /etc/sysctl.conf file

In this method, we will disable IPv6 by editing the /etc/sysctl.conf file. This method disable IPv6 in permanent way. Run the following command in your terminal to open the /etc/sysctl.conf file:

sudo nano /etc/sysctl.conf

Now, after opening the config file, You need to scroll down to the end of the file in nano using Alt + / . After going down to the end of the file, you need to paste the following lines:

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

Save changes and exit  the nano text editor. Run the following command to reload the sysctl file to take effect.

sudo sysctl -p

Just in case if you are unable to disable the IPv6 then you might need to do something further to make it happen.

Create a file named rc.local inside the /etc directory:

sudo nano /etc/rc.local

After creating rc.localf ile, enter the following inside that file:

#!/bin/bash
# /etc/rc.local

/etc/sysctl.d
/etc/init.d/procps restart

exit 0

Save the changes that you have made and exit the text editor.

At last, Run the following command to change the file permissions to make that file that you have created in above step to work:

sudo chmod 755 /etc/rc.local

Now, you will get rid of IPv6.

2. How to disable IPv6 using the GRUB config file

It is one of the easy and the convenient way to disable IPv6. Run the following command to open the config file:

sudo nano /etc/default/grub

Now you need to change 2 lines. You need to the change following two lines to the lines mentioned below:

GRUB_CMDLINE_LINUX_DEFAULT=""
GRUB_CMDLINE_LINUX=""

New lines that you need to change:

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

Save changes and exit from the text editor.

Run the following command to update the grub file to take effect from the changes you made

sudo update-grub

Reboot your system and IPv6 will be disabled!

3. How to disable IPv6 using sysctl

In this method, you will be only able to disable IPv6 temporary. You want to disable IPv6 temporarily then go through the following steps. It will disable till your next boot. Run the following command to disable IPv6 temporarily:

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

Run the following command to verify whether it is disabled successfully or not:

ip a

It will disable IPv6 till your next boot. Run the following command to disable IPv6 temporarily.

 

Leave a comment

Your email address will not be published. Required fields are marked *