How to disable IPv6 on CentOS 7

We will be disabling IPv6 in kernel module.

First, check IPv6 is enabled or not

ifconfig -a | grep inet6

if you see inet6 in the output, you have IPv6.

Let’s disable it. Edit /etc/default/grub file and add ” ipv6.disable=1″ to GRUB_CMDLINE_LINUX

GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet"
GRUB_DISABLE_RECOVERY="true"
GRUB_CMDLINE_LINUX="ipv6.disable=1 crashkernel=auto rhgb quiet"

Recreate a GRUB configuration file with command:

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

Now we can restart the server and verify no line “inet6” in the ifconfig/ip command output.

init 6
ifconfig -a | grep inet6

Ok, that’s it!

This entry was posted in Linux and tagged , , , . Bookmark the permalink.

Leave a Reply

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