1. 1、CentOS 6.3未关闭ipv6前: 
  2. [root@localhost ~]# ifconfig 
  3. eth0      Link encap:Ethernet  HWaddr 14:FE:B5:E4:88:37   
  4.           inet addr:192.168.7.5  Bcast:192.168.7.255  Mask:255.255.255.0 
  5.           inet6 addr: fe80::16fe:b5ff:fee4:8837/64 Scope:Link 
  6.           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1 
  7.           RX packets:29241896 errors:0 dropped:0 overruns:0 frame:0 
  8.           TX packets:6367343 errors:0 dropped:0 overruns:0 carrier:0 
  9.           collisions:0 txqueuelen:1000  
  10.           RX bytes:2183886705 (2.0 GiB)  TX bytes:1303582168 (1.2 GiB) 
  11.           Interrupt:16  
  12.  
  13. lo        Link encap:Local Loopback   
  14.           inet addr:127.0.0.1  Mask:255.0.0.0 
  15.           inet6 addr: ::1/128 Scope:Host 
  16.           UP LOOPBACK RUNNING  MTU:16436  Metric:1 
  17.           RX packets:188 errors:0 dropped:0 overruns:0 frame:0 
  18.           TX packets:188 errors:0 dropped:0 overruns:0 carrier:0 
  19.           collisions:0 txqueuelen:0  
  20.           RX bytes:14792 (14.4 KiB)  TX bytes:14792 (14.4 KiB) 
  21.  
  22. 2、通过内核模块加载信息查看 
  23. [root@localhost ~]# lsmod |grep ipv6 
  24. ipv6                  322029  43 cnic 
  25. 注释:有 “inet6 addr:。。。。。。。“ 的表示开启了ipv6功能。 
  26.  
  27. 3、ipv6关闭方法 
  28.  
  29. 在/etc/modprobe.d/dist.conf结尾添加 
  30.  
  31. alias net-pf-10 off 
  32. alias ipv6 off 
  33. 可用vi等编辑器,也可以通过命令: 
  34. [root@localhost ~]# cat <<EOF>>/etc/modprobe.d/dist.conf 
  35. alias net-pf-10 off 
  36. alias ipv6 off 
  37. EOF
  38.  
  39. 4、关闭ip6的iptables
  40. [root@localhost ~]# chkconfig ip6tables off
  41. [root@localhost ~]# reboot 
  42.  
  43. 5、重启后: 
  44. [root@localhost ~]# lsmod |grep ipv6 
  45. [root@localhost ~]# ifconfig 
  46. eth0      Link encap:Ethernet  HWaddr BC:30:5B:C0:CD:4F   
  47.           inet addr:192.168.7.5  Bcast:192.168.7.255  Mask:255.255.255.0 
  48.           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1 
  49.           RX packets:803 errors:0 dropped:0 overruns:0 frame:0 
  50.           TX packets:78 errors:0 dropped:0 overruns:0 carrier:0 
  51.           collisions:0 txqueuelen:1000  
  52.           RX bytes:55708 (54.4 KiB)  TX bytes:9946 (9.7 KiB) 
  53.           Interrupt:16  
  54.  
  55. lo        Link encap:Local Loopback   
  56.           inet addr:127.0.0.1  Mask:255.0.0.0 
  57.           UP LOOPBACK RUNNING  MTU:16436  Metric:1 
  58.           RX packets:0 errors:0 dropped:0 overruns:0 frame:0 
  59.           TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 
  60.           collisions:0 txqueuelen:0  
  61.           RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b) 

 

 
  
  1. CentOS 5 
  2. 1:编辑/etc/sysconfig/network  
  3. 默认是yes,改成no 
  4. NETWORKING_IPV6=no 
  5. 2:编辑 /etc/modprobe.conf  
  6. 如果没有就添加下面两行 
  7. alias net-pf-10 off 
  8. alias ipv6 off 
  9. 3:停止服务 
  10. #chkconfig ip6tables off 
  11. 4:重启 

 
  
  1. centos6.3 禁用IPv6 
  2. IPv6还没有完全普及,但是安装完系统之后IPv6是有效的,在一定程度上影响网络性能,所以在我们在完全不使用IPv6的情况下,最好关闭IPv6。其实在上一篇网络设置的文章中,我们提到过是否激活IPv6,但是只是那一点设置还是不能完全关闭IPv6,所以本文以完整的步骤叙述一下如何关闭它。 
  3.  
  4. 1.修改/etc/sysconfig/network,追加: 
  5.  
  6. NETWORKING_IPV6=no 
  7.  
  8. 2.修改/etc/hosts,把ipv6的那句本地主机名解析的也注释掉: 
  9.  
  10. #::1   localhost localhost6 localhost6.localdomain6 
  11.  
  12. 3.让系统不加载ipv6相关模块,这需要修改modprobe相关设定文件,为了管理方便,我们新建设定文件/etc/modprobe.d/ipv6off.conf,内容如下,三种方式,总有一款适合你: 
  13.  
  14. 推荐: 
  15. alias net-pf-10 off 
  16. options ipv6 disable=1 
  17.  
  18. 或者 install ipv6 /bin/true 
  19. 或者 install ipv6 /sbin/modprobe -n -i ipv6 
  20. 注意,如果你使用了网卡绑定(bond)技术,而且不希望用ipv6,那么你使用第一种,否则系统启动时,bonding模块可能会加载失败。 
  21.  
  22. 4.重启系统,然后确认: 
  23.  
  24. [root@test ~]# lsmod | grep -i ipv6 
  25. [root@test ~]# ifconfig | grep -i inet6 
  26. 如果上述2个命令执行的结果没有任何显示,那么说明ipv6已经被完全禁止了。 
  27.  
  28. 后记: 
  29. 在第三步不加载ipv6模块的方法里,可能有人会有类似这样的设置方法: 
  30. alias net-pf-10 off 
  31. alias ipv6 off 
  32. options ipv6 disable=1 
  33. 虽然这样在系统重启后,ipv6的确没被加载,但是因为第二句,在有的版本的系统里,当我们重启网络的时候,会出现如下错误: 

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

  关闭多余tty前:

 
  
  1. [root@CentOS ~]# ps aux |grep tty 
  2. root      1359  0.0  0.0   4056   592 tty1     Ss+  17:42   0:00 /sbin/mingetty /dev/tty1 
  3. root      1361  0.0  0.0   4056   592 tty2     Ss+  17:42   0:00 /sbin/mingetty /dev/tty2 
  4. root      1363  0.0  0.0   4056   596 tty3     Ss+  17:42   0:00 /sbin/mingetty /dev/tty3 
  5. root      1365  0.0  0.0   4056   592 tty4     Ss+  17:42   0:00 /sbin/mingetty /dev/tty4 
  6. root      1367  0.0  0.0   4056   596 tty5     Ss+  17:42   0:00 /sbin/mingetty /dev/tty5 
  7. root      1369  0.0  0.0   4056   596 tty6     Ss+  17:42   0:00 /sbin/mingetty /dev/tty6 
  8. root      1398  0.0  0.0 103232   868 pts/0    S+   17:44   0:00 grep tty 

