CentOS 6
1、编辑/boot/grub/grub.conf在以下行结尾加上ipv6.disable=1
kernel /vmlinuz-2.6.32-279.el6.x86_64 ro root=UUID=5bd71e9a-7b05-45f8-8928-ce88a2921fa0 rd_NO_LUKS rd_NO_LVM LANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet ipv6.disable=1
2、重启生效
CentOS 7
1、编辑/etc/default/grub,在GRUB_CMDLINE_LINUX加上的后面句首加上ipv6.disable=1。
cat /etc/default/grub
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="ipv6.disable=1 crashkernel=auto rhgb quiet net.ifnames=0"
GRUB_DISABLE_RECOVERY="true"
修改完毕后保存,运行grub2-mkconfig -o /boot/grub2/grub.cfg重新生成grub.cfg文件。
grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Found linux p_w_picpath: /boot/vmlinuz-3.10.0-514.el7.x86_64
Found initrd p_w_picpath: /boot/initramfs-3.10.0-514.el7.x86_64.img
Found linux p_w_picpath: /boot/vmlinuz-0-rescue-17d22e95741e42659fb29b8c611d8b33
Found initrd p_w_picpath: /boot/initramfs-0-rescue-17d22e95741e42659fb29b8c611d8b33.img