蘋果上架要求:要求支持IPV6only(因為阿里云主機沒有IPV6only)
確認IPV6是否開啟:
方式1:使用ifconfig查看自己的IP地址是否含有IPv6地址。
方式2.查看服務監聽的IP中是否有IPv6格式的地址。(netstat -tuln)
開啟IPV6:
vim?/etc/sysctl.conf
vim /etc/modprobe.d/disable_ipv6.conf
vim /etc/sysconfig/network
至此ipv6的服務器端支持已經完成,重啟服務器測試是否支持ipv6,重啟后,?ifconfig查看ipv6的信息,有看到有關IPV6的輸出就可以
添加ipv6隧道:
1. 注冊Tunnel broker
https://www.tunnelbroker.net/
注冊很容易,就不講了,注冊需要郵箱驗證,,gmail、163能收得到認證郵件,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,出現了設置的命令,復制到自己的云服務器上運行。如果是“專有網絡”,需要將HE配置隧道地址命令中的IPv4地址修改為ECS實例的內網地址。
如
modprobe ipv6
ip tunnel add he-ipv6 mode sit remote 【Tunnel 的 Server IPv4 Address】 local 【阿里云的內網 IPv4 地址】 ttl 255
ip link set he-ipv6 up
ip addr add 【IPv6】/64 dev he-ipv6
ip route add ::/0 dev he-ipv6
ip -f inet6 addr
4.測試ipv6
添加ipv6的dns服務器,在最后添加nameserver 2001:4860:4860::8888,nameserver 2001:4860:4860::8844谷歌的ipv6 dns服務器
# vim /etc/resolv.conf
options timeout:1attempts:1 rotate
nameserver x.x.x.x
nameserver x.x.x.x
nameserver 2001:4860:4860::8888
nameserver 2001:4860:4860::8844
# ping6 -c 5 ipv6.google.com
PING ipv6.google.com(tsa03s01-in-x0e.1e100.net) 56 data bytes
bytes from tsa03s01-in-x0e.1e100.net: icmp_seq=1 ttl=55 time=25.5 ms
bytes from tsa03s01-in-x0e.1e100.net: icmp_seq=2 ttl=55 time=25.5 ms
bytes from tsa03s01-in-x0e.1e100.net: icmp_seq=3 ttl=55 time=33.1 ms
bytes from tsa03s01-in-x0e.1e100.net: icmp_seq=4 ttl=55 time=25.5 ms
bytes from tsa03s01-in-x0e.1e100.net: icmp_seq=5 ttl=55 time=25.4 ms
--- ipv6.google.com ping statistics ---
packets transmitted, 5 received, 0% packet loss, time 4031ms
rtt min/avg/max/mdev = 25.473/27.040/33.180/3.073 ms
NGINX 配置
1、nginx開啟IPV6支持配置
到nginx的sbin目錄,cd /usr/local/nginx/sbin,執行命令./nginx -V
若沒有出現--with-ipv6,說明當前的nginx不支持ipv6,我們需要重新編譯Nginx,配置里面增加--with-ipv6
2、nginx配置ipv6監聽
listen 80;
listen [ ipv6 ]:80;
listen 443 ssl http2;
listen [ipv6]:443 ssl http2;
域名解析
為網站域名添加AAAA解析,值填 HE 里的Client IPv6 Address,去掉最后的/64 即可。如2001:470:1f18:583::2。
測試
http://ipv6-test.com/validate.php在這個網址中輸入你的域名就可以了,只要下面兩項可以過就可以提交app審核了:
AAAA DNS record
IPv6 web server
如下圖所示即表示站點已支持IPv6訪問。
如果IPv6 web server出現web server is unreachable : Connection timed out,自己寫一個定時腳本ping指定網址,如ping6 ipv6.baidu.com