(base) [machine_C]~$ ssh user@machine_A Warning: Permanently added 'machine_A' (ED25519) to the list of known hosts. user@machine_A's password: Last login: Mon Jun 2 xx:xx:xx xxxx from xxx.xxx.xxx.xxx (base) [machine_A]~$ # 此处C机可以登录到A机
上面是C机成功登录到计算节点和提交节点的输出结果。
1 2 3 4 5 6 7
(base) [machine_D]~$ ssh user@machine_B ssh: connect to host machine_B port 22: No route to host (base) [machine_D]~$ # 此处D机无法登录到B机
(base) [machine_D]~$ ssh user@machine_A ssh: connect to host machine_A port 22: No route to host (base) [machine_D]~$ # 此处D机无法登录到A机
上面是D机登陆失败的输出结果。ssh报错内容是 No route to host
另外,C和D可以互相ssh到对方,但是服务器A无法ssh到C和D两者(B亦如此)。
二、原因排查
经过和AI的讨论分析,可能的原因包括下面这些:
D机器的路由表配置错误,缺少到A和B的路由或默认网关错误。
网络设备(如交换机/路由器)上的ACL或VLAN配置阻止了D机器到A机器的流量。
计算节点或提交节点的防火墙阻止了来自D机器的 IP的入站流量。
计算节点缺少返回到D机器所在子网的路由,导致无法响应。
要排查这些原因,可以使用 ip route show 指令展示路由表,或使用 traceroute 查看路由转发的链路。
下面是C机器上的路由表(IP地址已经经过模糊化处理):
1 2 3 4 5
(base) [machine_C]~$ ip route show default via 10.10.334.1 dev eno1 proto dhcp src 10.10.333.75 metric 100 10.10.332.0/22 dev eno1 proto kernel scope link src 10.10.333.75 metric 100 10.10.334.1 dev eno1 proto dhcp scope link src 10.10.333.75 metric 100 10.10.334.4 dev eno1 proto dhcp scope link src 10.10.333.75 metric 100
下面是D机器上的路由表(IP地址已经经过模糊化处理):
1 2 3
(base) [machine_D]~$ ip route show default via 10.10.334.1 dev enp0s25 proto static 10.10.0.0/16 dev enp0s25 proto kernel scope link src 10.10.333.37
删除原来的路由表:sudo ip route del 10.10.0.0/16 dev enp0s25
增加新的路由表:sudo ip route add 10.10.332.0/22 dev enp0s25
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
(base) [machine_D]~$ traceroute 10.10.339.430 traceroute to 10.10.339.430 (10.10.339.430), 30 hops max, 60 byte packets 1 machine_D (10.10.333.37) 3066.337 ms !H 3066.307 ms !H 3066.295 ms !H (base) [machine_D]~$ sudo ip route del 10.10.0.0/16 dev enp0s25 (base) [machine_D]~$ ip route show default via 10.10.334.1 dev enp0s25 proto static (base) [machine_D]~$ sudo ip route add 10.10.332.0/22 dev enp0s25 (base) [machine_D]~$ ip route show default via 10.10.334.1 dev enp0s25 proto static 10.10.332.0/22 dev enp0s25 scope link (base) [machine_D]~$ traceroute 10.10.339.430 traceroute to 10.10.339.430 (10.10.339.430), 30 hops max, 60 byte packets 1 sibsrouter-114.icb.ac.cn (10.10.334.1) 0.975 ms 1.189 ms 1.171 ms 2 * * * 3 * * * 4 * * * 5 * * * 6 * * * 7 *
(base) [machine_D]:~$ cd /etc/netplan/ (base) [machine_D]:/etc/netplan$ ls 50-cloud-init.yaml (base) [machine_D]:/etc/netplan$ sudo vim 50-cloud-init.yaml (base) [machine_D]:/etc/netplan$ sudo netplan apply (base) [machine_D]:/etc/netplan$ ip route show default via 10.10.334.1 dev enp0s25 proto static 10.10.332.0/22 dev enp0s25 proto kernel scope link src 10.10.333.37
# This file is generated from information provided by the datasource. Changes # to it will not persist across an instance reboot. To disable cloud-init's # network configuration capabilities, write a file # /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following: # network: {config: disabled} network: ethernets: enp0s25: addresses: - 10.10.333.37/22 # 这个位置之前的数字是16,对应的ip范围比较大。现在改为22,相当于缩小范围。 nameservers: addresses: - 10.10.334.4 search: [] routes: - to: default via: 10.10.334.1 version: 2
netplan apply 之后路由表即已经刷新。
备注:为了对IP信息保密处理,文章中所有IP地址信息都经过了模糊化和无效化处理。有效的IP地址段为 0.0.0.0~255.255.255.255 ,超出255的数字没有任何意义。在读者实际操作时,直接使用 ip route del , ip route add, netplan apply 进行处理即可,其中涉及的IP地址以实际为准。