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
net.ipv6.conf.all.disable_ipv6=1
net.ipv6.conf.default.disable_ipv6=1
net.ipv6.conf.lo.disable_ipv6=1

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:

GRUB_CMDLINE_LINUX="ipv6.disable=1"

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

Ubuntu, Debian:

$ sudo update-grub

CentOS:

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

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

  • 0 Utilisateurs l'ont trouvée utile
Cette réponse était-elle pertinente?

Articles connexes

What Is My Router’s IP Address (Default Gateway)

A router is a device that communicates between the Internet (or public network) and the devices...

CIDR Notation – Explained & Examples

CIDR (Classless Inter-Domain Routing) notation is a compact method for specifying IP addresses...

169.254.0.0/16 – Disable ZEROCONF Route

You may notice that in your routing table you have a route 169.254.0.0/16. It is so called...

What is my Public IP address?

Use one of the following commands to check your public IP address from the Linux command line....

Finding Active Computers in Local Network from Linux

Searching for Linux command that can list all IP addresses of devices connected to the network?...