CentOS 6:
在/etc/resolv.conf文件中添加以下内容 options single-request-reopen
修改/etc/sysctl.conf文件
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.all.disable_ipv6 = 1
禁止加载IPv6模块
echo "install ipv6 /bin/true" > /etc/modprobe.d/disable-ipv6.conf
禁用网卡IPv6设置,使之仅在IPv4模式下运行
NETWORKING_IPV6=no
禁用网卡IPv6设置,使之仅在IPv4模式下运行。这个正常应该只有在网卡重启才会有效
vi /etc/sysconfig/network-scripts/ifcfg-ethX 或 vi /etc/sysconfig/network-scripts/ifcfg-em1IPV6INIT=no
IPV6_AUTOCONF=no
重启生效
CentOS 7:
Disable IPv6:(If U dont have use of IPV6)
First check that IPv6 is enabled or not:
[root@localhost ~]# lsmod | grep -i ipv6
nf_conntrack_ipv6 18738 5
nf_defrag_ipv6 34651 1 nf_conntrack_ipv6
nf_nat_ipv6 13279 1 ip6table_nat
nf_nat 21798 4 nf_nat_ipv4,nf_nat_ipv6,ip6table_nat,iptable_nat
nf_conntrack 101024 8 nf_nat,nf_nat_ipv4,nf_nat_ipv6,xt_conntrack,ip6table_nat,iptable_nat,nf_conntrack_ipv4,nf_conntrack_ipv6
Edit the grub file:
vi /etc/default/grub
Search for the line “GRUB_CMDLINE_LINUX” and add the following at the beginning: “ipv6.disable=1′′ Will look like this:
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="vconsole.font=latarcyrheb-sun16 vconsole.keymap=us rd.lvm.lv=centos/root crashkernel=auto rhgb quiet"
GRUB_DISABLE_RECOVERY="true"
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 vconsole.font=latarcyrheb-sun16 vconsole.keymap=us rd.lvm.lv=centos/root crashkernel=auto rhgb quiet"
GRUB_DISABLE_RECOVERY="true"
Create a new configuration based on the currently running system using grub2-mkconfig command:
grub2-mkconfig -o /boot/grub2/grub.cfg
Reboot the system:
reboot
Once again, check the IPv6 on the system:
lsmod | grep -i ipv6
up vote1down voteaccepted
The description sounds almost as though you might need to configure /etc/gai.conf. But I'll hold on that for blacklisting IPv6. To prevent the IPv6 module from binding to the IPv6 networking stack, add the line below to "/etc/modprobe.d/blacklist.conf" (or a different file name):
options ipv6 disable=1
Then, reboot.
This will allow the loading of the IPv6 module in order to satisfy any other modules that depend on it while disabling support for the IPv6 protocol.
EDIT
Also, you missed NETWORKING_IPV6=no in /etc/sysconfig/network.
本文为Lokie.Wang原创文章,转载无需和我联系,但请注明来自lokie博客http://lokie.wang