Disable IPv6 on Linux – Ubuntu, Debian, CentOS

To disable IPv6 on Linux it is required to modify Linux kernel parameters.

IPv6 can be temporary disabled at runtime, using sysctl command or it can be disabled permanently using either sysctl configuration file or the required kernel parameters can be passed at boot time using GRUB configuration.

In this note i am showing how to disable IPv6 temporary or permanently on Ubuntu, Debian, CentOS and similar Linux operating systems.

Check if IPv6 is enabled:

$ ip a | grep inet6

If IPv6 is enabled you should see IPv6 addresses, otherwise it is disabled and you shouldn’t see any IPv6 entries.

Disable IPv6 on Linux

To disable IPv6 at runtime temporary (settings won’t persist on reboot), execute the commands below:

$ 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

To re-enable IPv6, execute:

$ sudo sysctl -w net.ipv6.conf.all.disable_ipv6=0
$ sudo sysctl -w net.ipv6.conf.default.disable_ipv6=0
$ sudo sysctl -w net.ipv6.conf.lo.disable_ipv6=0

Disable IPv6 using Sysctl

To disable IPv6 permanently, open the file /etc/sysctl.d/99-sysctl.conf and add:

# Disable IPv6

Run the following command to apply new setting:

$ sudo sysctl -p

Disable IPv6 using GRUB

Open the file /etc/default/grub, find GRUB_CMDLINE_LINUX and append ipv6.disable=1:


Run one of the below commands, to re-generate GRUB configuration file.

Ubuntu, Debian:

$ sudo update-grub


$ grub2-mkconfig -o /boot/grub2/grub.cfg

Now, the IPv6 will be disabled on the system boot.

Was it useful? Share this post with the world!

Leave a Reply