CentOS5之前是直接在/etc/inittab文件中注释多余tty就可以了,但是6.3发生了改变。/etc/inittab中没有/etc/inittab选项。

 
  
  1. [root@CentOS ~]# vi  /etc/sysconfig/init 
  2.  
  3. color => new RH6.0 bootup 
  4. verbose => old-style bootup 
  5. # anything else => new style bootup without ANSI colors or positioning 
  6. BOOTUP=color 
  7. # column to start "[  OK  ]" label in  
  8. RES_COL=60 
  9. # terminal sequence to move to that column. You could change this 
  10. # to something like "tput hpa ${RES_COL}" if your terminal supports it 
  11. MOVE_TO_COL="echo -en \\033[${RES_COL}G" 
  12. # terminal sequence to set color to a 'success' color (currently: green) 
  13. SETCOLOR_SUCCESS="echo -en \\033[0;32m" 
  14. # terminal sequence to set color to a 'failure' color (currently: red) 
  15. SETCOLOR_FAILURE="echo -en \\033[0;31m" 
  16. # terminal sequence to set color to a 'warning' color (currently: yellow) 
  17. SETCOLOR_WARNING="echo -en \\033[0;33m" 
  18. # terminal sequence to reset to the default color. 
  19. SETCOLOR_NORMAL="echo -en \\033[0;39m" 
  20. # Set to anything other than 'no' to allow hotkey interactive startup... 
  21. PROMPT=yes 
  22. # Set to 'yes' to allow probing for devices with swap signatures 
  23. AUTOSWAP=no 
  24. # What ttys should gettys be started on? 
  25. #ACTIVE_CONSOLES=/dev/tty[1-6] 
  26. ACTIVE_CONSOLES=/dev/tty[1-3] ###改这里哦!! 
  27. # Set to '/sbin/sulogin' to prompt for password on single-user mode 
  28. # Set to '/sbin/sushell' otherwise 
  29. SINGLE=/sbin/sushell 
  30. [root@CentOS ~]# reboot 
  31. [root@CentOS ~]# ps aux |grep tty 
  32. root      1360  0.0  0.0   4056   596 tty1     Ss+  17:46   0:00 /sbin/mingetty /dev/tty1 
  33. root      1362  0.0  0.0   4056   596 tty2     Ss+  17:46   0:00 /sbin/mingetty /dev/tty2 
  34. root      1364  0.0  0.0   4056   596 tty3     Ss+  17:46   0:00 /sbin/mingetty /dev/tty3 
  35. root      1385  0.0  0.0 103232   868 pts/0    S+   17:46   0:00 grep tty