我正在尝试通过路由器在 IPv6 中连接两个模块(客户端和服务器)。它在 IPv4 中有效,但在 IPv6 中无效。
这是路由器配置:
$ ifconfig
eno1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.40.56.26 netmask 255.255.255.0 broadcast 10.40.56.255
inet6 fe80::47dc:3b02:90de:2030 prefixlen 64 scopeid 0x20<link>
ether 18:31:bf:e0:2c:4f txqueuelen 1000 (Ethernet)
RX packets 28116 bytes 3152995 (3.0 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 5440 bytes 3745444 (3.5 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 16 memory 0xa1300000-a1320000
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 14900 bytes 1346088 (1.2 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 14900 bytes 1346088 (1.2 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
tun0: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST> mtu 1500
inet 192.168.2.1 netmask 255.255.255.0 destination 192.168.2.1
inet6 fe80::4fe5:b420:b2db:cdab prefixlen 64 scopeid 0x20<link>
unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 txqueuelen 500 (UNSPEC)
RX packets 7 bytes 308 (308.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 27 bytes 1412 (1.3 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
tun1: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST> mtu 1500
inet6 2001:468:3000:1:: prefixlen 48 scopeid 0x0<global>
inet6 fe80::476b:d7be:189f:c9ee prefixlen 64 scopeid 0x20<link>
unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 txqueuelen 500 (UNSPEC)
RX packets 15 bytes 960 (960.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 14 bytes 672 (672.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
tun2: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST> mtu 1500
inet 192.168.4.1 netmask 255.255.255.0 destination 192.168.4.1
inet6 2001:468:3000:1:: prefixlen 48 scopeid 0x0<global>
inet6 fe80::7d63:28af:13a7:6813 prefixlen 64 scopeid 0x20<link>
unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 txqueuelen 500 (UNSPEC)
RX packets 33 bytes 2364 (2.3 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 14 bytes 672 (672.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
tun3: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST> mtu 1500
inet 192.168.5.1 netmask 255.255.255.0 destination 192.168.5.1
inet6 fe80::1a60:3195:6e42:c469 prefixlen 64 scopeid 0x20<link>
inet6 2001:468:4000:1:: prefixlen 48 scopeid 0x0<global>
unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 txqueuelen 500 (UNSPEC)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 14 bytes 672 (672.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
tun4: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST> mtu 1500
inet 192.168.2.1 netmask 255.255.255.0 destination 192.168.2.1
inet6 fe80::fca3:d3a9:2352:e365 prefixlen 64 scopeid 0x20<link>
unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 txqueuelen 500 (UNSPEC)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 14 bytes 672 (672.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
virbr0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 192.168.124.1 netmask 255.255.255.0 broadcast 192.168.124.255
ether 52:54:00:cb:49:e5 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
以下是路由命令的输出:
$ route -n -6
Kernel IPv6 routing table
Destination Next Hop Flag Met Ref Use If
2001:468:3000::/48 :: U 256 5 15 tun1
2001:468:3000::/48 :: U 256 5 33 tun2
2001:468:3000::/48 :: U 1024 1 0 tun1
2001:468:4000::/48 :: U 256 1 0 tun3
2001:468:4000::/48 :: U 1024 1 0 tun3
fc00::40:56:0/112 :: U 100 1 0 eno1
fe80::223:ebff:fea6:4c7f/128 :: U 100 1 0 eno1
fe80::/64 :: U 256 1 0 eno1
fe80::/64 :: U 256 1 0 tun0
fe80::/64 :: U 256 1 0 tun1
fe80::/64 :: U 256 1 0 tun2
fe80::/64 :: U 256 1 0 tun3
fe80::/64 :: U 256 1 0 tun4
::/0 fe80::223:ebff:fea6:4c7f UG 100 13 401 eno1
::/0 :: !n -1 1 498 lo
::1/128 :: Un 0 5 8 lo
2001:468:3000:1::/128 :: Un 0 2 0 lo
2001:468:3000:1::/128 :: Un 0 2 0 lo
2001:468:4000:1::/128 :: Un 0 2 0 lo
fe80::1a60:3195:6e42:c469/128 :: Un 0 2 0 lo
fe80::476b:d7be:189f:c9ee/128 :: Un 0 2 0 lo
fe80::47dc:3b02:90de:2030/128 :: Un 0 3 50 lo
fe80::4fe5:b420:b2db:cdab/128 :: Un 0 2 0 lo
fe80::7d63:28af:13a7:6813/128 :: Un 0 2 0 lo
fe80::fca3:d3a9:2352:e365/128 :: Un 0 2 0 lo
ff00::/8 :: U 256 4 429 eno1
ff00::/8 :: U 256 1 0 tun0
ff00::/8 :: U 256 1 0 tun1
ff00::/8 :: U 256 1 0 tun2
ff00::/8 :: U 256 1 0 tun3
ff00::/8 :: U 256 1 0 tun4
::/0 :: !n -1 1 498 lo
客户端尝试连接服务器套接字时连接失败。控制台输出正在打印error 113 No route to host on connect()
。
客户端设备正在获取以下地址:
2001:468:3000:2:5851:F42D:40B1:8CCF
当服务器正在获取:
2001:468:3000:1:5851:F42D:40B1:8CCF
请注意,当我在同一设备上配置客户端和服务器时,它可以正常工作。客户端/服务器设备获取以下地址:
2001:468:3000:1:5851:F42D:40B1:8CCF
答案1
我的路由器上未激活 IPV6 的 IP 转发。以下命令可临时激活它:
sysctl -w net.ipv6.conf.all.forwarding=1
要永久激活,请在文件 /etc/sysctl.conf 中添加以下行:
net.ipv6.conf.all.forwarding=1
然后,要应用更改,请使用以下命令重新加载文件:
sysctl -p /etc/sysctl.conf
答案2
rm /etc/dhcpcd.conf
就我的情况而言,我的 Arch 服务器在原始设置后配置过度。此配置文件是可选的,删除它可让 SSH 的 IPv6 连接不再出现问题。