在RHEL 5下面测试成功
 
 
linux下面禁止ipv6的方法:
来自: 杨志刚 博客 (http://yangzhigang.cublog.cn)
 
这里我所做的是Redhat Linux,在系统中ifconfig或是netstat -an都会显示出IPV6的结果,如:
[root@WebServer-22 conf]# ifconfig
eth1      Link encap:Ethernet  HWaddr 00:15:C5:EF:74:1C 
          inet addr:192.168.102.22  Bcast:192.168.102.255  Mask:255.255.255.0
          inet6 addr: fe80::215:c5ff:feef:741c/64 Scope:Link
 
[root@WebServer-22 conf]# netstat -ant
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address               Foreign Address            
tcp 0 576 ::ffff:192.168.102.22:22    ::ffff:192.168.12.100:3339  ESTABLISHED
tcp 0 0   ::ffff:192.168.102.22:80    ::ffff:192.168.102.25:36479 TIME_WAIT  
tcp 0 0   ::ffff:192.168.102.22:80    ::ffff:192.168.102.25:36503 TIME_WAIT  
 
在IPV6还没有广泛使用时,这有些不方便,那么在Redhat Linux下禁止IPV6的方法也很容易:
vi /etc/modprobe.conf,加入以下两行参数,
alias net-pf-10 off
alias ipv6 off
之后reboot。(注:用service network restart是不可以的)
 
重启之后,ifconfig或netstat -ant等只能显示IPV4的地址信息了。
 
对于其他的系统,可以参照以下文档:
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.

 

 

 

摘于:http://blog.chinaunix.net/uid-7654720-id-1742032.html

posted on 2015-03-10 16:15  胡彼德  阅读(248)  评论(0编辑  收藏  举报