天天看點

CentOS 6/7 禁用ipv6

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

繼續閱讀