搬砖计算机网络服务器

Centos7 IPV4服务器如何支持ipv6访问

2017-04-11  本文已影响1340人  魔法师_

参考:

https://bbs.aliyun.com/read/285557.html

https://www.aliyun.com/ss/ZWNzIGlwdjY

http://www.ttlsa.com/nginx/nginx-ipv6-configuration/

http://my.oschina.NET/blackfish/blog/49946

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

http://test-ipv6.com/

1Linux支持ipv6

2 nginx支持ipv6

3 ipv6隧道

4 AAAA域名解析

5 检测服务器IPV6是否失效

6  检测用户是否在IPV6网络环境

IPV4服务器如何支持ipv6访问,需要有几个前提:

1 IPV4公网IP

2 由于IPV4和IPV6两个网络不同不通,所以IPV4与IPV6之间要建立隧道,以便访问

3 服务器要开启IPV6支持,Linux通过修改系统参数实现

4 服务器上的Web服务器,如Nginx要开启IPV6支持

5 服务器要获取IPV6的IP,并做AAAA域名解析

1 linux支持ipv6

https://bbs.aliyun.com/read/285557.html

1.编辑 /etc/sysctl.conf 文件,将其中三条禁用IPv6的设置更改为:

net.ipv6.conf.all.disable_ipv6 = 0

net.ipv6.conf.default.disable_ipv6 = 0

net.ipv6.conf.lo.disable_ipv6 = 0

2.再运行 sysctl -p 的命令,启用IPv6

3. 转到 tunnelbroker.net网站,在 Example Configurateions 里选择 Linux-route2 的配置方法,示例命令如下:

modprobe ipv6

ip tunnel add he-ipv6 mode sit remote 216.218.221.6 local 121.43.110.72 ttl 255

ip link set he-ipv6 up

ip addr add 2001:470:18:401::2/64 dev he-ipv6

ip route add ::/0 dev he-ipv6

ip -f inet6 addr

2 nginx支持ipv6

http://www.ttlsa.com/nginx/nginx-ipv6-configuration/

http://my.oschina.Net/blackfish/blog/49946

执行脚本:

cd /usr/local/openresty-1.9.7.4

./configure --prefix=/usr/local/openresty--with-ipv6--with-pcre=/usr/local/pcre-8.38 --with-openssl=/usr/local/openssl-1.0.2g --with-zlib=/usr/local/zlib-1.2.8 --with-luajit --with-http_iconv_module --with-ld-opt="-Wl,-rpath,/usr/local/lib"  --with-http_stub_status_module --with-http_ssl_module --with-http_sub_module --add-module=./bundle/nginx-http-concat/

gmake

gmake install

编辑nginx.conf

vi /usr/local/openresty/nginx/conf/nginx.conf

每个server节下:

listen 80;

listen [::]:80 ipv6only=on;

验证:

netstat -lan|grep LISTEN

curl -I -6 localhost6

此时,可通过netstat -tulpn | grep :80命令查看,例如:

tcp 0 0 116.255.153.163:80 0.0.0.0:* LISTEN

tcp 0 0 2001:470:1f04:15c5::2:80 :::* LISTEN

3 ipv6隧道

参考https://bbs.aliyun.com/read/285557.html

转到 tunnelbroker.net网站,登录后-》Create Regular Tunnel -》创建时输入服务器的公网IP,例如:182.61.42.67,选择就近的接入点,如新加坡的,然后创建隧道,在 Example Configurateions 里选择 Linux-route2 的配置方法,示例命令如下:

modprobe ipv6

ip tunnel add he-ipv6 mode sit remote 216.218.221.6 local 121.43.110.72 ttl 255

ip link set he-ipv6 up

ip addr add 2001:470:18:401::2/64 dev he-ipv6

ip route add ::/0 dev he-ipv6

ip -f inet6 addr

4 AAAA域名解析

增加域名解析,对于同一个域名,可以有同名的A类和AAAA类域名解析。

如我已经有一个域名:A 类 demo.baidu.com 解析到 182.20.30.215 这个IPV4的IP的域名解析

我可以再加一条:AAAA类的demo.baidu.com解析到2001:470:35:884::2这个IPV4的IP的域名解析

知道这样的特性后,我的做法是,用两台服务器A和B,分别作为这个域名的IPV4解析和IPV6解析。

这样,用户在IPV4环境请求demo.baidu.com时,就是请求A服务器;

用户在IPV6环境请求demo.baidu.com时,就是请求B服务器;

5 检测服务器IPV6是否失效

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

测试下来,只要前两项通过即可。

6  检测用户是否在IPV6网络环境

http://test-ipv6.com/

遇到的问题,中间过程磕磕碰碰的,遇到的问题很多:

1 ping不通,打不开网站

总结下来,这几种情况会导致Ping不通得到的IPV6IP2001:470:35:884::2:

a) 我本机没有IPV6网络,即本机没有IPV6IP,通过这个网站测试http://test-ipv6.com/

b)服务器的IPV4防火墙开了(IPV6的防火墙开了没关系),所以暂时我将服务器的IPV4防火墙先关了

2 单点登录passport不能混在一起,混在一起会导致CAS校验失败

所以两个环境分别搭建cas和web服务,如:

A服务器:一个CAS+2个Tomcat服务器

B服务器:一个CAS+2个Tomcat服务器

上一篇 下一篇

猜你喜欢

热点阅读