0%

阿里云配置IPV6

阿里云配置IPV6

注册创建IPV6通道

Hurricane Electric 是一家位于美国的全球互联网服务提供商。该公司提供IPv4和IPv6接入 以及位于美国圣荷西的数据中心服务。(维基百科)

Hurricane Electric官网

  1. 登录Hurricane Electric官网,注册账号

  2. 填写相关注册信息并且需要验证邮箱。

  3. 邮箱验证通过后,登录选择Create Regular Tunnel.

  4. IPv4 Endpoint处填写IPv4地址,选择HongKong.HK。点击Create Tunnel,创建成功。

  5. 创建成功后可以得到下面的信息

配置ECS使其支持IPv6

  • 编辑/etc/sysctl.conf,将下面三项的配置改为0。后保存退出后。然后执行sysctl -p更新配置。
    1
    2
    3
    net.ipv6.conf.all.disable_ipv6 = 0
    net.ipv6.conf.default.disable_ipv6 = 0
    net.ipv6.conf.lo.disable_ipv6 = 0
  • 编辑网卡配置/etc/network/interfaces,在底部添加一下内容。(替换你的IPv4地址,替换成你申请到的IPv6的地址。IPv6地址格式为2001:470:xxxx:xxxx,不包括后面的::1/64或者::2/64)
1
2
3
4
5
6
7
8
9
10
11
12
13
auto he-ipv6
iface he-ipv6 inet6 v4tunnel
address <IPV6>::2
netmask 64
remote <HE 的 Server IPv4 Address>
local <IPv4>
endpoint any
ttl 255
gateway <IPv6>::1
up ip -6 route add 2000::/3 via ::<HE 的 Server IPv4 Address> dev he-ipv6
up ip -6 addr add <IPv6>::1:1/128 dev he-ipv6
up ip -6 addr add <IPv6>::2:1/128 dev he-ipv6
down ip -6 route flush dev he-ipv6
  • 重启服务器server nginx restart
  • 执行ifup he-ipv6开启IPv6
  • 然后,执行ifconig查看有没有he-ipv6的网卡

配置Nginx使其监听IPv6端口

编辑/usr/local/nginx/conf/nginx.conf

监听http请求80端口,https请求443端口

1
2
3
4
5
6
7
8
9
server {
listen 80;
listen [::]:80; // 监听 IPv6 的 80 端口
}

server {
listen 443 ;
listen [::]:443 ; // 监听 IPv6 的 443 端口
}

如果没有配置https的话,只需要监听80端口。

配置DNS使其支持IPv6解析

登录阿里云后台,添加AAAA类型的域名解析域名解析。记录值填写Client IPv6 Address的地址。去掉后面的/64。

测试IPv6配置是否成功

测试网址:

http://ipv6-test.com/validate.php

输入网址,点击测试
测试通过如下显示,说明网站支持IPv6。

不支持IPv6如下显示