User Tools

Site Tools


wiki:server:ipv6tunnel

配置 TunnelBroker IPv6 隧道

添加 IPv6 网络接口

编辑 /etc/sysctl.conf,修改以下条目。

net.ipv6.conf.all.disable_ipv6 = 0
net.ipv6.conf.default.disable_ipv6 = 0
net.ipv6.conf.lo.disable_ipv6 = 0

刷新设置文件

sysctl -p

新建 /etc/network/interfaces.d/he-ipv6

vi /etc/network/interfaces.d/he-ipv6

内容

auto he-ipv6
iface he-ipv6 inet6 v4tunnel
        address [客户端 IPv6 地址]
        netmask 64
        endpoint [隧道服务器 IPv4 地址]
        local [本机 IPv4 地址(公网IP或内网IP)]
        ttl 255
        gateway [隧道服务器 IPv6 地址]

启用 IPv6 隧道

安装网络工具包

apt-get install net-tools iproute2 -y

启动 he-ipv6 网络接口

ifup he-ipv6

其它操作

检测 IPv6 支持

ping6 google.com

NAT VPS 的额外设置

IPv4 NAT VPS 除了前面提到的替换 IP 操作以外,可能还需要一些额外的设置,否则可能还是无法访问 IPv6 网络。 配置防火墙允许 41 端口入站

ufw allow 41

添加相关的路由规则

route -A inet6 add ::/0 dev he-ipv6

优先使用 IPv4 网络

编辑 /etc/gai.conf 文件,在末尾添加下面这行配置:

precedence  ::ffff:0:0/96   100

一键添加命令如下:

echo 'precedence  ::ffff:0:0/96   100' | sudo tee -a /etc/gai.conf

完事执行 curl ip.p3terx.com 命令,显示 VPS 的 IPv4 地址则代表成功。

删除 HE IPv6 隧道

不想用了,或者想使用其它方式访问 IPv6 网络时,记得先删除。 停用隧道

ifdown he-ipv6

删除 he-ipv6 网络接口配置文件(若没有删除重启后会自动启用)

rm -f /etc/network/interfaces.d/he-ipv6

故障排除

add tunnel sit0 failed: No buffer space available

隧道已经存在,执行

ip tun del he-ipv6 

删除已经存在的隧道。

add tunnel "sit0" failed: No buffer space available

系统 IPv6 被禁用或者未更新配置文件,检查 /etc/sysctl.conf 中有无禁用 IPv6 的命令

wiki/server/ipv6tunnel.txt · Last modified: by maxduke

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki