wiki:linux:ipv6-support
Linux 支持 ipv6 网络
如果默认的网络环境不支持ipv6(只支持ipv4),
概要:通过 https://www.tunnelbroker.net 建立tunnel隧道,使得linux能够支持ipv6网络
创建隧道
- 创建通道“Create Regular Tunnel”
- 填写VPS的公网 IP 地址。填写IP时出现“IP is a potential tunnel endpoint.”说明可以添加ipv6隧道。
- 选择隧道节点,点击Create Tunnel创建。
- 关于隧道节点的选择,大家可以在自己的云服务器上分别ping一下提供的IP,选时延低的。
- 创建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
保存后,执行以下命令
resolvconf -u
重启网络
service networking restart
或者重启主机
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
如强制使用IPV6访问谷歌,也非常简单,在/etc/hosts里添加
# Google 2607:f8b0:4005:811::200e google.com 2607:f8b0:4005:80c::2004 www.google.com # Google Scholar 2607:f8b0:4005:80a::200e scholar.google.cn 2607:f8b0:4005:80a::200e scholar.google.com 2607:f8b0:4005:80a::200e scholar.google.com.hk 2607:f8b0:4005:80a::200e scholar.google.com.sg 2607:f8b0:4005:80a::200e scholar.google.com.tw 2607:f8b0:4005:80a::200e scholar.google.com.uk 2607:f8b0:4005:80a::200e scholar.l.google.com
Linux刷新dns的缓存方法是:
sudo /etc/init.d/nscd restart
如果发现提示命令找不到:sudo: /etc/init.d/nscd: command not found
需要先安装nscd包:
sudo apt-get install nscd
最暴力的方法刷dns,重启网络:
sudo /etc/init.d/networking restart
查询可用的ip地址
参考:
运行 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
无法使用ifconfig时,尝试运行以下命令
sudo apt install net-tools
wiki/linux/ipv6-support.txt · 最后更改: 2023/01/03 15:25 由 127.0.0.1
评论