Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2245885
  • 博文数量: 310
  • 博客积分: 6853
  • 博客等级: 准将
  • 技术积分: 2833
  • 用 户 组: 普通用户
  • 注册时间: 2005-08-04 16:41
文章分类

全部博文(310)

文章存档

2013年(17)

2012年(42)

2011年(76)

2010年(71)

2009年(99)

2007年(2)

2006年(1)

2005年(2)

分类: LINUX

2013-07-03 21:34:12


Here's the summary of what I can think of, with alternate methods in case the first one doesn't work with you:

Debian kernel 2.4:
  • In /etc/modutils, change the line
    alias net-pf-10 ipv6
    to
    alias net-pf-10 off
    alias ipv6 off
  • Reboot.
Debian kernel 2.6/Ubuntu ("official" method)/Fedora Core (method 1):
  • In /etc/modprobe.d/aliases, change the line
    alias net-pf-10 ipv6
    to
    alias net-pf-10 off
    alias ipv6 off
  • Reboot.
Debian kernel 2.6/Ubuntu (alternate method):
  • In /etc/modprobe.d/blacklist, add a line
    blacklist ipv6
  • Reboot.
RHEL/CentOS:
  • In /etc/modprobe.conf, make sure you have
    alias net-pf-10 off
    alias ipv6 off
  • Reboot.
RHEL/CentOS/Fedora Core (method 2)/Mandriva (method 1):
  • In /etc/sysconfig/network, add a line
    NETWORKING_IPV6="no"
  • Reboot.
SuSE 9.0:
  • In /etc/modules.conf, change the line
    alias net-pf-10 ipv6
    to
    alias net-pf-10 off
    alias ipv6 off
  • Reboot.
SuSE 9.1/9.2/9.3/10.0 ("official" method):
  • In /etc/modprobe.conf, change the line
    alias net-pf-10 ipv6
    to
    alias net-pf-10 ipv6
    install ipv6 /bin/true
  • Reboot.
SuSE 9.1/9.2/9.3/10.0 (alternate method)/Mandriva (method 2)/Slackware:
  • In /etc/modprobe.conf, make sure you change
    alias net-pf-10 ipv6
    to
    alias net-pf-10 off
    alias ipv6 off
  • Reboot.
Gentoo:
  • In /etc/modules.d/aliases, make sure you change
    alias net-pf-10 ipv6
    to
    alias net-pf-10 off
    alias ipv6 off
  • Reboot.

NOTES:
  • In distros using /etc/modprobe.conf, beware that you might get overriden by /etc/modprobe.conf.local or by /etc/modprobe.d/*.
  • If you disable IPv6, I suppose you don't need tunnels either. You could also add there:
    install sit0 /bin/true
  • A last "anti-IPv6" issue: don't forget the old trick of checking if your Firefox has IPv6 disabled:
    • CTRL+L, about:config (Enter)
    • Filter by ipv6.
    • Set network.dns.disableIPv6 to true.
------------------------------------------
实践:

IPv6还没有完全普及,但是安装完系统之后IPv6是有效的,在一定程度上影响网络性能,所以在我们在完全不使用IPv6的情况下,最好关闭IPv6。其实在上一篇网络设置的文章中,我们提到过是否激活IPv6,但是只是那一点设置还是不能完全关闭IPv6,所以本文以完整的步骤叙述一下如何关闭它。

1.修改/etc/sysconfig/network,追加:

NETWORKING_IPV6=no

2.修改/etc/hosts,把ipv6的那句本地主机名解析的也注释掉:

#::1 localhost localhost6 localhost6.localdomain6

3.让系统不加载ipv6相关模块,这需要修改modprobe相关设定文件,为了管理方便,我们新建设定文件/etc/modprobe.d/ipv6off.conf,内容如下,三种方式,总有一款适合你:

alias net-pf-10 off
options ipv6 disable=1

或者

install ipv6 /bin/true

或者

install ipv6 /sbin/modprobe -n -i ipv6

注意,如果你使用了网卡绑定(bond)技术,而且不希望用ipv6,那么你使用第一种,否则系统启动时,bonding模块可能会加载失败。

4.重启系统,然后确认:

[ ~]# lsmod | grep -i ipv6
[ ~]# ifconfig | grep -i inet6

如果上述2个命令执行的结果没有任何显示,那么说明ipv6已经被完全禁止了。

后记:
在第三步不加载ipv6模块的方法里,可能有人会有类似这样的设置方法:

alias net-pf-10 off
alias ipv6 off
options ipv6 disable=1

虽然这样在系统重启后,ipv6的确没被加载,但是因为第二句,在有的版本的系统里,当我们重启网络的时候,会出现如下错误:

FATAL: Module off not found.

我估计大家都不希望在启动过程中看到FATAL这样的错误信息,所以我就采用正文里所设置的方法。


阅读(3947) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~