IPv6隧道代理

介绍一下如何给只有IPv4的VPS 配置 IPv6。
IPv6测试
首先测试一下你的服务器支不支持IPv6,
Test your IPv6.
This will test your browser and connection for IPv6 readiness, as well as show you your current IPv4 and IPv6 address.

获取IPv6隧道
前往下面这个网站注册一个账户:
Hurricane Electric Free IPv6 Tunnel Broker

注册账户的过程就不说了,注册完账户之后,点击左侧的 Create Regular Tunnel,如下所示。

在下面的页面中,在对应的地方输入你的 VPS 的 IP 地址,注意不要输错了。然后根据你服务器的地址选择一个较近的服务器。选好之后,在页面最下方点击 Create,进入下一个页面。

配置IPv6
下一个页面如下所示。我们切换到 Example Configurations,然后选择 Linux-net-tools。会出现几行代码。

接下来我们登陆 VPS 的 SSH,复制上面的代码,全部运行。
最后,打开https://test-ipv6.com/ 测试连通性.
Test your IPv6.
This will test your browser and connection for IPv6 readiness, as well as show you your current IPv4 and IPv6 address.

设置开机启动
下面我们设置 IPv6 开机启动。首先安装必要的工具:
yum -y install vim
然后新建文件:
vim /root/ipv6.sh
按一下 i 进行插入,输入如下内容:
#!/bin/bash
ifconfig sit0 up
ifconfig sit0 inet6 tunnel ::YOUR-IPV4 #请进行替换
ifconfig sit1 up
ifconfig sit1 inet6 add YOUR-IPV6 #请进行替换
route -A inet6 add ::/0 dev sit1
上面的代码记得替换成你自己的 IPv4 和 IPv6 地址,其实就是把之前页面显示的代码抄过来,前面加上一行 #!/bin/bash 即可。
按一下 Esc 键,然后输入 :wq 保存并退出。如果不熟悉 vim 操作命令的,可以自己查一下。
给文件增加可执行权限:
chmod +x /root/ipv6.sh
然后编辑下面的文件:
vim /etc/rc.d/rc.local
在最下方加入下面一行代码:
sh /root/ipv6.sh
保存并退出,这样重启后也有 IPv6。
总结
至此,IPv6 已经成功配置并且可以开机启用。之后你们要进行什么骚操作,就自己发挥了。