您的位置:首页 > 运维架构 > Linux

腾讯云Centos开启IPV6

2017-03-29 16:32 260 查看
先看下开启后的效果吧。
[root@VM_centos ~]# ifconfig
eth0      Link encap:Ethernet  HWaddr 52:54:00:34

1:52  
          inet addr:10.101.3.185  Bcast:10.101.127.255  Mask:255.255.192.0
          inet6 addr: fe80::5054:ff:fe34:d152/64 Scope

ink 
 ------------------------->>>开启成功后会有一列IPV6的地址格式
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1010372 errors:0 dropped:0 overruns:0 frame:0
          TX packets:423319 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:79625272 (75.9 MiB)  TX bytes:44330935 (42.2 MiB)

腾讯云主机centos系统均加载了IPV6模块,可以使用lsmod命令查看,如下:
[root@VM_centos ~]# lsmod |grep ipv6
ipv6                  334804  0 

一、开启IPV6命令:sysctl -w net.ipv6.conf.all.disable_ipv6=0
[root@VM_centos ~]# sysctl -w net.ipv6.conf.all.disable_ipv6=0
error: "net.ipv6.conf.all.disable_ipv6" is an unknown key    -->内核参数没加载,则会报这个错(注意:centos6.2/7.0/7.1版本的默认是加载的,直接运行这个命令便可以成功,其它centos版本都得重启主机来加载,往下看...)

二、原来还要在配置文件中/etc/modprobe.d/ipv6.conf 修改内核参数,options ipv6 disable=0,设置为0表示打开这个参数。
[root@VM_centos ~]# cat /etc/modprobe.d/ipv6.conf 
# Anaconda disabling ipv6
options ipv6 disable=0

三、设置了还不行再操作第一步,还是报错,原来必须要重启云主机刚修改的内核参数才会加载生效。重启云主机后,再执行:sysctl -w net.ipv6.conf.all.disable_ipv6=0 就OK了。(最好把这条命令写在/etc/rc.local配置文件里,开机自动执行,不然重启后,又会默认关闭了。)
查看下设置生效的方法:
[root@VM_centos ~]# sysctl -a|grep ipv6|grep all.disable_ipv6  
net.ipv6.conf.all.disable_ipv6 = 0
再执行下ifconfig看下网卡,就会发现多了一个IPV6的地址。如第一段的开启效果。

注意:上述方法适用于centos6.2、centos6.3、centos6.4、centos6.5  centos6.6
centos5.8/5.11略有不同,IPV6内核参数文件在/etc/modprobe.conf中修改。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: