九溪

溪水润知林,滴露启慧心

用户工具

站点工具


wiki:linux:ipv6-support

这是本文档旧的修订版!


Linux 支持 ipv6 网络

如果默认的网络环境不支持ipv6(只支持ipv4),

概要:通过 https://www.tunnelbroker.net 建立tunnel隧道,使得linux能够支持ipv6网络

创建隧道

  1. 创建通道“Create Regular Tunnel”
    • 填写VPS的公网 IP 地址。填写IP时出现“IP is a potential tunnel endpoint.”说明可以添加ipv6隧道。
    • 选择隧道节点,点击Create Tunnel创建。
    • 关于隧道节点的选择,大家可以在自己的云服务器上分别ping一下提供的IP,选时延低的。
  2. 创建IPv6隧道及路由:
    • 到下一页面切换到Example configurations选项卡,
    • 下拉菜单选择Debian/Ubuntu,
    • 复制出现的内容。类似下面的代码
auto he-ipv6
iface he-ipv6 inet6 v4tunnel
        address xxxx:xxx:xxxx:xxx::x
        netmask 64
        endpoint xxx.xxx.xxx.xx
        local xxx.xxx.xxx.xxx
        ttl 255
        gateway xxxx:xxx:xxxx:xxx::x

在主机中添加ipv6隧道

编辑文件,将刚才复制的内容粘贴进去。

vim /etc/network/interfaces
auto he-ipv6
iface he-ipv6 inet6 v4tunnel
        address xxxx:xxx:xxxx:xxx::x
        netmask 64
        endpoint xxx.xxx.xxx.xx
        local xxx.xxx.xxx.xxx
        ttl 255
        gateway xxxx:xxx:xxxx:xxx::x

添加DNS

vim /etc/resolvconf/resolv.conf.d/base

加入以下内容

nameserver 2001:4860:4860::8844
nameserver 2001:470:20::2

保存后,执行以下命令

resolveconf -u

重启网络或重启主机

systemctl restart network

或者

reboot

然后,执行

ifconfig

应该可以看到 he-ipv6 网卡

没有的话,执行

ifup he-ipv6

接着连通测试

ping6 -c 5 2001:4860:4860::8888
ping6 -c 5 ipv6.google.com

Ping通了,说明网络已连通,能正常解析域名,说明DNS也正常。

其他IPv6 测试工具:

如何确定目前连接的方式为 IPv4 还是 IPv6?打开https://www.google.com/search?hl=en&q=what+is+my+ip,如果显示的您的 IP 地址为 IPv6 格式说明您是以 IPv6 的形式接入的,否则为 IPv4 形式。

Hosts 如果需要指定域名通过IPv6 访问,修改Hosts文件即可。

vi /etc/hosts

刷新DNS缓存

/etc/init.d/nscd restart

参考:

运行 resolvconf -u 出现以下信息

/etc/resolvconf/update.d/libc: Warning: /etc/resolv.conf is not a symbolic link to /run/resolvconf/resolv.conf

解决办法:

sudo rm /etc/resolv.conf
sudo ln -s /run/resolvconf/resolv.conf /etc/resolv.conf
sudo resolvconf -u

评论

请输入您的评论. 可以使用维基语法:
 
wiki/linux/ipv6-support.1570527852.txt.gz · 最后更改: 2023/01/03 15:24 (外部编辑)