具体:
1. 修改disable_ipv6.conf,不同的系统命名会有些差别
# cp /etc/modprobe.d/disable_ipv6.conf /data/guotest/ipv6/ ##先备份下原始配置,这是个好习惯! # vim /etc/modprobe.d/disable_ipv6.conf ##注释alias ipv6 off及修改options ipv6 disable为0 修改前 alias net-pf-10 off alias ipv6 off options ipv6 disable=1 修改后 alias net-pf-10 off #alias ipv6 off options ipv6 disable=0 # cp /etc/sysconfig/network /data/guotest/ipv6/# vim /etc/sysconfig/network ##修改NETWORKING_IPV6为yes 修改前 NETWORKING=yes HOSTNAME=coolnull NETWORKING_IPV6=no PEERNTP=no GATEWAY=*.*.*.* 修改后 NETWORKING=yes HOSTNAME=coolnull NETWORKING_IPV6=yes PEERNTP=noGATEWAY=*.*.*.*
2编辑 /etc/sysctl.conf 文件,将其中三条禁用IPv6的设置更改为(系统默认是0):
net.ipv6.conf.all.disable_ipv6 = 0 net.ipv6.conf.default.disable_ipv6 = 0 net.ipv6.conf.lo.disable_ipv6 = 0
再运行 sysctl -p 的命令,启用IPv6
3.转到 tunnelbroker.net 网站 ,
1)注册Tunnel broker
https://www.tunnelbroker.net/
注册很容易,就不讲了,注册需要邮箱验证,,gmail、163能收得到认证邮件,qq(如果qq收不到,看看垃圾站有没有,实在不行就换其他的邮箱)
2)创建通道“Create Regular Tunnel”
填写云服务器ip以及选择默认的隧道节点,点击Create Tunnel创建。填写ip都,如果出现“IP is a potential tunnel endpoint.”则证明可以添加ipv6隧道,一般隧道节点系统已经默认分配,可以手动选择,大家可以在自己的云服务器上分别ping一下这些ip,选时延低的。
3)创建ipv6隧道及路由
提交后,到下一页面切换到Example configurations选项卡,如果你的VPS是centOS/Debian这些常见Linux的话,下拉菜单选择Linux-route2,出现了设置的命令,复制到自己的云服务器上运行。
如果执行命令失败,可以复制以下命令,Server IPv4 Address Client IPv4 Address Server IPv6 Address等按IPv6 Tunnel那页对应的填写
#modprobe ipv6 # ip tunnel add he-ipv6 mode sit remote <Server IPv4 Address> local <Client IPv4 Address> ttl 255 # ip link set he-ipv6 up # ip addr add <Server IPv6 Address> dev he-ipv6 #(此处<Server IPv6 Address> 注意替换) # ip -6 route add ::/0 dev he-ipv6 # ip -f inet6 addr
4)测试ipv6
# ifconfig he-ipv6 ##可以看到已经获取ipv6地址及建立了he-ipv6隧道he-ipv6 Link encap:IPv6-in-IPv4 inet6 addr: x:x:x:x::x/64 Scope:Global inet6 addr: x::x:x/128 Scope:Link UP POINTOPOINT RUNNING NOARP MTU:1480 Metric:1 RX packets:252535 errors:0 dropped:0 overruns:0 frame:0 TX packets:167086 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:248945037 (237.4 MiB) TX bytes:22166230 (21.1 MiB)
# ping6 ipv6.google.com ##ping6域名会提示unknown host,这是因为当前系统不支持ipv6解析,只要添加下ipv6的dns服务器就可以了, unknown host # ping6 -c 5 2001:4860:4860::8888 ###直接ping6 ipv6是正常的 PING 2001:4860:4860::8888(2001:4860:4860::8888) 56 data bytes 64 bytes from 2001:4860:4860::8888: icmp_seq=1 ttl=61 time=3.52 ms 64 bytes from 2001:4860:4860::8888: icmp_seq=2 ttl=61 time=3.62 ms 64 bytes from 2001:4860:4860::8888: icmp_seq=3 ttl=61 time=3.95 ms 64 bytes from 2001:4860:4860::8888: icmp_seq=4 ttl=61 time=3.65 ms 64 bytes from 2001:4860:4860::8888: icmp_seq=5 ttl=61 time=3.70 ms --- 2001:4860:4860::8888 ping statistics --- 5 packets transmitted, 5 received, 0% packet loss, time 4009ms rtt min/avg/max/mdev = 3.525/3.692/3.954/0.157 ms
5).添加ipv6的dns服务器,在最后添加nameserver 2001:4860:4860::8888,nameserver 2001:4860:4860::8844谷歌的ipv6 dns服务器
# vim /etc/resolv.confoptions timeout:1 attempts:1 rotate nameserver x.x.x.x nameserver x.x.x.x nameserver 2001:4860:4860::8888nameserver 2001:4860:4860::8844
这时再ping6就正常了
# ping6 -c 5 ipv6.google.com PING ipv6.google.com(tsa03s01-in-x0e.1e100.net) 56 data bytes 64 bytes from tsa03s01-in-x0e.1e100.net: icmp_seq=1 ttl=56 time=365 ms 64 bytes from tsa03s01-in-x0e.1e100.net: icmp_seq=2 ttl=56 time=363 ms ^C --- ipv6.google.com ping statistics --- 2 packets transmitted, 2 received, 0% packet loss, time 999ms rtt min/avg/max/mdev = 363.202/364.506/365.810/1.304 ms
最后一步:配置 DNS 使其支持 IPv6 解析
这步最简单,只需给相应的域名加上AAAA解析,值填 HE 里的Client IPv6 Address,去掉最后的/64即可,如2001:470:100:100::2