Ale*_*nti 9 ipv6 networking routing
我正在使用我的提供商提供的静态 IPv4 和 IPv6 地址在 KVM 服务器上配置双栈网络。
我在安装 Ubuntu 时根据需要输入了所有地址、名称服务器和网关。之后,我检查了/etc/network/interfaces文件并注意到 IPv6 节不存在(ifconfig执行确认了这一点),因此我添加了相关行。这是最终文件:
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet static
address 151.236.18.86
netmask 255.255.255.0
network 151.236.18.0
broadcast 151.236.18.255
gateway 151.236.18.1
# dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 91.227.204.227 91.227.205.227
dns-search mydomainname.com
iface eth0 inet6 static
pre-up modprobe ipv6
address 2001:b60:1000:151:236:18:86:0
netmask 112
gateway 2001:b60:1000::1
dns-nameservers 2001:4860:4860::8888 2001:4860:4860::8844
dns-search mydomainname.com
Run Code Online (Sandbox Code Playgroud)
然后我通过重新启动网络sudo /etc/init.d/networking stop && sudo /etc/init.d/networking restart并注意到,当 IPv4 工作时,出站 IPv6 连接不可用(我还没有检查入站连接)。
ifconfig并ip -6 addr显示已识别 IPv6 地址:
eth0 Link encap:Ethernet HWaddr 52:54:00:b1:27:87
inet addr:151.236.18.86 Bcast:151.236.18.255 Mask:255.255.255.0
inet6 addr: fe80::5054:ff:feb1:2787/64 Scope:Link
inet6 addr: 2001:b60:1000:151:236:18:86:0/112 Scope:Global
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:16409 errors:0 dropped:0 overruns:0 frame:0
TX packets:1178 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1126656 (1.1 MB) TX bytes:763658 (763.6 KB)
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qlen 1000
inet6 2001:b60:1000:151:236:18:86:0/112 scope global
valid_lft forever preferred_lft forever
inet6 fe80::5054:ff:feb1:2787/64 scope link
valid_lft forever preferred_lft forever
Run Code Online (Sandbox Code Playgroud)
相反,IPv6 堆栈不存在默认路由:
$ ip -6 route
2001:b60:1000:151:236:18:86:0/112 dev eth0 proto kernel metric 256
fe80::/64 dev eth0 proto kernel metric 256
Run Code Online (Sandbox Code Playgroud)
尝试添加缺少的路由会导致“No route to host”错误:
$ sudo ip -6 route add default via 2001:b60:1000::1
RTNETLINK answers: No route to host
Run Code Online (Sandbox Code Playgroud)
可能有什么问题,我该如何修复网络配置,以便让 IPv6 堆栈正常工作?
在您的虚拟机中,运行以下命令:
ping6 ff02::2%eth0
Run Code Online (Sandbox Code Playgroud)
这ff02::2是 IPv6“所有路由器”多播地址。链路上的路由器将使用自己的地址响应 ping。例如:
64 bytes from fe80::56e6:fcff:fef4:66f1: icmp_seq=1 ttl=64 time=0.347 ms
Run Code Online (Sandbox Code Playgroud)
然后,您可以将其添加为gateway地址。
iface eth0 inet6 static
.....
gateway fe80::56e6:fcff:fef4:66f1
.....
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
37407 次 |
| 最近记录: |