Skip to content

Instantly share code, notes, and snippets.

@ganapathichidambaram
Created June 17, 2020 15:43
Show Gist options
  • Save ganapathichidambaram/f565063b626bebdb5c97f26ef85ea24a to your computer and use it in GitHub Desktop.
Save ganapathichidambaram/f565063b626bebdb5c97f26ef85ea24a to your computer and use it in GitHub Desktop.
Disable IPv6 on CentOS 8 Server

To Disable IPv6 on CentOS

Disable IPv6 Using sysctl

First create a new sysctl configuration file /etc/sysctl.d/90-ipv6.conf using the following command.

vi /etc/sysctl.d/90-ipv6.conf

Next, add the following lines and save the file.

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

Now, to disable IPv6 use the following command.

sysctl --load /etc/sysctl.d/90-ipv6.conf

Now ipv6 disabled. To verify the same, run the following ip command.

ip a | grep inet6

If the command doesn’t return anything implying that IPv6 has been disabled on all your network interfaces.

When using this method, some of your network interfaces may still use IPv6 once you reboot your system. This happens because CentOS 8 uses Network Manager by default.

To completely stop using IPv6, use the following nmcli command.

nmcli connection modify interface ipv6.method ignore

Note: Make Sure nmcli installed on the system to do above.

Disable IPv6 Using The Kernel Boot Option

The kernel boot option requires a system reboot after the configuration. It’s the best method of disabling IPv6.

To use this method, open the default GRUB configuration file /etc/default/grub with the vi text editor, as shown below.

vi /etc/default/grub

Next, head to the end of the file and create a new line and type the following.

GRUB_CMDLINE_LINUX="$GRUB_CMDLINE_LINUX ipv6.disable=1"

Next, save and exit the configuration file.

The next step is to update the GRUB CFG files. Type the following command to locate the grub files.

ls -lh /etc/grub*.cfg

You will see 2 GRUB CFG file paths: /boot/grub2/grub.cfg and /boot/efi/EFI/centos/grub.cfg.

Type the following command to create a new GRUB configuration file and save it to /boot/grub2/grub.cfg.

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

Next, type the following command to create a new GRUB configuration file and save it to /boot/efi/EFI/centos/grub.cfg.

grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg

Finally, reboot your CentOS machine.

reboot

After rebooting, type the following command to verify whether IPv6 is disabled.

ip a | grep inet6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment